Bug 41879: Disallow moves to invalid pickup locations for next available holds

Signed-off-by: Eric Phetteplace <phette23@gmail.com>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Lucas Gass 2026-05-07 16:46:49 +00:00 committed by Pedro Amorim
parent 560efd018b
commit 47dd1f1844
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
2 changed files with 19 additions and 3 deletions

View File

@ -214,6 +214,7 @@ sub move_hold {
$new_itemnumber = $item->itemnumber;
$new_biblionumber = $item->biblionumber;
# need to make sure the item is being moved to a valid pickup location
my $branchitemrule = C4::Circulation::GetBranchItemRule(
Koha::Policy::Holds->holds_control_library( $item, $patron ),
$item->effective_itemtype
@ -228,13 +229,28 @@ sub move_hold {
} elsif ( $args->{new_biblionumber} ) {
$new_biblionumber = $args->{new_biblionumber};
# for record level holds we must check to make sure there is at least 1 item on the record that can fulfill the new hold
my @items = Koha::Items->search( { biblionumber => $new_biblionumber } )->as_list;
my $valid_pickup_item = 0;
foreach my $candidate_item (@items) {
my $branchitemrule = C4::Circulation::GetBranchItemRule(
Koha::Policy::Holds->holds_control_library( $candidate_item, $patron ),
$candidate_item->effective_itemtype
);
my $policy = $branchitemrule->{hold_fulfillment_policy};
next
if ( $policy eq 'homebranch' || $policy eq 'holdingbranch' )
&& $self->branchcode ne $candidate_item->$policy;
$valid_pickup_item = 1;
last;
}
return { success => 0, error => 'invalidPickupBranch' } unless $valid_pickup_item;
$canReserve = C4::Reserves::CanBookBeReserved(
$patron->borrowernumber, $new_biblionumber, $self->branchcode,
{ ignore_hold_counts => 1 }
);
# for record level holds we must check to make sure there is an item on the record that can fufill the new hold
} else {
return { success => 0, error => 'Missing itemnumber or biblionumber' };
}

View File

@ -226,7 +226,7 @@
[% CASE 'damaged' %]
<span>Target item is damaged</span>
[% CASE 'invalidPickupBranch' %]
<span>Target item is an invalid pickup location</span>
<span>Target item/record is an invalid pickup location</span>
[% CASE %]
<span>Error: [% fail.error | html %]</span>
[% END %]