From 8f705ac59096c79d9c6cd1b580e40d2b9db4ed3c Mon Sep 17 00:00:00 2001 From: Magnus Enger Date: Thu, 28 Sep 2017 11:19:09 +0000 Subject: [PATCH] Bug 19260 - Restore ExpireReservesMaxPickupDelay It looks like bug 12063 accidentally removed the functionality of ExpireReservesMaxPickupDelay. This patch aims to restore it. To test: Before applying the patch: - Make sure ExpireReservesMaxPickUpDelay = "Don't allow" - Check out a book to a user - Add a reservastion on it for another user - Check the hold in the database. You should have: found = W, waitingdate = today, expirationdate = today + the value of ReservesMaxPickUpDelay The problem here is the expirationdate, it should be empty when ExpireReservesMaxPickUpDelay = "Don't allow". After applying the patch: - Repeat the steps above - expirationdate should now be NULL Please be creative when testing this. I am not sure I have seen all the possible concequences. Signed-off-by: Caroline Cyr La Rose --- Koha/Hold.pm | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/Koha/Hold.pm b/Koha/Hold.pm index d27bbae..7905c39 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -129,26 +129,30 @@ sub set_waiting { waitingdate => $today->ymd, }; - my $requested_expiration; - if ($self->expirationdate) { - $requested_expiration = dt_from_string($self->expirationdate); - } + if ( C4::Context->preference("ExpireReservesMaxPickUpDelay") ) { - my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay"); - my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays'); - my $calendar = Koha::Calendar->new( branchcode => $self->branchcode ); + my $requested_expiration; + if ($self->expirationdate) { + $requested_expiration = dt_from_string($self->expirationdate); + } - my $expirationdate = $today->clone; - $expirationdate->add(days => $max_pickup_delay); + my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay"); + my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays'); + my $calendar = Koha::Calendar->new( branchcode => $self->branchcode ); - if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) { - $expirationdate = $calendar->days_forward( dt_from_string(), $max_pickup_delay ); - } + my $expirationdate = $today->clone; + $expirationdate->add(days => $max_pickup_delay); - # If patron's requested expiration date is prior to the - # calculated one, we keep the patron's one. - my $cmp = $requested_expiration ? DateTime->compare($requested_expiration, $expirationdate) : 0; - $values->{expirationdate} = $cmp == -1 ? $requested_expiration->ymd : $expirationdate->ymd; + if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) { + $expirationdate = $calendar->days_forward( dt_from_string(), $max_pickup_delay ); + } + + # If patron's requested expiration date is prior to the + # calculated one, we keep the patron's one. + my $cmp = $requested_expiration ? DateTime->compare($requested_expiration, $expirationdate) : 0; + $values->{expirationdate} = $cmp == -1 ? $requested_expiration->ymd : $expirationdate->ymd; + + } $self->set($values)->store(); -- 1.9.1