From 5695f8aa1ec39b782b13a9d8c64c8f6a35f528bd Mon Sep 17 00:00:00 2001 From: Arthur Suzuki Date: Thu, 21 Mar 2019 21:52:06 +0100 Subject: [PATCH] Bug 20985 : Add OnShelfHoldsAllowed checks to CanItemBeReserved Test plan : 1 / Check that default circulation have OnShelfHoldsAllowed to Yes 2 / Place a hold on a book with a single item, item being available for loan, verify that hold can be placed. 3 / Set OnShelfHoldsAllowed to any other value, verify that hold cannot be placed for reason "onShelfHoldsNotAllowed" (shown in the item table). --- C4/Reserves.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 5fc68f1359..8648c5b5e6 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -295,6 +295,7 @@ sub CanBookBeReserved{ if ($canReserve->{status} eq 'OK') { #We can reserve this Item! } @RETURNS { status => OK }, if the Item can be reserved. + { status => onShelfHoldsNotAllowed }, if onShelfHoldsAllowed parameter and item availability combination doesn't allow holds. { status => ageRestricted }, if the Item is age restricted for this borrower. { status => damaged }, if the Item is damaged. { status => cannotReserveFromOtherBranches }, if syspref 'canreservefromotherbranches' is OK. @@ -327,6 +328,11 @@ sub CanItemBeReserved { if ( $item->damaged && !C4::Context->preference('AllowHoldsOnDamagedItems') ); + # Check for item on shelves and OnShelfHoldsAllowed + my $on_shelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } ); + return { status => 'onShelfHoldsNotAllowed' } + unless ( $on_shelf_holds ); + # Check for the age restriction my ( $ageRestriction, $daysToAgeRestriction ) = C4::Circulation::GetAgeRestriction( $biblio->biblioitem->agerestriction, $borrower ); -- 2.11.0