From b9e27c399602f7a343ede597c87d4c3d8ea710d8 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 12 Aug 2022 16:19:49 +0000 Subject: [PATCH] Bug 31356: Use hold expiration date instead of adding days to the waiting date MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The Talking Tech outbound script currently just adds the ReservesMaxPickUpDelay to the waiting date to calculate the "expiration date", but it should use the actual hold expiration date which may differ from this naive calculation based on various system preference values. Test Plan: 1) Create a holiday for tomorrow 2) Set ReservesMaxPickUpDelay to 5 3) Set "Days mode" to "Same week day" 4) Enable ExcludeHolidaysFromMaxPickUpDelay 5) Enable TalkingTechItivaPhoneNotification 6) Create a hold and fill the hold so it is waiting 7) Enable "Hold filled" phone notices for that patron 8) Create a 'phone' version of the HOLD notice 9) Run ./misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl --type RESERVE -w 0 10) Note the output has the expiration date ( 15th colume ) 5 days from now which is *not* the hold's expiration date 11) Apply this patch 12) Repeat the command from step 9 13) Note the expiration date column now matches the holds actual expiration date! Signed-off-by: Kyle Hall Signed-off-by: Joonas Kylmälä Signed-off-by: Tomas Cohen Arazi (cherry picked from commit f6a08737c9ad9c85e98887e3a55cf31029c5a8c8) Signed-off-by: Lucas Gass --- misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl index 6a1456987f..5f679a9932 100755 --- a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl +++ b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl @@ -308,7 +308,8 @@ sub GetWaitingHolds { my $query = "SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname, borrowers.categorycode, borrowers.phone, borrowers.email, borrowers.branchcode, biblio.biblionumber, biblio.title, items.barcode, reserves.waitingdate, reserves.branchcode AS site, branches.branchname AS site_name, - TO_DAYS(NOW())-TO_DAYS(reserves.waitingdate) AS days_since_waiting + TO_DAYS(NOW())-TO_DAYS(reserves.waitingdate) AS days_since_waiting, + reserves.expirationdate FROM borrowers JOIN reserves USING (borrowernumber) JOIN items USING (itemnumber) JOIN biblio ON (biblio.biblionumber = items.biblionumber) @@ -321,7 +322,6 @@ sub GetWaitingHolds { AND message_name = 'Hold_Filled' $patron_branchcode_filter "; - my $pickupdelay = C4::Context->preference("ReservesMaxPickUpDelay"); my $sth = $dbh->prepare($query); $sth->execute(); my @results; @@ -338,12 +338,8 @@ sub GetWaitingHolds { my $calendar = Koha::Calendar->new( branchcode => $issue->{'site'}, days_mode => $daysmode ); my $waiting_date = dt_from_string( $issue->{waitingdate}, 'sql' ); - my $pickup_date = $waiting_date->clone->add( days => $pickupdelay ); - if ( $calendar->is_holiday($pickup_date) ) { - $pickup_date = $calendar->next_open_days( $pickup_date, 1 ); - } - $issue->{'date_due'} = output_pref({dt => $pickup_date, dateformat => 'iso' }); + $issue->{'date_due'} = output_pref({dt => dt_from_string($issue->{expirationdate}), dateformat => 'iso' }); $issue->{'level'} = 1; # only one level for Hold Waiting notifications my $days_to_subtract = 0; -- 2.39.5