From 44f53cc7d30e433a5a51d5f115f428402a6cc5d9 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 28 Jun 2022 12:14:41 -0300 Subject: [PATCH] Bug 25711: Deprecate ExpireReservesMaxPickUpDelayCharge Signed-off-by: Tomas Cohen Arazi --- Koha/CirculationRules.pm | 8 +----- Koha/Hold.pm | 2 +- .../data/mysql/atomicupdate/bug_25711.pl | 26 +++++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 - .../admin/preferences/circulation.pref | 5 ---- 5 files changed, 28 insertions(+), 14 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_25711.pl diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm index d849fb4617..c8609add66 100644 --- a/Koha/CirculationRules.pm +++ b/Koha/CirculationRules.pm @@ -671,7 +671,6 @@ sub get_effective_daysmode { =head3 get_effective_expire_reserves_charge Return the value for expire_reserves_charge defined in the circulation rules. -If not defined (or empty string), the value of the system preference ExpireReservesMaxPickUpDelayCharge is returned =cut @@ -682,7 +681,7 @@ sub get_effective_expire_reserves_charge { my $branchcode = $params->{branchcode}; my $categorycode = $params->{categorycode}; - my $expire_reserves_charge_rule = $class->get_effective_rule( + return $class->get_effective_rule( { itemtype => $itemtype, branchcode => $branchcode, @@ -690,11 +689,6 @@ sub get_effective_expire_reserves_charge { rule_name => 'expire_reserves_charge', } ); - - # return the rule value (incl. 0) if rule found so there's an object in the variable, - # or return default value from sysprefs when rule wasn't found and there's undef - return $expire_reserves_charge_rule ? $expire_reserves_charge_rule->rule_value : C4::Context->preference("ExpireReservesMaxPickUpDelayCharge"); - } =head3 type diff --git a/Koha/Hold.pm b/Koha/Hold.pm index 84218eb416..8204158b9e 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -629,7 +629,7 @@ my $cancel_hold = $hold->cancel( Cancel a hold: - The hold will be moved to the old_reserves table with a priority=0 - The priority of other holds will be updated -- The patron will be charge (see ExpireReservesMaxPickUpDelayCharge) if the charge_cancel_fee parameter is set +- The patron will be charged if charge_cancel_fee parameter is set (controlled by the expire_reserves_charge circ rule) - The canceled hold will have the cancellation reason added to old_reserves.cancellation_reason if one is passed in - a CANCEL HOLDS log will be done if the pref HoldsLog is on diff --git a/installer/data/mysql/atomicupdate/bug_25711.pl b/installer/data/mysql/atomicupdate/bug_25711.pl new file mode 100755 index 0000000000..10e682c4d4 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_25711.pl @@ -0,0 +1,26 @@ +use Modern::Perl; + +return { + bug_number => "25711", + description => "Move ExpireReservesMaxPickUpDelayCharge to the circulation rules", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + + my ($expire_reserves_charge) = $dbh->selectrow_array( q{ + SELECT value FROM systempreferences + WHERE variable='ExpireReservesMaxPickUpDelayCharge'; + }); + + $expire_reserves_charge //= 0; + + $dbh->do(qq{ + INSERT INTO circulation_rules + ( categorycode, branchcode, itemtype, rule_name, rule_value ) + VALUES + ( NULL, NULL, NULL, 'expire_reserves_charge', $expire_reserves_charge ); + }); + + say $out "ExpireReservesMaxPickUpDelayCharge migrated to the expire_reserves_charge circulation rule"; + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 9a5cb2e0a8..d65f8b5ca4 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -218,7 +218,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('ExpireReservesAutoFill','0',NULL,'Automatically fill the next hold with a automatically canceled expired waiting hold.','YesNo'), ('ExpireReservesAutoFillEmail','', NULL,'Send email notification of hold filled from automatically expired/cancelled hold to this address. If not defined, Koha will fallback to the library reply-to address','Free'), ('ExpireReservesMaxPickUpDelay','0','','Enabling this allows holds to expire automatically if they have not been picked by within the time period specified in ReservesMaxPickUpDelay','YesNo'), -('ExpireReservesMaxPickUpDelayCharge','0',NULL,'If ExpireReservesMaxPickUpDelay is enabled, and this field has a non-zero value, than a borrower whose waiting hold has expired will be charged this amount.','free'), ('ExpireReservesOnHolidays', '1', NULL, 'If false, reserves at a library will not be canceled on days the library is not open.', 'YesNo'), ('ExcludeHolidaysFromMaxPickUpDelay', '0', NULL, 'If ON, reserves max pickup delay takes into accountthe closed days.', 'YesNo'), ('ExportCircHistory', 0, NULL, "Display the export circulation options", '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 f99af038e8..c673a22e00 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 @@ -768,11 +768,6 @@ Circulation: class: email - . If no address is defined here, the email will be sent to the library's reply-to address. - '
NOTE: These system preferences require the misc/cronjobs/holds/cancel_expired_holds.pl cronjob. Ask your system administrator to schedule it.
' - - - - If using ExpireReservesMaxPickUpDelay, charge a patron who allows their waiting hold to expire a fee of - - pref: ExpireReservesMaxPickUpDelayCharge - class: currency - - "." - - Satisfy holds using items from the libraries - pref: StaticHoldsQueueWeight -- 2.37.3