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

(-)a/C4/Circulation.pm (-9 / +9 lines)
Lines 1027-1045 sub CanBookBeIssued { Link Here
1027
    # if TooMany max_allowed returns 0 the user doesn't have permission to check out this book
1027
    # if TooMany max_allowed returns 0 the user doesn't have permission to check out this book
1028
    if ( $toomany && not exists $needsconfirmation{RENEW_ISSUE} ) {
1028
    if ( $toomany && not exists $needsconfirmation{RENEW_ISSUE} ) {
1029
        if ( $toomany->{max_allowed} == 0 ) {
1029
        if ( $toomany->{max_allowed} == 0 ) {
1030
            $needsconfirmation{PATRON_CANT}      = 1;
1030
            $needsconfirmation{PATRON_CANT}                  = 1;
1031
            $needsconfirmation{circulation_rule_PATRON_CANT} = $toomany->{circulation_rule};
1031
            $needsconfirmation{circulation_rule_PATRON_CANT} = $toomany->{circulation_rule};
1032
        }
1032
        }
1033
        if ( C4::Context->preference("AllowTooManyOverride") ) {
1033
        if ( C4::Context->preference("AllowTooManyOverride") ) {
1034
            $needsconfirmation{TOO_MANY}           = $toomany->{reason};
1034
            $needsconfirmation{TOO_MANY}                  = $toomany->{reason};
1035
            $needsconfirmation{current_loan_count} = $toomany->{count};
1035
            $needsconfirmation{current_loan_count}        = $toomany->{count};
1036
            $needsconfirmation{max_loans_allowed}  = $toomany->{max_allowed};
1036
            $needsconfirmation{max_loans_allowed}         = $toomany->{max_allowed};
1037
            $needsconfirmation{circulation_rule_TOO_MANY}   = $toomany->{circulation_rule};
1037
            $needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule};
1038
        } else {
1038
        } else {
1039
            $issuingimpossible{TOO_MANY}           = $toomany->{reason};
1039
            $issuingimpossible{TOO_MANY}                  = $toomany->{reason};
1040
            $issuingimpossible{current_loan_count} = $toomany->{count};
1040
            $issuingimpossible{current_loan_count}        = $toomany->{count};
1041
            $issuingimpossible{max_loans_allowed}  = $toomany->{max_allowed};
1041
            $issuingimpossible{max_loans_allowed}         = $toomany->{max_allowed};
1042
            $needsconfirmation{circulation_rule_TOO_MANY}   = $toomany->{circulation_rule};
1042
            $needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule};
1043
        }
1043
        }
1044
    }
1044
    }
1045
1045
(-)a/t/db_dependent/Circulation/TooMany.t (-12 / +11 lines)
Lines 209-216 subtest '1 Issuingrule exist with onsiteissueqty=unlimited' => sub { Link Here
209
    is_deeply(
209
    is_deeply(
210
        $data,
210
        $data,
211
        {
211
        {
212
            reason => 'TOO_MANY_CHECKOUTS',
212
            reason      => 'TOO_MANY_CHECKOUTS',
213
            count => 1,
213
            count       => 1,
214
            max_allowed => 1,
214
            max_allowed => 1,
215
        },
215
        },
216
        'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
216
        'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
Lines 289-303 subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed. Do a CO' => sub { Link Here
289
    my $issue = C4::Circulation::AddIssue( $patron, $item->barcode, dt_from_string() );
289
    my $issue = C4::Circulation::AddIssue( $patron, $item->barcode, dt_from_string() );
290
    like( $issue->issue_id, qr|^\d+$|, 'The issue should have been inserted' );
290
    like( $issue->issue_id, qr|^\d+$|, 'The issue should have been inserted' );
291
291
292
    t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0);
292
    t::lib::Mocks::mock_preference( 'ConsiderOnSiteCheckoutsAsNormalCheckouts', 0 );
293
    my $data = C4::Circulation::TooMany( $patron, $item );
293
    my $data = C4::Circulation::TooMany( $patron, $item );
294
    my $rule = delete $data->{circulation_rule};
294
    my $rule = delete $data->{circulation_rule};
295
    is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' );
295
    is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' );
296
    is_deeply(
296
    is_deeply(
297
        $data,
297
        $data,
298
        {
298
        {
299
            reason => 'TOO_MANY_CHECKOUTS',
299
            reason      => 'TOO_MANY_CHECKOUTS',
300
            count => 1,
300
            count       => 1,
301
            max_allowed => 1,
301
            max_allowed => 1,
302
        },
302
        },
303
        'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
303
        'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
Lines 357-363 subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed, Do a OSCO' => sub { Link Here
357
    my $issue = C4::Circulation::AddIssue( $patron, $item->barcode, dt_from_string(), undef, undef, undef, { onsite_checkout => 1 } );
357
    my $issue = C4::Circulation::AddIssue( $patron, $item->barcode, dt_from_string(), undef, undef, undef, { onsite_checkout => 1 } );
358
    like( $issue->issue_id, qr|^\d+$|, 'The issue should have been inserted' );
358
    like( $issue->issue_id, qr|^\d+$|, 'The issue should have been inserted' );
359
359
360
    t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0);
360
    t::lib::Mocks::mock_preference( 'ConsiderOnSiteCheckoutsAsNormalCheckouts', 0 );
361
    is(
361
    is(
362
        C4::Circulation::TooMany( $patron, $item ),
362
        C4::Circulation::TooMany( $patron, $item ),
363
        undef,
363
        undef,
Lines 369-390 subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed, Do a OSCO' => sub { Link Here
369
    is_deeply(
369
    is_deeply(
370
        $data,
370
        $data,
371
        {
371
        {
372
            reason => 'TOO_MANY_ONSITE_CHECKOUTS',
372
            reason      => 'TOO_MANY_ONSITE_CHECKOUTS',
373
            count => 1,
373
            count       => 1,
374
            max_allowed => 1,
374
            max_allowed => 1,
375
        },
375
        },
376
        'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
376
        'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
377
    );
377
    );
378
378
379
    t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1);
379
    t::lib::Mocks::mock_preference( 'ConsiderOnSiteCheckoutsAsNormalCheckouts', 1 );
380
    $data = C4::Circulation::TooMany( $patron, $item );
380
    $data = C4::Circulation::TooMany( $patron, $item );
381
    $rule = delete $data->{circulation_rule};
381
    $rule = delete $data->{circulation_rule};
382
    is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' );
382
    is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' );
383
    is_deeply(
383
    is_deeply(
384
        $data,
384
        $data,
385
        {
385
        {
386
            reason => 'TOO_MANY_CHECKOUTS',
386
            reason      => 'TOO_MANY_CHECKOUTS',
387
            count => 1,
387
            count       => 1,
388
            max_allowed => 1,
388
            max_allowed => 1,
389
        },
389
        },
390
        'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
390
        'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
391
- 

Return to bug 18139