From 10c8fb5c193130c2f1519f80c859bdd77005bde6 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 19 Feb 2024 12:31:07 +0000 Subject: [PATCH] Bug 35944: Add booking handling to CanBookBeRenewed This patch adds a bookings check to CanBookBeRenewed --- C4/Circulation.pm | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 5f348af7826..21f4872dbe5 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2999,8 +2999,8 @@ sub CanBookBeRenewed { my $final_unseen_renewal = 0; # override_limit will override anything else except on_reserve + my $branchcode = _GetCircControlBranch( $item, $patron ); unless ( $override_limit ){ - my $branchcode = _GetCircControlBranch( $item, $patron ); my $issuing_rule = Koha::CirculationRules->get_effective_rules( { categorycode => $patron->categorycode, @@ -3120,6 +3120,21 @@ sub CanBookBeRenewed { } } + # CHECK FOR BOOKINGS + my $startdate = + ( C4::Context->preference('RenewalPeriodBase') eq 'date_due' ) + ? dt_from_string( $issue->date_due, 'sql' ) + : dt_from_string(); + my $datedue = CalcDateDue( $startdate, $item->effective_itemtype, $branchcode, $patron, 'is a renewal' ); + if ( + my $booking = $item->find_booking( + { checkout_date => $startdate, due_date => $datedue, patron_id => $patron->borrowernumber } + ) + ) + { + return ( 0, 'booked' ) unless ( $booking->patron_id == $patron->borrowernumber ); + } + if ( $auto_renew eq 'auto_too_soon' ) { # If its cron, tell it it's too soon for a an auto renewal -- 2.43.2