From 71e235751f609ada9f2fcb78eeda5c3b417bf83f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 12 Mar 2020 08:29:27 +0100 Subject: [PATCH] Bug 24159: Set days_mode according to circ rules in 3 other places There are 3 other occurrences where the new circ rule can be used: * C4::Circulation::checkHighHolds * Koha::Hold->set_waiting * misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl Test plan: * checkHighHolds Enable decreaseLoanHighHolds and fill decreaseLoanHighHoldsDuration Setup things to hit a "high demand" alert with a shortened due date Check an item out => The due date must be recalculated depending on the circ rule useDaysMode. * set_waiting Set ExcludeHolidaysFromMaxPickUpDelay to "1" (note that there is currently a bug in the description of the syspref, see bug 22381 comment 19) Mark a hold waiting The expiration date should have been set depending on the value of the circ rule. * TalkingTech cronjob Cannot test this Signed-off-by: Simon Perry Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart --- C4/Circulation.pm | 11 +++++++++-- Koha/Hold.pm | 11 ++++++++++- .../thirdparty/TalkingTech_itiva_outbound.pl | 13 +++++++++++-- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 40caebaf67..cc4a95a3ea 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1240,9 +1240,16 @@ sub checkHighHolds { my $issuedate = dt_from_string(); - my $calendar = Koha::Calendar->new( branchcode => $branchcode ); - my $itype = $item_object->effective_itemtype; + my $useDaysMode_value = Koha::CirculationRules->get_useDaysMode_effective_value( + { + categorycode => $borrower->{categorycode}, + itemtype => $itype, + branchcode => $branchcode, + } + ); + my $calendar = Koha::Calendar->new( branchcode => $branchcode, days_mode => $useDaysMode_value ); + my $orig_due = C4::Circulation::CalcDateDue( $issuedate, $itype, $branchcode, $borrower ); my $decreaseLoanHighHoldsDuration = C4::Context->preference('decreaseLoanHighHoldsDuration'); diff --git a/Koha/Hold.pm b/Koha/Hold.pm index e8d9e0cc2c..700c85572a 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -178,12 +178,21 @@ sub set_waiting { 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 $expirationdate = $today->clone; $expirationdate->add(days => $max_pickup_delay); if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) { + my $itemtype = $self->item ? $self->item->effective_itemtype : $self->biblio->itemtype; + my $useDaysMode_value = Koha::CirculationRules->get_useDaysMode_effective_value( + { + categorycode => $self->borrower->categorycode, + itemtype => $itemtype, + branchcode => $self->branchcode, + } + ); + my $calendar = Koha::Calendar->new( branchcode => $self->branchcode, days_mode => $useDaysMode_value ); + $expirationdate = $calendar->days_forward( dt_from_string(), $max_pickup_delay ); } diff --git a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl index 1131da61e2..cbab04947d 100755 --- a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl +++ b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl @@ -311,7 +311,7 @@ sub GetWaitingHolds { my $patron_branchcode_filter = $patron_branchcode ? "AND borrowers.branchcode = '$patron_branchcode'" : q{}; - my $query = "SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname, + 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 @@ -332,7 +332,16 @@ sub GetWaitingHolds { $sth->execute(); my @results; while ( my $issue = $sth->fetchrow_hashref() ) { - my $calendar = Koha::Calendar->new( branchcode => $issue->{'site'} ); + my $item = Koha::Items->find({ barcode => $issue->{barcode} }); + my $useDaysMode_value = Koha::CirculationRules->get_useDaysMode_effective_value( + { + categorycode => $issue->{categorycode}, + itemtype => $item->effective_itemtype, + branchcode => $issue->{site}, + } + ); + + my $calendar = Koha::Calendar->new( branchcode => $issue->{'site'}, days_mode => $useDaysMode_value ); my $waiting_date = dt_from_string( $issue->{waitingdate}, 'sql' ); my $pickup_date = $waiting_date->clone->add( days => $pickupdelay ); -- 2.39.5