From 04e9cb2223e5c3706d345e994f7b12acfc3dfd0c Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 4 May 2015 09:33:31 -0400 Subject: [PATCH] Bug 14137 - Allow ExpireReservesMaxPickUpDelayCharge to be used without ExpireReservesMaxPickUpDelay Some libraries would like to be able to use ExpireReservesMaxPickUpDelayCharge without ExpireReservesMaxPickUpDelay. ExpireReservesMaxPickUpDelay automatically cancels the holds but some librarians would prefer to cancel the holds manually but still have the patron's charged the fee for allowing a waiting hold to become expired and canceled. Test Plan: 1) Apply this patch 2) Set a fee amount in ExpireReservesMaxPickUpDelayCharge 3) Cancel a hold from the "holds over" tab 4) View the patron record, note the fee has been added Signed-off-by: Jason Burds --- C4/Reserves.pm | 24 ++++++++++++++++++++ .../en/modules/admin/preferences/circulation.pref | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 6ed1543..be99479 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -1052,6 +1052,30 @@ sub CancelReserve { my $reserve = GetReserve( $reserve_id ); if ($reserve) { + # Charge for canceled reserves that have been waiting too long + if ( $reserve->{found} eq 'W' + && $reserve->{priority} == 0 + && C4::Context->preference("ExpireReservesMaxPickUpDelay") ) + { + my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay"); + + my $now = dt_from_string(); + my $waitingdate = dt_from_string( $reserve->{waitingdate} ); + my $duration = $waitingdate->delta_days($now); + my $days_waiting = $duration->in_units('days'); + if ( $days_waiting > $max_pickup_delay ) { + my $charge = C4::Context->preference("ExpireReservesMaxPickUpDelayCharge"); + if ($charge) { + manualinvoice( + $reserve->{'borrowernumber'}, + $reserve->{'itemnumber'}, + 'Hold waiting too long', + 'F', $charge + ); + } + } + } + my $query = " UPDATE reserves SET cancellationdate = now(), 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 6a0954d..80477b1 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 @@ -484,7 +484,7 @@ Circulation: no: "Don't allow" - "holds to expire automatically if they have not been picked by within the time period specified in ReservesMaxPickUpDelay" - - - If using ExpireReservesMaxPickUpDelay, charge a borrower who allows his or her waiting hold to expire a fee of + - Charge a borrower who allows his or her waiting hold to expire be canceled a fee of - pref: ExpireReservesMaxPickUpDelayCharge class: currency - -- 1.7.10.4