Lines 395-401
sub _checkHoldPolicy {
Link Here
|
395 |
|
395 |
|
396 |
=head2 MapItemsToHoldRequests |
396 |
=head2 MapItemsToHoldRequests |
397 |
|
397 |
|
398 |
MapItemsToHoldRequests($hold_requests, $available_items, $branches, $transport_cost_matrix) |
398 |
my $item_map = MapItemsToHoldRequests($hold_requests, $available_items, $branches, $transport_cost_matrix) |
|
|
399 |
|
400 |
Parameters: |
401 |
$hold_requests is a hash containing hold information built by GetPendingHoldRequestsForBib |
402 |
$available_items is a hash containing item information built by GetItemsAvailableToFillHoldRequestsForBib |
403 |
$branches is an arrayref to a list of branches filled by load_branches_to_pull_from |
404 |
$transport_cost_matrix is a hash of hashes with branchcodes as keys, listing the cost to transfer from that branch to another |
405 |
|
406 |
Returns a hash of hashes with itemnumbers as keys, each itemnumber containing a hash with the information |
407 |
about the hold it has been mapped to. |
399 |
|
408 |
|
400 |
=cut |
409 |
=cut |
401 |
|
410 |
|
Lines 548-556
sub MapItemsToHoldRequests {
Link Here
|
548 |
next if $request->{allocated}; |
557 |
next if $request->{allocated}; |
549 |
next if defined($request->{itemnumber}); # already handled these |
558 |
next if defined($request->{itemnumber}); # already handled these |
550 |
|
559 |
|
551 |
# look for local match first |
560 |
# HoldsQueuePrioritizeBranch check |
|
|
561 |
# ******************************** |
552 |
my $pickup_branch = $request->{branchcode} || $request->{borrowerbranch}; |
562 |
my $pickup_branch = $request->{branchcode} || $request->{borrowerbranch}; |
553 |
my ($itemnumber, $holdingbranch); |
563 |
my ($itemnumber, $holdingbranch); # These variables are used for tracking the filling of the hold |
|
|
564 |
# $itemnumber, when set, is the item that has been chosen for the hold |
565 |
# $holdingbranch gets set to the pickup branch of the request if there are items held at that branch |
566 |
# otherwise it gets set to the least cost branch of the transport cost matrix |
567 |
# otherwise it gets sets to the first branch from the list of branches to pull from |
554 |
|
568 |
|
555 |
my $holding_branch_items = $items_by_branch{$pickup_branch}; |
569 |
my $holding_branch_items = $items_by_branch{$pickup_branch}; |
556 |
my $priority_branch = C4::Context->preference('HoldsQueuePrioritizeBranch') // 'homebranch'; |
570 |
my $priority_branch = C4::Context->preference('HoldsQueuePrioritizeBranch') // 'homebranch'; |
Lines 605-610
sub MapItemsToHoldRequests {
Link Here
|
605 |
next; |
619 |
next; |
606 |
} |
620 |
} |
607 |
} |
621 |
} |
|
|
622 |
# End HoldsQueuePrioritizeBranch check |
623 |
# ******************************** |
624 |
|
608 |
|
625 |
|
609 |
unless ($itemnumber) { |
626 |
unless ($itemnumber) { |
610 |
# not found yet, fall back to basics |
627 |
# not found yet, fall back to basics |
Lines 620-626
sub MapItemsToHoldRequests {
Link Here
|
620 |
my $holding_branch_items = $items_by_branch{$branch} |
637 |
my $holding_branch_items = $items_by_branch{$branch} |
621 |
or next; |
638 |
or next; |
622 |
|
639 |
|
623 |
$holdingbranch ||= $branch; |
640 |
$holdingbranch ||= $branch; # We set this as the first from the list of pull branches |
|
|
641 |
# unless we set it above to the pickupbranch or the least cost branch |
642 |
# FIXME: The itention is to follow StaticHoldsQueueWeight, but we don't check that pref |
624 |
foreach my $item (@$holding_branch_items) { |
643 |
foreach my $item (@$holding_branch_items) { |
625 |
next if $pickup_branch ne $item->{homebranch}; |
644 |
next if $pickup_branch ne $item->{homebranch}; |
626 |
next unless _checkHoldPolicy($item, $request); |
645 |
next unless _checkHoldPolicy($item, $request); |
627 |
- |
|
|