From 2e87613c8b137c4d6d1af8e40311a58c5a842d42 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Fri, 8 Nov 2019 10:22:09 +0100 Subject: [PATCH] Bug 23669 : Add overlap reserve check in ILS-DI HoldTitle and HoldItem Test plan : - set PreventReservesOnSamePeriod - put a first reserve on an item - try to put another reserve from ILS-DI - the second reserve should succeed although PreventReservesOnSamePeriod is set. - apply patch and repeat the process, the second reserve should not succeed --- C4/ILSDI/Services.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm index 52585ac2dd..3536c20290 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -25,7 +25,7 @@ use C4::Items qw( get_hostitemnumbers_of ); use C4::Circulation qw( CanBookBeRenewed barcodedecode CanBookBeIssued AddRenewal ); use C4::Accounts; use C4::Biblio qw( GetMarcBiblio ); -use C4::Reserves qw( CanBookBeReserved IsAvailableForItemLevelRequest CalculatePriority AddReserve CanItemBeReserved ); +use C4::Reserves qw( CanBookBeReserved IsAvailableForItemLevelRequest CalculatePriority AddReserve CanItemBeReserved ReservesOnSamePeriod); use C4::Context; use C4::Auth; use CGI qw ( -utf8 ); @@ -785,6 +785,10 @@ sub HoldTitle { $expdate = $cgi->param('expiry_date'); } + if (C4::Context->preference('PreventReservesOnSamePeriod') && ReservesOnSamePeriod($biblionumber, undef, $resdate, $expdate)) { + return { code => 'NotHoldable' }; + } + # Add the reserve # $branch, $borrowernumber, $biblionumber, # $constraint, $bibitems, $priority, $resdate, $expdate, $notes, @@ -887,6 +891,10 @@ sub HoldItem { $expdate = $cgi->param('expiry_date'); } + if (C4::Context->preference('PreventReservesOnSamePeriod') && ReservesOnSamePeriod($biblionumber, $itemnumber, $resdate, $expdate)) { + return { code => 'NotHoldable' }; + } + # Add the reserve my $priority = C4::Reserves::CalculatePriority($biblionumber); AddReserve( -- 2.35.1