From 2f6a1b4080ef104c518cf5173b474ce272b91192 Mon Sep 17 00:00:00 2001 From: Arthur Suzuki Date: Thu, 13 Jun 2024 09:13:29 +0200 Subject: [PATCH] Bug 37172 - HoldItem and HoldTitle do not check all the values of "hold_fulfillment_policy" rule --- C4/ILSDI/Services.pm | 24 +++++------------------- C4/Reserves.pm | 6 ++++++ 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm index a214836d93b..58f0028734b 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -758,20 +758,12 @@ sub HoldTitle { my $title = $biblio ? $biblio->title : ''; + my $branch = $cgi->param('pickup_location') // $patron->branchcode; + # Check if the biblio can be reserved - my $code = CanBookBeReserved( $borrowernumber, $biblionumber )->{status}; + my $code = CanBookBeReserved( $borrowernumber, $biblionumber, $branch )->{status}; return { code => $code } unless ( $code eq 'OK' ); - my $branch; - - # Pickup branch management - if ( $cgi->param('pickup_location') ) { - $branch = $cgi->param('pickup_location'); - return { code => 'LocationNotFound' } unless Koha::Libraries->find($branch); - } else { # if the request provide no branch, use the borrower's branch - $branch = $patron->branchcode; - } - my $destination = Koha::Libraries->find($branch); return { code => 'libraryNotPickupLocation' } unless $destination->pickup_location; return { code => 'cannotBeTransferred' } unless $biblio->can_be_transferred({ to => $destination }); @@ -858,14 +850,8 @@ sub HoldItem { # If the biblio does not match the item, return an error code return { code => 'RecordNotFound' } if $item->biblionumber ne $biblio->biblionumber; - # Pickup branch management - my $branch; - if ( $cgi->param('pickup_location') ) { - $branch = $cgi->param('pickup_location'); - return { code => 'LocationNotFound' } unless Koha::Libraries->find($branch); - } else { # if the request provide no branch, use the borrower's branch - $branch = $patron->branchcode; - } + # Pickup branch management} + my $branch = $cgi->param('pickup_location') // $patron->branchcode; # Check for item disponibility my $canitembereserved = C4::Reserves::CanItemBeReserved( $patron, $item, $branch )->{status}; diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 5056c5b51bd..ba641fbb2cc 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -633,6 +633,12 @@ sub CanItemBeReserved { unless ($item->can_be_transferred({ to => $destination })) { return { status => 'cannotBeTransferred' }; } + if ($branchitemrule->{hold_fulfillment_policy} eq 'homebranch' && $pickup_branchcode ne $item->homebranch) { + return { status => 'cannotBeTransferred' }; + } + if ($branchitemrule->{hold_fulfillment_policy} eq 'holdingbranch' && $pickup_branchcode ne $item->holdingbranch) { + return { status => 'cannotBeTransferred' }; + } if ($branchitemrule->{hold_fulfillment_policy} eq 'holdgroup' && !$item_library->validate_hold_sibling( {branchcode => $pickup_branchcode} )) { return { status => 'pickupNotInHoldGroup' }; } -- 2.45.1