@@ -, +, @@ per record --- C4/Reserves.pm | 3 +++ t/db_dependent/Holds.t | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) --- a/C4/Reserves.pm +++ a/C4/Reserves.pm @@ -378,6 +378,9 @@ sub CanItemBeReserved { found => undef, # Found holds don't count against a patron's holds limit } ); + if ( $holds_per_record == 0 ) { + return "noReservesAllowed"; + } if ( $holds->count() >= $holds_per_record ) { return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record }; } --- a/t/db_dependent/Holds.t +++ a/t/db_dependent/Holds.t @@ -336,9 +336,13 @@ subtest 'CanItemBeReserved' => sub { q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record) VALUES (?, ?, ?, ?, ?)}, {}, '*', '*', $itemtype_can, 2, 2 ); + $dbh->do( + q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record) VALUES (?, ?, ?, ?, ?)}, {}, + '*', '*', 'CANNOT_RECORD', 0, 0 + ); subtest 'noReservesAllowed' => sub { - plan tests => 4; + plan tests => 5; my $biblionumber_cannot = $builder->build_sample_biblio({ itemtype => $itemtype_cant })->biblionumber; my $biblionumber_can = $builder->build_sample_biblio({ itemtype => $itemtype_can })->biblionumber; @@ -348,6 +352,9 @@ subtest 'CanItemBeReserved' => sub { my ( undef, undef, $itemnumber_2_can ) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1, itype => 'CAN' } , $biblionumber_can); my ( undef, undef, $itemnumber_2_cannot ) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1, itype => 'CANNOT' } , $biblionumber_can); + my ($biblionumber_record_cannot) = create_helper_biblio('CANNOT_RECORD'); + my ( undef, undef, $itemnumber_3_cannot ) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1, itype => 'CANNOT_RECORD' } , $biblionumber_record_cannot); + Koha::Holds->search({borrowernumber => $borrowernumbers[0]})->delete; t::lib::Mocks::mock_preference('item-level_itypes', 1); @@ -368,6 +375,10 @@ subtest 'CanItemBeReserved' => sub { CanItemBeReserved( $borrowernumbers[0], $itemnumber_2_cannot), 'OK', "With biblio level set, rule from biblio must be picked (CAN)" ); + is( + CanItemBeReserved( $borrowernumbers[0], $itemnumber_3_cannot), 'noReservesAllowed', + "When no holds allowed and no holds per record allowed should return noReservesAllowed" + ); }; subtest 'tooManyHoldsForThisRecord + tooManyReserves + itemAlreadyOnHold' => sub { --