@@ -, +, @@ on-site checkout to a regular checkout --- C4/Circulation.pm | 3 ++- t/db_dependent/Circulation/SwitchOnSiteCheckouts.t | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -531,7 +531,8 @@ sub TooMany { } } if ( C4::Context->preference('ConsiderOnSiteCheckoutsAsNormalCheckouts') ) { - if ( $checkout_count >= $max_checkouts_allowed ) { + my $delta = $switch_onsite_checkout ? 1 : 0; + if ( $checkout_count >= $max_checkouts_allowed + $delta ) { return { reason => 'TOO_MANY_CHECKOUTS', count => $checkout_count, --- a/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t +++ a/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t @@ -15,7 +15,7 @@ # with Koha; if not, see . use Modern::Perl; -use Test::More tests => 5; +use Test::More tests => 8; use C4::Context; use C4::Biblio; @@ -117,8 +117,23 @@ my $another_item = $builder->build({ }); C4::Circulation::AddIssue( $patron, $another_item->{barcode}, dt_from_string, undef, dt_from_string, undef, { onsite_checkout => 1 } ); -( undef, undef, undef, $messages ) = C4::Circulation::CanBookBeIssued( $patron, $another_item->{barcode} ); +( $impossible, undef, undef, $messages ) = C4::Circulation::CanBookBeIssued( $patron, $another_item->{barcode} ); is( $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}, 1, '' ); +is( exists $impossible->{TOO_MANY}, '', '' ); + +$dbh->do(q|DELETE FROM issuingrules|); +my $borrower_circ_rule = $builder->build({ + source => 'DefaultCircRule', + value => { + branchcode => $branch->{branchcode}, + categorycode => '*', + maxissueqty => 2, + maxonsiteissueqty => 1, + }, +}); +( $impossible, undef, undef, $messages ) = C4::Circulation::CanBookBeIssued( $patron, $another_item->{barcode} ); +is( $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}, 1, '' ); +is( exists $impossible->{TOO_MANY}, '', '' ); $schema->storage->txn_rollback; --