From ea6bd172db50a944d5402b5281e80b41c5ff444c Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 20 Nov 2020 12:50:00 -0500 Subject: [PATCH] Bug 27068: Add hold group limits to Holds Queue builder --- C4/HoldsQueue.pm | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm index 14b5dc15ce..f94268294b 100644 --- a/C4/HoldsQueue.pm +++ b/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} }; -- 2.24.1 (Apple Git-126)