if ( $onsite_checkout ) {
if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed ) {
- return ($onsite_checkout_count, $max_onsite_checkouts_allowed);
+ return {
+ reason => 'TOO_MANY_ONSITE_CHECKOUTS',
+ count => $onsite_checkout_count,
+ max_allowed => $max_onsite_checkouts_allowed,
+ }
}
}
if ( C4::Context->preference('ConsiderOnSiteCheckoutsAsNormalCheckouts') ) {
if ( $checkout_count >= $max_checkouts_allowed ) {
- return ($checkout_count, $max_checkouts_allowed);
+ return {
+ reason => 'TOO_MANY_CHECKOUTS',
+ count => $checkout_count,
+ max_allowed => $max_checkouts_allowed,
+ };
}
} elsif ( not $onsite_checkout ) {
if ( $checkout_count - $onsite_checkout_count >= $max_checkouts_allowed ) {
- return ($checkout_count - $onsite_checkout_count, $max_checkouts_allowed);
+ return {
+ reason => 'TOO_MANY_CHECKOUTS',
+ count => $checkout_count - $onsite_checkout_count,
+ max_allowed => $max_checkouts_allowed,
+ };
}
}
}
if ( $onsite_checkout ) {
if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed ) {
- return ($onsite_checkout_count, $max_onsite_checkouts_allowed);
+ return {
+ reason => 'TOO_MANY_ONSITE_CHECKOUTS',
+ count => $onsite_checkout_count,
+ max_allowed => $max_onsite_checkouts_allowed,
+ }
}
}
if ( C4::Context->preference('ConsiderOnSiteCheckoutsAsNormalCheckouts') ) {
if ( $checkout_count >= $max_checkouts_allowed ) {
- return ($checkout_count, $max_checkouts_allowed);
+ return {
+ reason => 'TOO_MANY_CHECKOUTS',
+ count => $checkout_count,
+ max_allowed => $max_checkouts_allowed,
+ };
}
} elsif ( not $onsite_checkout ) {
if ( $checkout_count - $onsite_checkout_count >= $max_checkouts_allowed ) {
- return ($checkout_count - $onsite_checkout_count, $max_checkouts_allowed);
+ return {
+ reason => 'TOO_MANY_CHECKOUTS',
+ count => $checkout_count - $onsite_checkout_count,
+ max_allowed => $max_checkouts_allowed,
+ };
}
}
}
#
# JB34 CHECKS IF BORROWERS DON'T HAVE ISSUE TOO MANY BOOKS
#
- my ($current_loan_count, $max_loans_allowed) = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout } );
- # if TooMany max_loans_allowed returns 0 the user doesn't have permission to check out this book
- if (defined $max_loans_allowed && $max_loans_allowed == 0) {
- $needsconfirmation{PATRON_CANT} = 1;
- } else {
- if($max_loans_allowed){
- if ( C4::Context->preference("AllowTooManyOverride") ) {
- $needsconfirmation{TOO_MANY} = 1;
- $needsconfirmation{current_loan_count} = $current_loan_count;
- $needsconfirmation{max_loans_allowed} = $max_loans_allowed;
- } else {
- $issuingimpossible{TOO_MANY} = 1;
- $issuingimpossible{current_loan_count} = $current_loan_count;
- $issuingimpossible{max_loans_allowed} = $max_loans_allowed;
- }
+ my $toomany = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $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 ) {
+ $needsconfirmation{PATRON_CANT} = 1;
+ }
+ if ( C4::Context->preference("AllowTooManyOverride") ) {
+ $needsconfirmation{TOO_MANY} = $toomany->{reason};
+ $needsconfirmation{current_loan_count} = $toomany->{count};
+ $needsconfirmation{max_loans_allowed} = $toomany->{max_allowed};
+ } else {
+ $needsconfirmation{TOO_MANY} = $toomany->{reason};
+ $issuingimpossible{current_loan_count} = $toomany->{count};
+ $issuingimpossible{max_loans_allowed} = $toomany->{max_allowed};
}
}
});
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0);
is_deeply(
- [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ) ],
- [ 0, 0 ],
+ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ),
+ {
+ reason => 'TOO_MANY_CHECKOUTS',
+ count => 0,
+ max_allowed => 0,
+ },
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
);
is_deeply(
- [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ) ],
- [ 0, 0 ],
+ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ),
+ {
+ reason => 'TOO_MANY_ONSITE_CHECKOUTS',
+ count => 0,
+ max_allowed => 0,
+ },
'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
);
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1);
is_deeply(
- [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ) ],
- [ 0, 0 ],
+ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ),
+ {
+ reason => 'TOO_MANY_CHECKOUTS',
+ count => 0,
+ max_allowed => 0,
+ },
'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
);
is_deeply(
- [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ) ],
- [ 0, 0 ],
+ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ),
+ {
+ reason => 'TOO_MANY_ONSITE_CHECKOUTS',
+ count => 0,
+ max_allowed => 0,
+ },
'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
);
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0);
is_deeply(
- [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ) ],
- [ 1, 1 ],
+ 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(
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1);
is_deeply(
- [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ) ],
- [ 1, 1 ],
+ 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 } ) ],
- [ 1, 1 ],
+ 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'
);
'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
);
is_deeply(
- [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ) ],
- [ 1, 1 ],
+ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ),
+ {
+ reason => 'TOO_MANY_ONSITE_CHECKOUTS',
+ count => 1,
+ max_allowed => 1,
+ },
'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
);
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1);
is_deeply(
- [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ) ],
- [ 1, 1 ],
+ 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 } ) ],
- [ 1, 1 ],
+ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ),
+ {
+ reason => 'TOO_MANY_ONSITE_CHECKOUTS',
+ count => 1,
+ max_allowed => 1,
+ },
'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
);
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0);
is_deeply(
- [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ) ],
- [ 1, 1 ],
+ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ),
+ {
+ reason => 'TOO_MANY_CHECKOUTS',
+ count => 1,
+ max_allowed => 1,
+ },
'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
);
is(
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1);
is_deeply(
- [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ) ],
- [ 1, 1 ],
+ 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 } ) ],
- [ 1, 1 ],
+ 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'
);
'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
);
is_deeply(
- [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ) ],
- [ 1, 1 ],
+ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ),
+ {
+ reason => 'TOO_MANY_ONSITE_CHECKOUTS',
+ count => 1,
+ max_allowed => 1,
+ },
'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
);
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1);
is_deeply(
- [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ) ],
- [ 1, 1 ],
+ 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 } ) ],
- [ 1, 1 ],
+ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ),
+ {
+ reason => 'TOO_MANY_ONSITE_CHECKOUTS',
+ count => 1,
+ max_allowed => 1,
+ },
'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
);