From 3c6652702af85b594c24ce402b6a29b3ac2329d1 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 16 Aug 2016 16:52:27 +0100 Subject: [PATCH] Bug 16272: (follow-up) Specific case when switching an on-site checkout to a regular checkout Same as previous patch but if another circ rule exists Signed-off-by: Nick Clemens --- C4/Circulation.pm | 3 ++- t/db_dependent/Circulation/SwitchOnSiteCheckouts.t | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 3fa4e2b..4ab7afa 100644 --- a/C4/Circulation.pm +++ b/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, diff --git a/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t b/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t index 4f8f175..5a46a20 100644 --- a/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t +++ b/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; -- 2.1.4