@@ -, +, @@ --- C4/HoldsQueue.pm | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-) --- a/C4/HoldsQueue.pm +++ a/C4/HoldsQueue.pm @@ -354,8 +354,6 @@ sub MapItemsToHoldRequests { return unless scalar(@$hold_requests) > 0; return unless scalar(@$available_items) > 0; - my $automatic_return = C4::Context->preference("AutomaticItemReturn"); - # identify item-level requests my %specific_items_requested = map { $_->{itemnumber} => 1 } grep { defined($_->{itemnumber}) } @@ -419,7 +417,7 @@ sub MapItemsToHoldRequests { my $pickup_branch = $request->{branchcode} || $request->{borrowerbranch}; my ($itemnumber, $holdingbranch); - my $holding_branch_items = $automatic_return ? undef : $items_by_branch{$pickup_branch}; + my $holding_branch_items = $items_by_branch{$pickup_branch}; if ( $holding_branch_items ) { foreach my $item (@$holding_branch_items) { if ( $request->{borrowerbranch} eq $item->{homebranch} ) { @@ -587,10 +585,15 @@ sub least_cost_branch { #$from - arrayref my ($to, $from, $transport_cost_matrix) = @_; -# Nothing really spectacular: supply to branch, a list of potential from branches -# and find the minimum from - to value from the transport_cost_matrix + # Nothing really spectacular: supply to branch, a list of potential from branches + # and find the minimum from - to value from the transport_cost_matrix return $from->[0] if @$from == 1; + # If the pickup library is in the list of libraries to pull from, + # return that library right away, it is obviously the least costly + my ($self) = grep( /$to/, @$from ); + return ($self) if $self; + my ($least_cost, @branch); foreach (@$from) { my $cell = $transport_cost_matrix->{$to}{$_}; --