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 <lucas@bywatersolutions.com>
Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
emlam 2023-04-05 09:30:30 -04:00 committed by Tomas Cohen Arazi
parent c1fe7406b9
commit 21bcb6e855
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -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