View | Details | Raw Unified | Return to bug 11258
Collapse All | Expand All

(-)a/C4/HoldsQueue.pm (-2 / +2 lines)
Lines 432-438 sub MapItemsToHoldRequests { Link Here
432
                }
432
                }
433
            }
433
            }
434
            $holdingbranch = $pickup_branch;
434
            $holdingbranch = $pickup_branch;
435
            $itemnumber ||= $holding_branch_items->[0]->{itemnumber};
436
        }
435
        }
437
        elsif ($transport_cost_matrix) {
436
        elsif ($transport_cost_matrix) {
438
            $pull_branches = [keys %items_by_branch];
437
            $pull_branches = [keys %items_by_branch];
Lines 467-472 sub MapItemsToHoldRequests { Link Here
467
                $holdingbranch ||= $branch;
466
                $holdingbranch ||= $branch;
468
                foreach my $item (@$holding_branch_items) {
467
                foreach my $item (@$holding_branch_items) {
469
                    next if $pickup_branch ne $item->{homebranch};
468
                    next if $pickup_branch ne $item->{homebranch};
469
                    next if ( $item->{holdallowed} == 1 && $item->{homebranch} ne $request->{borrowerbranch} );
470
470
471
                    $itemnumber = $item->{itemnumber};
471
                    $itemnumber = $item->{itemnumber};
472
                    $holdingbranch = $branch;
472
                    $holdingbranch = $branch;
Lines 476-482 sub MapItemsToHoldRequests { Link Here
476
476
477
            unless ( $itemnumber ) {
477
            unless ( $itemnumber ) {
478
                foreach my $current_item ( @{ $items_by_branch{$holdingbranch} } ) {
478
                foreach my $current_item ( @{ $items_by_branch{$holdingbranch} } ) {
479
                    if ( $holdingbranch && ( $current_item->{holdallowed} == 2 || $pickup_branch eq $current_item->{homebranch} ) ) {
479
                    if ( $holdingbranch && ( $current_item->{holdallowed} == 2 || $request->{borrowerbranch} eq $current_item->{homebranch} ) ) {
480
                        $itemnumber = $current_item->{itemnumber};
480
                        $itemnumber = $current_item->{itemnumber};
481
                        last; # quit this loop as soon as we have a suitable item
481
                        last; # quit this loop as soon as we have a suitable item
482
                    }
482
                    }
(-)a/t/db_dependent/HoldsQueue.t (-4 / +4 lines)
Lines 12-18 use C4::Context; Link Here
12
12
13
use Data::Dumper;
13
use Data::Dumper;
14
14
15
use Test::More tests => 20;
15
use Test::More tests => 21;
16
16
17
17
18
use C4::Branch;
18
use C4::Branch;
Lines 287-294 $dbh->do("DELETE FROM default_circ_rules"); Link Here
287
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 1 )");
287
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 1 )");
288
C4::HoldsQueue::CreateQueue();
288
C4::HoldsQueue::CreateQueue();
289
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
289
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
290
ok( @$holds_queue == 1, "Holds queue filling correct number for default holds policy 'from home library'" );
290
ok( @$holds_queue == 2, "Holds queue filling correct number for default holds policy 'from home library'" );
291
ok( $holds_queue->[0]->{cardnumber} eq 'CARDNUMBER1', "Holds queue filling correct hold for default holds policy 'from home library'");
291
ok( $holds_queue->[0]->{cardnumber} eq 'CARDNUMBER1', "Holds queue filling 1st correct hold for default holds policy 'from home library'");
292
ok( $holds_queue->[1]->{cardnumber} eq 'CARDNUMBER2', "Holds queue filling 2nd correct hold for default holds policy 'from home library'");
292
293
293
$dbh->do("DELETE FROM default_circ_rules");
294
$dbh->do("DELETE FROM default_circ_rules");
294
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 2 )");
295
$dbh->do("INSERT INTO default_circ_rules ( holdallowed ) VALUES ( 2 )");
295
- 

Return to bug 11258