From dc71eecfc2c07f457ab4d3b5c5653841288067e5 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 dc157c12de..728dc7d3c5 100644 --- a/Koha/CirculationRules.pm +++ b/Koha/CirculationRules.pm @@ -750,7 +750,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 @@ -761,7 +760,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, @@ -769,11 +768,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 62648edbf4..b01fe4a341 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -672,7 +672,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 8a7aec0d27..cb4911fa5f 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -240,7 +240,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 cc11c87a14..ddffdd0c9c 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 @@ -773,11 +773,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 - - "." - - The holds queue should prioritize filling a hold by matching the patron's home library with an item having a matching - pref: HoldsQueuePrioritizeBranch -- 2.42.0