From 4df93e4b44e8dbeca51932fb31817ee25979d5f8 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Tue, 7 Oct 2025 15:53:26 +0000 Subject: [PATCH] Bug 30331: Rename RenewalPeriodBase as ManualRenewalPeriodBase and add AutomaticRenewalPeriodBase sys pref --- C4/Circulation.pm | 6 ++-- C4/UsageStats.pm | 3 +- .../data/mysql/atomicupdate/bug_30331.pl | 32 +++++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 3 +- .../admin/preferences/circulation.pref | 11 +++++-- 5 files changed, 48 insertions(+), 7 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_30331.pl diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 0a8df342638..d96fd7c0e12 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3327,7 +3327,7 @@ sub CanBookBeRenewed { # CHECK FOR BOOKINGS if ( $item->bookings->count ) { my $startdate = - ( C4::Context->preference('RenewalPeriodBase') eq 'date_due' ) + ( C4::Context->preference('ManualRenewalPeriodBase') eq 'date_due' ) ? dt_from_string( $issue->date_due, 'sql' ) : dt_from_string(); my $datedue = CalcDateDue( $startdate, $item->effective_itemtype, $branchcode, $patron, 'is a renewal' ); @@ -3467,12 +3467,12 @@ sub AddRenewal { # If the due date wasn't specified, calculate it by adding the # book's loan length to today's date or the current due date - # based on the value of the RenewalPeriodBase syspref. + # based on the value of the ManualRenewalPeriodBase syspref. my $itemtype = $item_object->effective_itemtype; unless ($datedue) { $datedue = - ( C4::Context->preference('RenewalPeriodBase') eq 'date_due' ) + ( C4::Context->preference('ManualRenewalPeriodBase') eq 'date_due' ) ? dt_from_string( $issue->date_due, 'sql' ) : dt_from_string(); $datedue = CalcDateDue( $datedue, $itemtype, $circ_library->branchcode, $patron, 'is a renewal' ); diff --git a/C4/UsageStats.pm b/C4/UsageStats.pm index 4492080c097..7b5beb78845 100644 --- a/C4/UsageStats.pm +++ b/C4/UsageStats.pm @@ -180,7 +180,8 @@ sub _shared_preferences { IssueLostItem IssuingInProcess OverduesBlockCirc - RenewalPeriodBase + ManualRenewalPeriodBase + AutomaticRenewalPeriodBase RenewalSendNotice ReturnBeforeExpiry TransfersMaxDaysWarning diff --git a/installer/data/mysql/atomicupdate/bug_30331.pl b/installer/data/mysql/atomicupdate/bug_30331.pl new file mode 100755 index 00000000000..7b95aa4977e --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_30331.pl @@ -0,0 +1,32 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "30331", + description => + "Rename RenewalPeriodBase as ManualRenewalPeriodBase AND add new AutomaticRenewalPeriodBase system preference", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + #Get the old value before changing anything + my $base_period = C4::Context->preference('RenewalPeriodBase'); + + $dbh->do( + q{ + UPDATE systempreferences SET variable = 'ManualRenewalPeriodBase' WHERE variable = 'RenewalPeriodBase' + } + ); + + say_success( $out, "System preference RenewalPeriodBase updated to ManualRenewalPeriodBase" ); + + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences (`variable`,`value`,`options`,`explanation`,`type`) + VALUES ('AutomaticRenewalPeriodBase', ? ,'date_due|now','Set whether the renewal date should be counted from the date_due or from the moment the Patron asks for renewal, for automatic renewals','Choice') + }, undef, $base_period + ); + + say_success( $out, "System preference AutomaticRenewalPeriodBase added." ); + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 0d77d5ba947..a7549a8d262 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -100,6 +100,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('AutomaticConfirmTransfer','0',NULL,'Defines whether transfers should be automatically confirmed at checkin if modal dismissed','YesNo'), ('AutomaticEmailReceipts','0','','Send email receipts for payments and write-offs','YesNo'), ('AutomaticItemReturn','1',NULL,'If ON, Koha will automatically set up a transfer of this item to its homebranch','YesNo'), +('AutomaticRenewalPeriodBase','date_due','date_due|now','Set whether the renewal date should be counted from the date_due or from the moment the Patron asks for renewal, for automatic renewals ','Choice'), ('autoMemberNum','0','','If ON, patron number is auto-calculated','YesNo'), ('AutoRemoveOverduesRestrictions','no','no|when_no_overdue|when_no_overdue_causing_debarment', 'Defines if and on what conditions OVERDUES debarments should automatically be lifted when overdue items are returned by the patron.','Choice'), ('AutoRenewalNotices','preferences','cron|preferences|never','How should Koha determine whether to end autorenewal notices','Choice'), @@ -406,6 +407,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('makePreviousSerialAvailable','0','','make previous serial automatically available when collecting a new serial. Please note that the item-level_itypes syspref must be set to specific item.','YesNo'), ('Mana','2',NULL,'request to Mana Webservice. Mana centralize common information between other Koha to facilitate the creation of new subscriptions, vendors, report queries etc... You can search, share, import and comment the content of Mana.','Choice'), ('ManaToken','',NULL,'Security token used for authentication on Mana KB service (anti spam)','Textarea'), +('ManualRenewalPeriodBase','date_due','date_due|now','Set whether the renewal date should be counted from the date_due or from the moment the Patron asks for renewal, for manual renewals ','Choice'), ('MARCAuthorityControlField008','|| aca||aabn | a|a d',NULL,'Define the contents of MARC21 authority control field 008 position 06-39','Textarea'), ('MarcFieldDocURL', '', NULL, 'URL used for MARC field documentation. Following substitutions are available: {MARC} = marc flavour, eg. "MARC21" or "UNIMARC". {FIELD} = field number, eg. "000" or "048". {LANG} = user language, eg. "en" or "fi-FI"', 'free'), ('MarcFieldForCreatorId','',NULL,'Where to store the borrowernumber of the record''s creator','Free'), @@ -679,7 +681,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('RenewAccruingItemInOpac','0','','If enabled, when the fines on an item accruing is paid off in the OPAC via a payment plugin, attempt to renew that item. If the syspref "RenewalPeriodBase" is set to "due date", renewed items may still be overdue','YesNo'), ('RenewAccruingItemWhenPaid','0','','If enabled, when the fines on an item accruing is paid off, attempt to renew that item. If the syspref "RenewalPeriodBase" is set to "due date", renewed items may still be overdue','YesNo'), ('RenewalLog','0','','If ON, log information about renewals','YesNo'), -('RenewalPeriodBase','date_due','date_due|now','Set whether the renewal date should be counted from the date_due or from the moment the Patron asks for renewal ','Choice'), ('RenewalSendNotice','0','',NULL,'YesNo'), ('RenewSerialAddsSuggestion','0',NULL,'If ON, adds a new suggestion at serial subscription renewal','YesNo'), ('RentalFeesCheckoutConfirmation', '0', NULL , 'Allow user to confirm when checking out an item with rental fees.', 'YesNo'), 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 82070552d6c..19e701cad0d 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 @@ -345,8 +345,15 @@ Circulation: exact_time: exact time - . Only relevant for loans calculated in days, hourly loans are not affected. - - - When renewing checkouts, base the new due date on - - pref: RenewalPeriodBase + - When renewing checkouts manually, base the new due date on + - pref: ManualRenewalPeriodBase + choices: + date_due: the old due date of the checkout + now: the current date + - . + - + - When renewing checkouts automaticaly, base the new due date on + - pref: AutomaticRenewalPeriodBase choices: date_due: the old due date of the checkout now: the current date -- 2.39.5