From 666f79ed7412e495726ff65fa4b03f9286abbc97 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 Signed-off-by: Kyle M Hall --- C4/Circulation.pm | 3 ++- .../Circulation/SwitchOnSiteCheckouts.t | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index a76dce3212..4d0e7d5798 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -532,7 +532,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 4f8f17525d..5a46a204a5 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.39.5