Bugzilla – Attachment 185274 Details for
Bug 23415
Notify patron fines when renewing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23415: (QA follow-up) Move to Circulation::CanBookBeRenewed
0005-Bug-23415-QA-follow-up-Move-to-Circulation-CanBookBe.patch (text/plain), 5.62 KB, created by
Emmi Takkinen
on 2025-08-08 12:19:43 UTC
(
hide
)
Description:
Bug 23415: (QA follow-up) Move to Circulation::CanBookBeRenewed
Filename:
MIME Type:
Creator:
Emmi Takkinen
Created:
2025-08-08 12:19:43 UTC
Size:
5.62 KB
patch
obsolete
>From 9f495b2d7f37bf275e63c03e450899ab781d626a Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 16 Feb 2024 14:57:33 +0000 >Subject: [PATCH 5/6] Bug 23415: (QA follow-up) Move to > Circulation::CanBookBeRenewed > >This moves the basic calculation for too_much_oweing out of the >controller and into the class method. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > C4/Circulation.pm | 4 ++++ > circ/renew.pl | 15 +++++++-------- > .../intranet-tmpl/prog/en/modules/circ/renew.tt | 2 +- > t/db_dependent/Circulation.t | 11 ++++++++++- > 4 files changed, 22 insertions(+), 10 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 7e78a39098..d696184a6d 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -3174,9 +3174,11 @@ sub CanBookBeRenewed { > && $issuing_rule->{unseen_renewals_allowed} == ( $issue->unseen_renewals + 1 ) ) ? 1 : 0; > > my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing'); >+ my $finesblockrenewing = C4::Context->preference("FineNoRenewals"); > my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing'); > my $restricted = $patron->is_debarred; > my $hasoverdues = $patron->has_overdues; >+ my $balance = $patron->account->balance; > > if ( $restricted and $restrictionblockrenewing ) { > return ( 0, 'restriction' ); >@@ -3184,6 +3186,8 @@ sub CanBookBeRenewed { > || ( $issue->is_overdue and $overduesblockrenewing eq 'blockitem' ) ) > { > return ( 0, 'overdue' ); >+ } elsif ( $finesblockrenewing && $balance > $finesblockrenewing ) { >+ return ( 0, 'too_much_oweing'); > } > > } >diff --git a/circ/renew.pl b/circ/renew.pl >index b8de0d3614..7d1b304083 100755 >--- a/circ/renew.pl >+++ b/circ/renew.pl >@@ -67,9 +67,6 @@ if ( $op eq 'cud-renew' && $barcode ) { > > $patron = $checkout->patron; > >- $balance = $patron->account->balance; >- my $amountlimit = C4::Context->preference("FineNoRenewals"); >- > if ( ( $patron->is_debarred || q{} ) lt dt_from_string()->ymd() ) { > my $can_renew; > my $info; >@@ -94,12 +91,15 @@ if ( $op eq 'cud-renew' && $barcode ) { > ); > } > >- if ( $balance > $amountlimit ) { >- $error = "too_much_debt"; >- $can_renew = 0; >+ if ( $error && ($error eq 'too_much_oweing' or $error eq 'auto_too_much_oweing') ) { > if ($override_debt) { > $can_renew = 1; >- $error = undef; >+ $error = undef; >+ } >+ else { >+ $balance = $patron->account->balance; >+ $template->param( balance => $balance ); >+ $can_renew = 0; > } > } > >@@ -137,7 +137,6 @@ if ( $op eq 'cud-renew' && $barcode ) { > error => $error, > soonestrenewdate => $soonest_renew_date, > latestautorenewdate => $latest_auto_renew_date, >- balance => $balance, > ); > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt >index d74f1ea834..434b2435a4 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt >@@ -138,7 +138,7 @@ > <button type="submit" class="btn btn-default approve"><i class="fa fa-check"></i> Override limit and renew</button> > </form> > [% END %] >- [% ELSIF error == "too_much_debt" %] >+ [% ELSIF error == "too_much_oweing" %] > > <li>The patron has a debt of [% balance | $Price %].</li> > <form method="post" action="/cgi-bin/koha/circ/renew.pl"> >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 62c695a994..d0ba740d6e 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -495,7 +495,7 @@ subtest "GetIssuingCharges tests" => sub { > > my ( $reused_itemnumber_1, $reused_itemnumber_2 ); > subtest "CanBookBeRenewed tests" => sub { >- plan tests => 114; >+ plan tests => 116; > > C4::Context->set_preference( 'ItemsDeniedRenewal', '' ); > >@@ -1821,6 +1821,8 @@ subtest "CanBookBeRenewed tests" => sub { > "Account line description must not contain 'Lost Items ', but be title, barcode, itemcallnumber" > ); > >+ t::lib::Mocks::mock_preference('FineNoRenewals', 0); >+ > # Recalls > t::lib::Mocks::mock_preference( 'UseRecalls', 1 ); > Koha::CirculationRules->set_rules( >@@ -1897,6 +1899,13 @@ subtest "CanBookBeRenewed tests" => sub { > ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $recall_issue ); > is( $renewokay, 1, 'Can renew item if biblio-level recall has already been allocated an item' ); > $recall->set_cancelled; >+ >+ # Too much debt >+ t::lib::Mocks::mock_preference('FineNoRenewals', 1); >+ ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_1); >+ is( $renewokay, 0, 'Cannot renew, too much debt and FineNoRenewals=1' ); >+ is( $error, 'too_much_oweing', 'Cannot renew, debt not allowed (returned code is too_much_oweing)'); >+ C4::Context->dbh->do("DELETE FROM accountlines"); > }; > > subtest "CanBookBeRenewed | bookings" => sub { >-- >2.34.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23415
:
92039
|
92541
|
98442
|
98634
|
98996
|
98997
|
105893
|
105894
|
108392
|
109871
|
109872
|
109876
|
109880
|
116919
|
116920
|
116921
|
116922
|
118175
|
118176
|
118177
|
118178
|
118183
|
119300
|
119301
|
119302
|
119303
|
121472
|
139670
|
139671
|
139672
|
139673
|
139674
|
146415
|
148198
|
148199
|
148200
|
148201
|
148202
|
152776
|
152777
|
152778
|
152779
|
152780
|
152781
|
154595
|
154596
|
154597
|
154598
|
154599
|
154600
|
158302
|
158303
|
158304
|
158305
|
158306
|
158307
|
161964
|
161965
|
161966
|
161967
|
161968
|
161969
|
162171
|
162172
|
162173
|
162174
|
162175
|
162176
|
162177
|
162178
|
162179
|
162180
|
171620
|
171621
|
171622
|
171623
|
171983
|
171984
|
171985
|
171986
|
172906
|
172907
|
172908
|
172909
|
172910
|
185270
|
185271
|
185272
|
185273
| 185274 |
185275