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

(-)a/Koha/Items.pm (-4 / +26 lines)
Lines 61-75 placing a hold on one of those items. Link Here
61
sub filter_by_for_hold {
61
sub filter_by_for_hold {
62
    my ($self) = @_;
62
    my ($self) = @_;
63
63
64
    my @hold_not_allowed_itypes = Koha::CirculationRules->search(
64
    my $default_rule = Koha::CirculationRules->get_effective_rule(
65
        {
65
        {
66
            rule_name    => 'holdallowed',
66
            rule_name    => 'holdallowed',
67
            branchcode   => undef,
68
            categorycode => undef,
69
            rule_value   => 'not_allowed',
67
            rule_value   => 'not_allowed',
70
        }
68
        }
71
    )->get_column('itemtype');
69
    );
70
    my @hold_not_allowed_itypes;
71
    if ( $default_rule ) {
72
        @hold_not_allowed_itypes = Koha::ItemTypes->search->get_column('itemtype');
73
        my @hold_allowed_itypes = Koha::CirculationRules->search(
74
            {
75
                rule_name    => 'holdallowed',
76
                rule_value   => { '!=' => 'not_allowed' },
77
                branchcode   => undef,
78
                categorycode => undef,
79
            }
80
        )->get_column('itemtype');
81
        @hold_not_allowed_itypes = array_minus( @hold_not_allowed_itypes, @hold_allowed_itypes )
82
    } else {
83
        @hold_not_allowed_itypes = Koha::CirculationRules->search(
84
            {
85
                rule_name    => 'holdallowed',
86
                branchcode   => undef,
87
                categorycode => undef,
88
                rule_value   => 'not_allowed',
89
            }
90
        )->get_column('itemtype');
91
    }
92
72
    push @hold_not_allowed_itypes, Koha::ItemTypes->search({ notforloan => 1 })->get_column('itemtype');
93
    push @hold_not_allowed_itypes, Koha::ItemTypes->search({ notforloan => 1 })->get_column('itemtype');
94
    @hold_not_allowed_itypes = uniq @hold_not_allowed_itypes;
73
95
74
    my $params = {
96
    my $params = {
75
        itemlost   => 0,
97
        itemlost   => 0,
(-)a/t/db_dependent/Koha/Holds.t (+7 lines)
Lines 412-417 subtest 'Desks' => sub { Link Here
412
subtest 'get_items_that_can_fill' => sub {
412
subtest 'get_items_that_can_fill' => sub {
413
    plan tests => 2;
413
    plan tests => 2;
414
414
415
    Koha::CirculationRules->search(
416
        {
417
            rule_name    => 'holdallowed',
418
            rule_value   => 'not_allowed',
419
        }
420
    )->delete;
421
415
    my $biblio = $builder->build_sample_biblio;
422
    my $biblio = $builder->build_sample_biblio;
416
    my $itype_1 = $builder->build_object({ class => 'Koha::ItemTypes' }); # For 1, 2, 3, 4
423
    my $itype_1 = $builder->build_object({ class => 'Koha::ItemTypes' }); # For 1, 2, 3, 4
417
    my $itype_2 = $builder->build_object({ class => 'Koha::ItemTypes' });
424
    my $itype_2 = $builder->build_object({ class => 'Koha::ItemTypes' });
(-)a/t/db_dependent/Koha/Items.t (-1 / +7 lines)
Lines 1512-1517 subtest 'can_be_transferred' => sub { Link Here
1512
subtest 'filter_by_for_hold' => sub {
1512
subtest 'filter_by_for_hold' => sub {
1513
    plan tests => 12;
1513
    plan tests => 12;
1514
1514
1515
    Koha::CirculationRules->search(
1516
        {
1517
            rule_name    => 'holdallowed',
1518
            rule_value   => 'not_allowed',
1519
        }
1520
    )->delete;
1521
1515
    my $biblio = $builder->build_sample_biblio;
1522
    my $biblio = $builder->build_sample_biblio;
1516
    is( $biblio->items->filter_by_for_hold->count, 0, 'no item yet' );
1523
    is( $biblio->items->filter_by_for_hold->count, 0, 'no item yet' );
1517
    $builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => 1 } );
1524
    $builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => 1 } );
1518
- 

Return to bug 29087