@@ -, +, @@ --- C4/Circulation.pm | 4 +-- t/db_dependent/Circulation/TooMany.t | 55 +++++++++++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 3 deletions(-) --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -474,7 +474,7 @@ sub TooMany { my $max_checkouts_allowed = $issuing_rule->maxissueqty; my $max_onsite_checkouts_allowed = $issuing_rule->maxonsiteissueqty; - if ( $onsite_checkout ) { + if ( $onsite_checkout and defined $max_onsite_checkouts_allowed ) { if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed ) { return { reason => 'TOO_MANY_ONSITE_CHECKOUTS', @@ -528,7 +528,7 @@ sub TooMany { my $max_checkouts_allowed = $branch_borrower_circ_rule->{maxissueqty}; my $max_onsite_checkouts_allowed = $branch_borrower_circ_rule->{maxonsiteissueqty}; - if ( $onsite_checkout ) { + if ( $onsite_checkout and defined $max_onsite_checkouts_allowed ) { if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed ) { return { reason => 'TOO_MANY_ONSITE_CHECKOUTS', --- a/t/db_dependent/Circulation/TooMany.t +++ a/t/db_dependent/Circulation/TooMany.t @@ -15,7 +15,7 @@ # with Koha; if not, see . use Modern::Perl; -use Test::More tests => 6; +use Test::More tests => 7; use C4::Context; use C4::Biblio; @@ -159,6 +159,59 @@ subtest '1 Issuingrule exist 0 0: no issue allowed' => sub { teardown(); }; +subtest '1 Issuingrule exist with onsiteissueqty=unlimited' => sub { + plan tests => 4; + my $issuingrule = $builder->build({ + source => 'Issuingrule', + value => { + branchcode => $branch->{branchcode}, + categorycode => $category->{categorycode}, + itemtype => '*', + maxissueqty => 1, + maxonsiteissueqty => undef, + }, + }); + my $issue = C4::Circulation::AddIssue( $patron, $item->{barcode}, dt_from_string() ); + t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); + is_deeply( + C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), + { + reason => 'TOO_MANY_CHECKOUTS', + count => 1, + max_allowed => 1, + }, + 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' + ); + is( + C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), + undef, + 'OSCO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' + ); + + t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); + is_deeply( + C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), + { + reason => 'TOO_MANY_CHECKOUTS', + count => 1, + max_allowed => 1, + }, + 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' + ); + is_deeply( + C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), + { + reason => 'TOO_MANY_CHECKOUTS', + count => 1, + max_allowed => 1, + }, + 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' + ); + + teardown(); +}; + + subtest '1 Issuingrule exist 1 1: issue is allowed' => sub { plan tests => 4; my $issuingrule = $builder->build({ --