View | Details | Raw Unified | Return to bug 16272
Collapse All | Expand All

(-)a/C4/Circulation.pm (-2 / +9 lines)
Lines 384-389 sub TooMany { Link Here
384
	my $item		= shift;
384
	my $item		= shift;
385
    my $params = shift;
385
    my $params = shift;
386
    my $onsite_checkout = $params->{onsite_checkout} || 0;
386
    my $onsite_checkout = $params->{onsite_checkout} || 0;
387
    my $switch_onsite_checkout = $params->{switch_onsite_checkout} || 0;
387
    my $cat_borrower    = $borrower->{'categorycode'};
388
    my $cat_borrower    = $borrower->{'categorycode'};
388
    my $dbh             = C4::Context->dbh;
389
    my $dbh             = C4::Context->dbh;
389
	my $branch;
390
	my $branch;
Lines 474-480 sub TooMany { Link Here
474
            }
475
            }
475
        }
476
        }
476
        if ( C4::Context->preference('ConsiderOnSiteCheckoutsAsNormalCheckouts') ) {
477
        if ( C4::Context->preference('ConsiderOnSiteCheckoutsAsNormalCheckouts') ) {
477
            if ( $checkout_count >= $max_checkouts_allowed ) {
478
            my $delta = $switch_onsite_checkout ? 1 : 0;
479
            if ( $checkout_count >= $max_checkouts_allowed + $delta ) {
478
                return {
480
                return {
479
                    reason => 'TOO_MANY_CHECKOUTS',
481
                    reason => 'TOO_MANY_CHECKOUTS',
480
                    count => $checkout_count,
482
                    count => $checkout_count,
Lines 924-930 sub CanBookBeIssued { Link Here
924
#
926
#
925
    # JB34 CHECKS IF BORROWERS DON'T HAVE ISSUE TOO MANY BOOKS
927
    # JB34 CHECKS IF BORROWERS DON'T HAVE ISSUE TOO MANY BOOKS
926
    #
928
    #
927
    my $toomany = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout } );
929
    my $switch_onsite_checkout =
930
          C4::Context->preference('SwitchOnSiteCheckouts')
931
      and $issue->{onsite_checkout}
932
      and $issue
933
      and $issue->{borrowernumber} == $borrower->{'borrowernumber'} ? 1 : 0;
934
    my $toomany = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout, switch_onsite_checkout => $switch_onsite_checkout, } );
928
    # if TooMany max_allowed returns 0 the user doesn't have permission to check out this book
935
    # if TooMany max_allowed returns 0 the user doesn't have permission to check out this book
929
    if ( $toomany ) {
936
    if ( $toomany ) {
930
        if ( $toomany->{max_allowed} == 0 ) {
937
        if ( $toomany->{max_allowed} == 0 ) {
(-)a/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t (-2 / +16 lines)
Lines 15-21 Link Here
15
# with Koha; if not, see <http://www.gnu.org/licenses>.
15
# with Koha; if not, see <http://www.gnu.org/licenses>.
16
16
17
use Modern::Perl;
17
use Modern::Perl;
18
use Test::More tests => 4;
18
use Test::More tests => 5;
19
use C4::Context;
19
use C4::Context;
20
20
21
use C4::Biblio;
21
use C4::Biblio;
Lines 105-110 is( $issue->{onsite_checkout}, 0, '' ); Link Here
105
my $five_days_after = dt_from_string->add( days => 5 )->set( hour => 23, minute => 59, second => 0 );
105
my $five_days_after = dt_from_string->add( days => 5 )->set( hour => 23, minute => 59, second => 0 );
106
is( $issue->{date_due}, $five_days_after );
106
is( $issue->{date_due}, $five_days_after );
107
107
108
# Specific case
109
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1);
110
my $another_item = $builder->build({
111
    source => 'Item',
112
    value => {
113
        biblionumber => $biblio->{biblionumber},
114
        homebranch => $branch->{branchcode},
115
        holdingbranch => $branch->{branchcode},
116
    },
117
});
118
119
C4::Circulation::AddIssue( $patron, $another_item->{barcode}, dt_from_string, undef, dt_from_string, undef, { onsite_checkout => 1 } );
120
( undef, undef, undef, $messages ) = C4::Circulation::CanBookBeIssued( $patron, $another_item->{barcode} );
121
is( $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}, 1, '' );
122
108
$schema->storage->txn_rollback;
123
$schema->storage->txn_rollback;
109
124
110
1;
125
1;
111
- 

Return to bug 16272