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

(-)a/Koha/Items.pm (-1 / +1 lines)
Lines 65-71 sub filter_by_for_hold { Link Here
65
            withdrawn  => 0,
65
            withdrawn  => 0,
66
            notforloan => { '<=' => 0 }
66
            notforloan => { '<=' => 0 }
67
            ,    # items with negative or zero notforloan value are holdable
67
            ,    # items with negative or zero notforloan value are holdable
68
            ( C4::Context->preference('AllowHoldsOnDamagedItems') ? ( damaged => 0 ) : () ),
68
            ( ! C4::Context->preference('AllowHoldsOnDamagedItems' ) ? ( damaged => 0 ) : () ),
69
            itype        => { -not_in => \@hold_not_allowed_itypes },
69
            itype        => { -not_in => \@hold_not_allowed_itypes },
70
        }
70
        }
71
    );
71
    );
(-)a/t/db_dependent/Koha/Items.t (-2 / +16 lines)
Lines 1510-1516 subtest 'can_be_transferred' => sub { Link Here
1510
};
1510
};
1511
1511
1512
subtest 'filter_by_for_hold' => sub {
1512
subtest 'filter_by_for_hold' => sub {
1513
    plan tests => 4;
1513
    plan tests => 8;
1514
1514
1515
    my $biblio = $builder->build_sample_biblio;
1515
    my $biblio = $builder->build_sample_biblio;
1516
    is( $biblio->items->filter_by_for_hold->count, 0, 'no item yet' );
1516
    is( $biblio->items->filter_by_for_hold->count, 0, 'no item yet' );
Lines 1521-1526 subtest 'filter_by_for_hold' => sub { Link Here
1521
    $builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => -1 } );
1521
    $builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => -1 } );
1522
    is( $biblio->items->filter_by_for_hold->count, 2, '2 items for hold' );
1522
    is( $biblio->items->filter_by_for_hold->count, 2, '2 items for hold' );
1523
1523
1524
    $builder->build_sample_item( { biblionumber => $biblio->biblionumber, itemlost => 0 } );
1525
    $builder->build_sample_item( { biblionumber => $biblio->biblionumber, itemlost => 1 } );
1526
    is( $biblio->items->filter_by_for_hold->count, 3, '3 items for hold - itemlost' );
1527
1528
    $builder->build_sample_item( { biblionumber => $biblio->biblionumber, withdrawn => 0 } );
1529
    $builder->build_sample_item( { biblionumber => $biblio->biblionumber, withdrawn => 1 } );
1530
    is( $biblio->items->filter_by_for_hold->count, 4, '4 items for hold - withdrawn' );
1531
1532
    $builder->build_sample_item( { biblionumber => $biblio->biblionumber, damaged => 0 } );
1533
    $builder->build_sample_item( { biblionumber => $biblio->biblionumber, damaged => 1 } );
1534
    t::lib::Mocks::mock_preference('AllowHoldsOnDamagedItems', 0);
1535
    is( $biblio->items->filter_by_for_hold->count, 5, '5 items for hold - not damaged if not AllowHoldsOnDamagedItems' );
1536
    t::lib::Mocks::mock_preference('AllowHoldsOnDamagedItems', 1);
1537
    is( $biblio->items->filter_by_for_hold->count, 6, '6 items for hold - damaged if AllowHoldsOnDamagedItems' );
1538
1524
    $biblio->delete;
1539
    $biblio->delete;
1525
};
1540
};
1526
1541
1527
- 

Return to bug 3142