From 276bd9af4b9b64b1c5f870c7b59f33039f7e28fa Mon Sep 17 00:00:00 2001 From: emlam Date: Wed, 5 Apr 2023 09:30:30 -0400 Subject: [PATCH] Bug 32627: Calculate expirationdate relative to waitingdate Hold::set_waiting should calculate the MaxPickupDelay expiration date based on waitingdate rather than the current date, to avoid resetting the expirationdate on a hold that was already waiting. To test: 1. Place a hold and check in the item so the hold will be set to Waiting 2. Confirm that the expiration date is correct based on the ReservesMaxPickupDelay setting 3. Adjust your system clock to one day later 4. Check in the item again and confirm the hold 5. Note that the expiration date has changed 7. Apply patch and restart_all 8. Repeat steps 1-4. Confirm that the expiration date is calculated correctly, and does not change when the item is checked in again 9. Reset your system clock to the current date 10. Set ExcludeHolidaysFromMaxPickupDelay to Use the Calendar 11. Add an upcoming holiday to the calendar 12. Repeat steps 1-4. Confirm the expiration date correctly accounts for the holiday, and does not change when the item is checked in again Signed-off-by: Lucas Gass Signed-off-by: Laura Escamilla Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 21bcb6e85520b2963dde71c21ccb5e169c4c5e28) Signed-off-by: Matt Blenkinsop --- Koha/Hold.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Koha/Hold.pm b/Koha/Hold.pm index a5a9d03003..d832c2097b 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -231,7 +231,7 @@ sub set_waiting { my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay"); my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays'); - my $new_expiration_date = $today->clone->add(days => $max_pickup_delay); + my $new_expiration_date = dt_from_string($self->waitingdate)->clone->add( days => $max_pickup_delay ); if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) { my $itemtype = $self->item ? $self->item->effective_itemtype : $self->biblio->itemtype; @@ -244,7 +244,7 @@ sub set_waiting { ); my $calendar = Koha::Calendar->new( branchcode => $self->branchcode, days_mode => $daysmode ); - $new_expiration_date = $calendar->days_forward( dt_from_string(), $max_pickup_delay ); + $new_expiration_date = $calendar->days_forward( dt_from_string($self->waitingdate), $max_pickup_delay ); } # If patron's requested expiration date is prior to the -- 2.39.5