@@ -, +, @@ --- C4/HoldsQueue.pm | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) --- a/C4/HoldsQueue.pm +++ a/C4/HoldsQueue.pm @@ -415,6 +415,9 @@ sub MapItemsToHoldRequests { && $item->{homebranch} ne $request->{borrowerbranch} ) || $item->{_object}->exclude_from_local_holds_priority; + # Group holds + next if $item->{holdallowed} == 3 && !Koha::Libraries->find( $item->{homebranch} )->validate_hold_sibling( { branchcode => $request->{borrowerbranch} } ); + next if $request->{itemnumber} && $request->{itemnumber} != $item->{itemnumber}; next unless $item->{_object}->can_be_transferred( { to => $libraries->{ $request->{branchcode} } } ); @@ -584,6 +587,10 @@ sub MapItemsToHoldRequests { foreach my $item (@$holding_branch_items) { next if $pickup_branch ne $item->{homebranch}; next if ( $item->{holdallowed} == 1 && $item->{homebranch} ne $request->{borrowerbranch} ); + + # Group holds + next if $item->{holdallowed} == 3 && !Koha::Libraries->find( $item->{homebranch} )->validate_hold_sibling( { branchcode => $request->{borrowerbranch} } ); + next unless $items_by_itemnumber{ $item->{itemnumber} }->{_object}->can_be_transferred( { to => $libraries->{ $request->{branchcode} } } ); # Don't fill item level holds that contravene the hold pickup policy at this time @@ -603,7 +610,12 @@ sub MapItemsToHoldRequests { # Now try items from the least cost branch based on the transport cost matrix or StaticHoldsQueueWeight unless ( $itemnumber ) { foreach my $current_item ( @{ $items_by_branch{$holdingbranch} } ) { - if ( $holdingbranch && ( $current_item->{holdallowed} == 2 || $request->{borrowerbranch} eq $current_item->{homebranch} ) ) { + if ( $holdingbranch && ( + $current_item->{holdallowed} == 2 + || $request->{borrowerbranch} eq $current_item->{homebranch} # holdallowed == 1 + # Group holds + || ( $current_item->{holdallowed} == 3 && Koha::Libraries->find( $current_item->{homebranch} )->validate_hold_sibling( { branchcode => $request->{borrowerbranch} } ) ) + ) ) { # Don't fill item level holds that contravene the hold pickup policy at this time next unless $current_item->{hold_fulfillment_policy} eq 'any' @@ -631,6 +643,11 @@ sub MapItemsToHoldRequests { foreach my $item (@$holding_branch_items) { next if ( $item->{holdallowed} == 1 && $item->{homebranch} ne $request->{borrowerbranch} ); + # Group holds + next if $item->{holdallowed} == 3 + && !Koha::Libraries->find( $item->{homebranch} ) + ->validate_hold_sibling( { branchcode => $request->{borrowerbranch} } ); + # Don't fill item level holds that contravene the hold pickup policy at this time next unless $item->{hold_fulfillment_policy} eq 'any' || $request->{branchcode} eq $item->{ $item->{hold_fulfillment_policy} }; --