|
Lines 547-587
sub MapItemsToHoldRequests {
Link Here
|
| 547 |
# HoldsQueuePrioritizeBranch check |
547 |
# HoldsQueuePrioritizeBranch check |
| 548 |
# ******************************** |
548 |
# ******************************** |
| 549 |
my $pickup_branch = $request->{branchcode} || $request->{borrowerbranch}; |
549 |
my $pickup_branch = $request->{branchcode} || $request->{borrowerbranch}; |
| 550 |
my ($itemnumber, $holdingbranch); # These variables are used for tracking the filling of the hold |
550 |
my ( $itemnumber, $holdingbranch ); # These variables are used for tracking the filling of the hold |
| 551 |
# $itemnumber, when set, is the item that has been chosen for the hold |
551 |
# $itemnumber, when set, is the item that has been chosen for the hold |
| 552 |
# $holdingbranch gets set to the pickup branch of the request if there are items held at that branch |
552 |
# $holdingbranch gets set to the pickup branch of the request if there are items held at that branch |
| 553 |
# otherwise it gets set to the least cost branch of the transport cost matrix |
553 |
# otherwise it gets set to the least cost branch of the transport cost matrix |
| 554 |
# otherwise it gets sets to the first branch from the list of branches to pull from |
554 |
# otherwise it gets sets to the first branch from the list of branches to pull from |
| 555 |
|
555 |
|
| 556 |
my $holding_branch_items = $items_by_branch{$pickup_branch}; |
556 |
my $holding_branch_items = $items_by_branch{$pickup_branch}; |
| 557 |
my $priority_branch = C4::Context->preference('HoldsQueuePrioritizeBranch') // 'homebranch'; |
|
|
| 558 |
if ($holding_branch_items) { |
557 |
if ($holding_branch_items) { |
| 559 |
foreach my $item (@$holding_branch_items) { |
|
|
| 560 |
next unless _can_item_fill_request( $item, $request, $libraries ); |
| 561 |
|
| 562 |
if ( $request->{borrowerbranch} eq $item->{$priority_branch} ) { |
| 563 |
$itemnumber = $item->{itemnumber}; |
| 564 |
last; |
| 565 |
} |
| 566 |
} |
| 567 |
$holdingbranch = $pickup_branch; |
558 |
$holdingbranch = $pickup_branch; |
| 568 |
} |
559 |
} elsif ($transport_cost_matrix) { |
| 569 |
elsif ($transport_cost_matrix) { |
560 |
$pull_branches = [ keys %items_by_branch ]; |
| 570 |
$pull_branches = [keys %items_by_branch]; |
|
|
| 571 |
$holdingbranch = least_cost_branch( $pickup_branch, $pull_branches, $transport_cost_matrix ); |
561 |
$holdingbranch = least_cost_branch( $pickup_branch, $pull_branches, $transport_cost_matrix ); |
| 572 |
if ( $holdingbranch ) { |
562 |
next |
| 573 |
|
563 |
unless $holdingbranch |
| 574 |
my $holding_branch_items = $items_by_branch{$holdingbranch}; |
564 |
; # If using the matrix, and nothing is least cost, it means we cannot transfer to the pikcup branch for this request |
| 575 |
foreach my $item (@$holding_branch_items) { |
565 |
$holding_branch_items = $items_by_branch{$holdingbranch}; |
| 576 |
next if $request->{borrowerbranch} ne $item->{$priority_branch}; |
566 |
} |
| 577 |
next unless _can_item_fill_request( $item, $request, $libraries ); |
|
|
| 578 |
|
567 |
|
| 579 |
$itemnumber = $item->{itemnumber}; |
568 |
my $priority_branch = C4::Context->preference('HoldsQueuePrioritizeBranch') // 'homebranch'; |
| 580 |
last; |
569 |
foreach my $item (@$holding_branch_items) { |
| 581 |
} |
570 |
if ( _can_item_fill_request( $item, $request, $libraries ) |
| 582 |
} |
571 |
&& $request->{borrowerbranch} eq $item->{$priority_branch} ) |
| 583 |
else { |
572 |
{ |
| 584 |
next; |
573 |
$itemnumber = $item->{itemnumber}; |
|
|
574 |
last; |
| 585 |
} |
575 |
} |
| 586 |
} |
576 |
} |
| 587 |
# End HoldsQueuePrioritizeBranch check |
577 |
# End HoldsQueuePrioritizeBranch check |
| 588 |
- |
|
|