From e44f763d176281dba3e8aa4632676e2bcc864795 Mon Sep 17 00:00:00 2001 From: Emmi Takkinen Date: Fri, 28 May 2021 11:04:16 +0300 Subject: [PATCH 2/6] Bug 23415: Rename OPACFineNoRenewals OPACFineNoRenewals no longer applies just to OPAC. To avoid confusion rename it as FineNoRenewals and also rename all occurences in code. To test, confirm everything works as described in previous test plans. Also prove t/db_dependent/Circulation.t Signed-off-by: Martin Renvoize Signed-off-by: Shi Yao Wang Signed-off-by: Martin Renvoize --- C4/Circulation.pm | 2 +- circ/renew.pl | 2 +- .../data/mysql/atomicupdate/bug_23415.pl | 18 +++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 5 ++-- .../admin/preferences/circulation.pref | 7 ++++- .../en/modules/admin/preferences/opac.pref | 8 +----- .../prog/en/modules/circ/circulation.tt | 2 +- .../prog/en/modules/members/moremember.tt | 2 +- opac/opac-user.pl | 4 +-- t/db_dependent/Circulation.t | 27 ++++++++++--------- 10 files changed, 49 insertions(+), 28 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_23415.pl diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 48185eb022..7e78a39098 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -4903,7 +4903,7 @@ sub _CanBookBeAutoRenewed { } if ( C4::Context->preference('OPACFineNoRenewalsBlockAutoRenew') ) { - my $fine_no_renewals = C4::Context->preference("OPACFineNoRenewals"); + my $fine_no_renewals = C4::Context->preference("FineNoRenewals"); my $amountoutstanding = C4::Context->preference("OPACFineNoRenewalsIncludeCredits") ? $patron->account->balance diff --git a/circ/renew.pl b/circ/renew.pl index 539b0eddeb..22274d6fa8 100755 --- a/circ/renew.pl +++ b/circ/renew.pl @@ -68,7 +68,7 @@ if ( $op eq 'cud-renew' && $barcode ) { $patron = $checkout->patron; $balance = $patron->account->balance; - my $amountlimit = C4::Context->preference("OPACFineNoRenewals"); + my $amountlimit = C4::Context->preference("FineNoRenewals"); if ( ( $patron->is_debarred || q{} ) lt dt_from_string()->ymd() ) { my $can_renew; diff --git a/installer/data/mysql/atomicupdate/bug_23415.pl b/installer/data/mysql/atomicupdate/bug_23415.pl new file mode 100755 index 0000000000..a4160f16ce --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_23415.pl @@ -0,0 +1,18 @@ +use Modern::Perl; + +return { + bug_number => "23415", + description => "Rename OPACFineNoRenewals", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do( + q{ + UPDATE systempreferences SET variable = "FineNoRenewals", explanation = "Fine limit above which user or staff cannot renew items" WHERE variable = "OPACFineNoRenewals"; + } + ); + + say $out "Updated system preference 'OPACFineNoRenewals'"; + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 76954d2022..92f625c75d 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -290,6 +290,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('FinesIncludeGracePeriod','1',NULL,'If enabled, fines calculations will include the grace period.','YesNo'), ('FinesLog','1',NULL,'If ON, log fines','YesNo'), ('finesMode','off','off|production','Choose the fines mode, \'off\' (no charges), \'production\' (accrue overdue fines). Requires accruefines cronjob.','Choice'), +('FineNoRenewals','100','','Fine limit above which user or staff cannot renew items','Integer'), ('ForceLibrarySelection','0',NULL,'Force staff to select a library when logging into the staff interface.','YesNo'), ('ForcePasswordResetWhenSetByStaff','0',NULL,'Force a staff created patron account to reset its password after its first OPAC login.','YesNo'), ('FRBRizeEditions','0','','If ON, Koha will query one or more ISBN web services for associated ISBNs and display an Editions tab on the details pages','YesNo'), @@ -504,8 +505,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OPACFallback', 'prog', 'bootstrap|prog', 'Define the fallback theme for the OPAC interface.', 'Themes'), ('OpacFavicon','','','Enter a complete URL to an image to replace the default Koha favicon on the OPAC','free'), ('OPACFineNoRenewals','100','','Fine limit above which user cannot renew books via OPAC','Integer'), -('OPACFineNoRenewalsBlockAutoRenew','0','','Block/Allow auto renewals if the patron owe more than OPACFineNoRenewals','YesNo'), -('OPACFineNoRenewalsIncludeCredits','1',NULL,'If enabled the value specified in OPACFineNoRenewals should include any unapplied account credits in the calculation','YesNo'), +('OPACFineNoRenewalsBlockAutoRenew','0','','Block/Allow auto renewals if the patron owe more than FineNoRenewals','YesNo'), +('OPACFineNoRenewalsIncludeCredits','1',NULL,'If enabled the value specified in FineNoRenewals should include any unapplied account credits in the calculation','YesNo'), ('OPACFinesTab','1','','If OFF the patron fines tab in the OPAC is disabled.','YesNo'), ('OPACFRBRizeEditions','0','','If ON, the OPAC will query one or more ISBN web services for associated ISBNs and display an Editions tab on the details pages','YesNo'), ('OpacHiddenItems','','','This syspref allows to define custom rules for hiding specific items at the OPAC. See https://wiki.koha-community.org/wiki/OpacHiddenItems for more information.','Textarea'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index ef3c7acc01..d6bd0ba710 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -496,7 +496,7 @@ Circulation: blockitem: block renewing only for this item. block: block renewing for all the patron's items. - - - If a patron owes more than the value of OPACFineNoRenewals, + - If a patron owes more than the value of FineNoRenewals, - pref: OPACFineNoRenewalsBlockAutoRenew choices: 1: block @@ -561,6 +561,11 @@ Circulation: open: "extend the loan period and set the checkout to be due at the library's open time." close: "shorten the loan period and set the checkout to be due at the library's close time." ignore: "do not consider the library's opening hours." + - + - Only allow patrons or staff to renew items if patron has less than + - pref: FineNoRenewals + class: currency + - [% local_currency %] in fines (leave blank to disable). Lost item policy: - - By default, set the LOST value of an item to diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index 5944febf80..7b77677caf 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -652,18 +652,12 @@ OPAC: none: "NULL" opacrenew: "'OPACRenew'" - as branchcode to store in the statistics table for renewals done in the OPAC. - - - - Only allow patrons to renew their own checkouts on the OPAC if they have less than - - pref: OPACFineNoRenewals - class: currency - - '[% local_currency %] in charges (leave blank to disable).' - -
NOTE: If set, confirmation dialog is shown when renewing for patron with charges from staff interface.' - - pref: OPACFineNoRenewalsIncludeCredits choices: 1: Include 0: "Don't include" - - outstanding/unapplied credits when applying the OPACFineNoRenewals rule to patrons. + - outstanding/unapplied credits when applying the FineNoRenewals rule to patrons. - - pref: OpacHiddenItems type: textarea diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index 4cd08600b9..e3605370e3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -1135,7 +1135,7 @@ [% UNLESS ( patron.borrowernumber ) %]window.onload=function(){ $('#findborrower').focus(); };[% END %] - var amountlimit = "[% Koha.Preference('OPACFineNoRenewals') | html %]"; + var amountlimit = "[% Koha.Preference('FineNoRenewals') | html %]"; var fines = "[% fines | $Price %]"; var MSG_CONFIRM_RENEW = _("The patron has a debt of %s\nAre you sure you want to renew checkout(s)?").format(fines); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt index 1c0b34dd04..819344051f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -807,7 +807,7 @@ CAN_user_circulate_manage_bookings = [% CAN_user_circulate_manage_bookings | $raw %] patron_borrowernumber = [% patron.borrowernumber | $raw %] - var amountlimit = "[% Koha.Preference('OPACFineNoRenewals') | html %]"; + var amountlimit = "[% Koha.Preference('FineNoRenewals') | html %]"; var fines = "[% fines | $Price %]"; var MSG_CONFIRM_RENEW = _("The patron has a debt of %s\n Are you sure you want to renew checkout(s)?").format(fines); diff --git a/opac/opac-user.pl b/opac/opac-user.pl index be5f63896b..75c4117d15 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -125,8 +125,8 @@ if ( $userdebarred || $borr->{'gonenoaddress'} || $borr->{'lost'} ) { } my $amountoutstanding = $patron->account->balance; -my $no_renewal_amt = C4::Context->preference('OPACFineNoRenewals'); -$no_renewal_amt = undef unless looks_like_number($no_renewal_amt); +my $no_renewal_amt = C4::Context->preference( 'FineNoRenewals' ); +$no_renewal_amt = undef unless looks_like_number( $no_renewal_amt ); my $amountoutstandingfornewal = C4::Context->preference("OPACFineNoRenewalsIncludeCredits") ? $amountoutstanding diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index eb70c6f6a0..62c695a994 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -1349,9 +1349,9 @@ subtest "CanBookBeRenewed tests" => sub { } } ); - C4::Context->set_preference( 'OPACFineNoRenewalsBlockAutoRenew', '1' ); - C4::Context->set_preference( 'OPACFineNoRenewals', '10' ); - C4::Context->set_preference( 'OPACFineNoRenewalsIncludeCredits', '1' ); + C4::Context->set_preference('OPACFineNoRenewalsBlockAutoRenew','1'); + C4::Context->set_preference('FineNoRenewals','10'); + C4::Context->set_preference('OPACFineNoRenewalsIncludeCredit','1'); my $fines_amount = 5; my $account = Koha::Account->new( { patron_id => $renewing_borrowernumber } ); $account->add_debit( @@ -1363,9 +1363,10 @@ subtest "CanBookBeRenewed tests" => sub { description => "Some fines" } )->status('RETURNED')->store; - ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue ); + ( $renewokay, $error ) = + CanBookBeRenewed( $renewing_borrower_obj, $issue ); is( $renewokay, 1, 'Renew, even if renewal is automatic' ); - is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 5' ); + is( $error, 'auto_renew', 'Can auto renew, FineNoRenewals=10, patron has 5' ); $account->add_debit( { @@ -1376,9 +1377,10 @@ subtest "CanBookBeRenewed tests" => sub { description => "Some fines" } )->status('RETURNED')->store; - ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue ); + ( $renewokay, $error ) = + CanBookBeRenewed( $renewing_borrower_obj, $issue ); is( $renewokay, 1, 'Renew, even if renewal is automatic' ); - is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 10' ); + is( $error, 'auto_renew', 'Can auto renew, FineNoRenewals=10, patron has 10' ); $account->add_debit( { @@ -1389,9 +1391,10 @@ subtest "CanBookBeRenewed tests" => sub { description => "Some fines" } )->status('RETURNED')->store; - ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue ); - is( $renewokay, 0, 'Do not renew, renewal is automatic' ); - is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, patron has 15' ); + ( $renewokay, $error ) = + CanBookBeRenewed( $renewing_borrower_obj, $issue ); + is( $renewokay, 0, 'Do not renew, renewal is automatic' ); + is( $error, 'auto_too_much_oweing', 'Cannot auto renew, FineNoRenewals=10, patron has 15' ); $account->add_credit( { @@ -1405,7 +1408,7 @@ subtest "CanBookBeRenewed tests" => sub { is( $renewokay, 1, 'Renew, even if renewal is automatic' ); is( $error, 'auto_renew', - 'Can auto renew, OPACFineNoRenewals=10, OPACFineNoRenewalsIncludeCredits=1, patron has 15 debt, 5 credit' + 'Can auto renew, FineNoRenewals=10, OPACFineNoRenewalsIncludeCredits=1, patron has 15 debt, 5 credit' ); C4::Context->set_preference( 'OPACFineNoRenewalsIncludeCredits', '0' ); @@ -1413,7 +1416,7 @@ subtest "CanBookBeRenewed tests" => sub { is( $renewokay, 0, 'Do not renew, renewal is automatic' ); is( $error, 'auto_too_much_oweing', - 'Cannot auto renew, OPACFineNoRenewals=10, OPACFineNoRenewalsIncludeCredits=1, patron has 15 debt, 5 credit' + 'Cannot auto renew, FineNoRenewals=10, OPACFineNoRenewalsIncludeCredits=1, patron has 15 debt, 5 credit' ); $dbh->do( 'DELETE FROM accountlines WHERE borrowernumber=?', undef, $renewing_borrowernumber ); -- 2.34.1