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

(-)a/C4/Reserves.pm (-1 / +1 lines)
Lines 189-195 sub AddReserve { Link Here
189
            && ( $item->damaged && C4::Context->preference('AllowHoldsOnDamagedItems') || !$item->damaged )
189
            && ( $item->damaged && C4::Context->preference('AllowHoldsOnDamagedItems') || !$item->damaged )
190
190
191
            # Lastly, if this already has holds, we shouldn't make it waiting for the new hold
191
            # Lastly, if this already has holds, we shouldn't make it waiting for the new hold
192
            && !$item->holds->count )
192
            && !$item->current_holds->count )
193
        {
193
        {
194
            $priority = 0;
194
            $priority = 0;
195
            $found = 'W';
195
            $found = 'W';
(-)a/t/db_dependent/Reserves.t (-6 / +24 lines)
Lines 672-678 subtest '_koha_notify_reserve() tests' => sub { Link Here
672
};
672
};
673
673
674
subtest 'ReservesNeedReturns' => sub {
674
subtest 'ReservesNeedReturns' => sub {
675
    plan tests => 13;
675
    plan tests => 18;
676
676
677
    my $library    = $builder->build_object( { class => 'Koha::Libraries' } );
677
    my $library    = $builder->build_object( { class => 'Koha::Libraries' } );
678
    my $item_info  = {
678
    my $item_info  = {
Lines 731-744 subtest 'ReservesNeedReturns' => sub { Link Here
731
    $hold->delete;
731
    $hold->delete;
732
    $hold_1->delete;
732
    $hold_1->delete;
733
733
734
    $builder->build({ source => "Branchtransfer", value => {
734
    my $transfer = $builder->build_object({
735
        itemnumber  => $item->itemnumber,
735
        class => "Koha::Item::Transfers",
736
        datearrived => undef,
736
        value => {
737
    } });
737
          itemnumber  => $item->itemnumber,
738
          datearrived => undef,
739
        }
740
    });
738
    $item->damaged(0)->store;
741
    $item->damaged(0)->store;
739
    $hold = place_item_hold( $patron, $item, $library, $priority );
742
    $hold = place_item_hold( $patron, $item, $library, $priority );
740
    is( $hold->found, undef, 'If ReservesNeedReturns is 0 but item in transit the hold must not be set to waiting' );
743
    is( $hold->found, undef, 'If ReservesNeedReturns is 0 but item in transit the hold must not be set to waiting' );
741
    is( $hold->priority, 1,  'If ReservesNeedReturns is 0 but item in transit the hold must not be set to waiting' );
744
    is( $hold->priority, 1,  'If ReservesNeedReturns is 0 but item in transit the hold must not be set to waiting' );
745
    $hold->delete;
746
    $transfer->delete;
747
748
    $hold = place_item_hold( $patron, $item, $library, $priority );
749
    is( $hold->priority, 0, 'If ReservesNeedReturns is 0 and no other status, priority must have been set to 0' );
750
    is( $hold->found, 'W', 'If ReservesNeedReturns is 0 and no other status, found must have been set waiting' );
751
    $hold_1 = place_item_hold( $patron, $item, $library, $priority );
752
    is( $hold_1->priority, 1, 'If ReservesNeedReturns is 0 but item has a hold priority is 1' );
753
    $hold_1->suspend(1)->store; # We suspend the hold
754
    $hold->delete; # Delete the waiting hold
755
    $hold = place_item_hold( $patron, $item, $library, $priority );
756
    is( $hold->priority, 0, 'If ReservesNeedReturns is 0 and other hold(s) suspended, priority must have been set to 0' );
757
    is( $hold->found, 'W', 'If ReservesNeedReturns is 0 and other  hold(s) suspended, found must have been set waiting' );
758
759
760
742
761
743
    t::lib::Mocks::mock_preference('ReservesNeedReturns', 1); # Don't affect other tests
762
    t::lib::Mocks::mock_preference('ReservesNeedReturns', 1); # Don't affect other tests
744
};
763
};
745
- 

Return to bug 23964