From a9985d49c39434da129e014f24175531a1feeeb2 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 23 Jul 2013 08:05:22 -0400 Subject: [PATCH] Bug 10628 - AutomaticItemReturn prevents holds queue from filling local holds with local items For some reason, C4::HoldsQueue::MapItemsToHoldRequests uses the system preference AutomaticItemReturn to decide if an attempt to fill local holds with local items. No explanation of this behavior is provided. --- C4/HoldsQueue.pm | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-) diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm index 2052f09..7aa3f56 100755 --- a/C4/HoldsQueue.pm +++ b/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}{$_}; -- 1.7.2.5