Bug 16272: Specific case when switching an on-site checkout to a regular checkout
In the case on-site checkouts are considered as a regular checkout in issuing rules (i.e. ConsiderOnSiteCheckoutsAsNormalCheckouts is on): When after the on-site checkout the maximum limit of checkouts is reached and the patron wants to switch an on-site checkout to a regular checkout, the C4::Circulation::TooMany subroutine will return a TOO_MANY_CHECKOUTS error. To avoid that, we need to allow an extra checkout in this subroutine. Test plan: 0/ Switch ConsiderOnSiteCheckoutsAsNormalCheckouts and SwitchOnSiteCheckouts on 1/ In the issuing rules, set the total number of checkouts (maxissueqty) to 2 and the number of on-site checkouts to 2 (maxonsiteissueqty) 2/ Check 2 items out ticking the 'on-site checkout' checkbox 3/ Check one of these items out, to automatically switch it to a regular checkout => The checkout should be allowed. Sponsored-by: BULAC - http://www.bulac.fr/ Signed-off-by: Nicolas Legrand <nicolas.legrand@bulac.fr> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
parent
e018b69dca
commit
fe563f5911
2 changed files with 25 additions and 3 deletions
|
@ -387,6 +387,7 @@ sub TooMany {
|
|||
my $item = shift;
|
||||
my $params = shift;
|
||||
my $onsite_checkout = $params->{onsite_checkout} || 0;
|
||||
my $switch_onsite_checkout = $params->{switch_onsite_checkout} || 0;
|
||||
my $cat_borrower = $borrower->{'categorycode'};
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $branch;
|
||||
|
@ -477,7 +478,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,
|
||||
|
@ -819,7 +821,12 @@ sub CanBookBeIssued {
|
|||
#
|
||||
# JB34 CHECKS IF BORROWERS DON'T HAVE ISSUE TOO MANY BOOKS
|
||||
#
|
||||
my $toomany = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout } );
|
||||
my $switch_onsite_checkout =
|
||||
C4::Context->preference('SwitchOnSiteCheckouts')
|
||||
and $issue->{onsite_checkout}
|
||||
and $issue
|
||||
and $issue->{borrowernumber} == $borrower->{'borrowernumber'} ? 1 : 0;
|
||||
my $toomany = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout, switch_onsite_checkout => $switch_onsite_checkout, } );
|
||||
# if TooMany max_allowed returns 0 the user doesn't have permission to check out this book
|
||||
if ( $toomany ) {
|
||||
if ( $toomany->{max_allowed} == 0 ) {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
# with Koha; if not, see <http://www.gnu.org/licenses>.
|
||||
|
||||
use Modern::Perl;
|
||||
use Test::More tests => 4;
|
||||
use Test::More tests => 5;
|
||||
use C4::Context;
|
||||
|
||||
use C4::Biblio;
|
||||
|
@ -105,6 +105,21 @@ is( $issue->{onsite_checkout}, 0, '' );
|
|||
my $five_days_after = dt_from_string->add( days => 5 )->set( hour => 23, minute => 59, second => 0 );
|
||||
is( $issue->{date_due}, $five_days_after );
|
||||
|
||||
# Specific case
|
||||
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1);
|
||||
my $another_item = $builder->build({
|
||||
source => 'Item',
|
||||
value => {
|
||||
biblionumber => $biblio->{biblionumber},
|
||||
homebranch => $branch->{branchcode},
|
||||
holdingbranch => $branch->{branchcode},
|
||||
},
|
||||
});
|
||||
|
||||
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} );
|
||||
is( $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}, 1, '' );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
|
||||
1;
|
||||
|
|
Loading…
Reference in a new issue