From db05a34ddc597676f9e1aaac572456d8f9a5ebd4 Mon Sep 17 00:00:00 2001 From: Emmi Takkinen Date: Fri, 28 May 2021 11:04:16 +0300 Subject: [PATCH] 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 --- C4/Circulation.pm | 2 +- circ/renew.pl | 2 +- .../Bug_23415-Rename_OPACFineNoRenewals.perl | 12 ++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 6 +++--- .../en/modules/admin/preferences/circulation.pref | 7 ++++++- .../prog/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 | 2 +- t/db_dependent/Circulation.t | 12 ++++++------ 10 files changed, 33 insertions(+), 22 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/Bug_23415-Rename_OPACFineNoRenewals.perl diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 10db0d226a..62dc86dfc3 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2823,7 +2823,7 @@ sub CanBookBeRenewed { } 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("OPACFineNoRenewalsIncludeCredit") ? $patron->account->balance diff --git a/circ/renew.pl b/circ/renew.pl index 1d093ba69c..ff64326883 100755 --- a/circ/renew.pl +++ b/circ/renew.pl @@ -69,7 +69,7 @@ if ($barcode) { $borrower = $issue->borrower(); my $patron = Koha::Patrons->find($borrower->borrowernumber); $balance = $patron->account->balance; - my $amountlimit = C4::Context->preference("OPACFineNoRenewals"); + my $amountlimit = C4::Context->preference("FineNoRenewals"); if ( ( $borrower->debarred() || q{} ) lt dt_from_string()->ymd() ) { my $can_renew; diff --git a/installer/data/mysql/atomicupdate/Bug_23415-Rename_OPACFineNoRenewals.perl b/installer/data/mysql/atomicupdate/Bug_23415-Rename_OPACFineNoRenewals.perl new file mode 100644 index 0000000000..9094806172 --- /dev/null +++ b/installer/data/mysql/atomicupdate/Bug_23415-Rename_OPACFineNoRenewals.perl @@ -0,0 +1,12 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + # you can use $dbh here like: + # $dbh->do( "ALTER TABLE biblio ADD COLUMN badtaste int" ); + + $dbh->do(q{ + UPDATE systempreferences SET variable = "FineNoRenewals" where variable = "OPACFineNoRenewals"; + }); + + # Always end with this (adjust the bug info) + NewVersion( $DBversion, 23415, "Rename OPACFineNoRenewals"); +} diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 0a86168ee0..90990640dc 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -218,6 +218,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'), ('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'), ('GDPR_Policy','','Enforced|Permissive|Disabled','General Data Protection Regulation - policy', 'Choice'), ('TaxRates','0','','Default Goods and Services tax rate NOT in %, but in numeric form (0.12 for 12%), set to 0 to disable GST','Integer'), @@ -338,7 +339,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('maxItemsInSearchResults','20',NULL,'Specify the maximum number of items to display for each result on a page of results','free'), ('MaxOpenSuggestions','',NULL,'Limit the number of open suggestions a patron can have at once','Integer'), ('maxoutstanding','5','','maximum amount withstanding to be able make holds','Integer'), -('OPACFineNoRenewalsBlockAutoRenew','0','','Block/Allow auto renewals if the patron owe more than OPACFineNoRenewals','YesNo'), +('OPACFineNoRenewalsBlockAutoRenew','0','','Block/Allow auto renewals if the patron owe more than FineNoRenewals','YesNo'), ('maxRecordsForFacets','20',NULL,NULL,'Integer'), ('maxreserves','50','','Define maximum number of holds a patron can place','Integer'), ('MaxSearchResultsItemsPerRecordStatusCheck','20','','Max number of items per record for which to check transit and hold status','Integer'), @@ -407,7 +408,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OpacExportOptions','bibtex,dc,marcxml,marc8,utf8,marcstd,mods,ris,isbd','','Define export options available on OPAC detail page.','multiple'), ('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'), ('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 http://wiki.koha-community.org/wiki/OpacHiddenItems for more information.','Textarea'), @@ -492,7 +492,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OpenURLResolverURL', '', NULL, 'URL of OpenURL Resolver', 'Free'), ('OpenURLText', '', NULL, 'Text of OpenURL links (or image title if OpenURLImageLocation is defined)', 'Free'), ('OpenURLImageLocation', '', NULL, 'Location of image for OpenURL links', 'Free'), -('OPACFineNoRenewalsIncludeCredits','1',NULL,'If enabled the value specified in OPACFineNoRenewals should include any unapplied account credits in the calculation','YesNo'), +('OPACFineNoRenewalsIncludeCredits','1',NULL,'If enabled the value specified in FineNoRenewals should include any unapplied account credits in the calculation','YesNo'), ('OPACShowOpenURL', '0', NULL, 'Enable display of OpenURL links in OPAC search results and detail page', 'YesNo'), ('OPACOpenURLItemTypes', '', NULL, 'Show the OpenURL link only for these item types', 'Free'), ('OrderPdfFormat','pdfformat::layout3pages','Controls what script is used for printing (basketgroups)','','free'), 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 0bf3b7c518..8d73a81769 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 @@ -519,7 +519,7 @@ Circulation: 0: allow - renewing of 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 @@ -551,6 +551,11 @@ Circulation: - "
ccode: [NEWFIC,NULL,DVD]" - "
itype: [NEWBK,\"\"]" - "
NOTE: The word 'NULL' can be used to block renewal on undefined fields, while an empty string \"\" will block on an empty (but defined) field." + - + - 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). Checkin policy: - - pref: TrapHoldsOnOrder 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 553c2b520f..70892d3092 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 @@ -597,18 +597,12 @@ OPAC: none: "NULL" opacrenew: "'OPACRenew'" - as branchcode to store in the statistics table. - - - - Only allow patrons to renew their own books on the OPAC if they have less than - - pref: OPACFineNoRenewals - class: currency - - '[% local_currency %] in fines (leave blank to disable). - -
NOTE: If set, confirmation dialog is shown when renewing for patron with fines 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: OPACViewOthersSuggestions choices: 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 432a140be0..345fe93a48 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -1212,7 +1212,7 @@ [% UNLESS ( patron.borrowernumber ) %][% UNLESS ( borrowers ) %]window.onload=function(){ $('#findborrower').focus(); };[% END %][% END %] - var amountlimit = "[% Koha.Preference('OPACFineNoRenewals') | html %]"; + var amountlimit = "[% Koha.Preference('FineNoRenewals') | html %]"; var fines = "[% fines | html %]"; var MSG_CONFRIM_RENEW = _("The patron has a debt of %s.\n Are 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 ff2ca56491..4ea468bef8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -965,7 +965,7 @@ columns_settings_issues_table = [% TablesSettings.GetColumns( 'members', 'moremember', 'issues-table', 'json' ) | $raw %] - var amountlimit = "[% Koha.Preference('OPACFineNoRenewals') | html %]"; + var amountlimit = "[% Koha.Preference('FineNoRenewals') | html %]"; var fines = "[% fines | html %]"; var MSG_CONFRIM_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 7a9c774d67..f6a884c9ea 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -127,7 +127,7 @@ if ( $userdebarred || $borr->{'gonenoaddress'} || $borr->{'lost'} ) { } my $amountoutstanding = $patron->account->balance; -my $no_renewal_amt = C4::Context->preference( 'OPACFineNoRenewals' ); +my $no_renewal_amt = C4::Context->preference( 'FineNoRenewals' ); $no_renewal_amt = undef unless looks_like_number( $no_renewal_amt ); my $amountoutstandingfornewal = C4::Context->preference("OPACFineNoRenewalsIncludeCredit") diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index 6266d14561..38b67c0ea0 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -1071,7 +1071,7 @@ subtest "CanBookBeRenewed tests" => sub { } ); C4::Context->set_preference('OPACFineNoRenewalsBlockAutoRenew','1'); - C4::Context->set_preference('OPACFineNoRenewals','10'); + 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}); @@ -1087,7 +1087,7 @@ subtest "CanBookBeRenewed tests" => sub { ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); is( $renewokay, 0, 'Do not renew, 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( { @@ -1101,7 +1101,7 @@ subtest "CanBookBeRenewed tests" => sub { ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); is( $renewokay, 0, 'Do not renew, 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( { @@ -1115,7 +1115,7 @@ subtest "CanBookBeRenewed tests" => sub { ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); is( $renewokay, 0, 'Do not renew, renewal is automatic' ); - is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, patron has 15' ); + is( $error, 'auto_too_much_oweing', 'Cannot auto renew, FineNoRenewals=10, patron has 15' ); $account->add_credit( { @@ -1128,13 +1128,13 @@ subtest "CanBookBeRenewed tests" => sub { ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); is( $renewokay, 0, 'Do not renew, renewal is automatic' ); - is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, OPACFineNoRenewalsIncludeCredit=1, patron has 15 debt, 5 credit' ); + is( $error, 'auto_renew', 'Can auto renew, FineNoRenewals=10, OPACFineNoRenewalsIncludeCredit=1, patron has 15 debt, 5 credit' ); C4::Context->set_preference('OPACFineNoRenewalsIncludeCredit','0'); ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); is( $renewokay, 0, 'Do not renew, renewal is automatic' ); - is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, OPACFineNoRenewalsIncludeCredit=1, patron has 15 debt, 5 credit' ); + is( $error, 'auto_too_much_oweing', 'Cannot auto renew, FineNoRenewals=10, OPACFineNoRenewalsIncludeCredit=1, patron has 15 debt, 5 credit' ); $dbh->do('DELETE FROM accountlines WHERE borrowernumber=?', undef, $renewing_borrowernumber); C4::Context->set_preference('OPACFineNoRenewalsIncludeCredit','1'); -- 2.25.1