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

(-)a/C4/Circulation.pm (-2 / +9 lines)
Lines 383-388 sub TooMany { Link Here
383
	my $item		= shift;
383
	my $item		= shift;
384
    my $params = shift;
384
    my $params = shift;
385
    my $onsite_checkout = $params->{onsite_checkout} || 0;
385
    my $onsite_checkout = $params->{onsite_checkout} || 0;
386
    my $switch_onsite_checkout = $params->{switch_onsite_checkout} || 0;
386
    my $cat_borrower    = $borrower->{'categorycode'};
387
    my $cat_borrower    = $borrower->{'categorycode'};
387
    my $dbh             = C4::Context->dbh;
388
    my $dbh             = C4::Context->dbh;
388
	my $branch;
389
	my $branch;
Lines 473-479 sub TooMany { Link Here
473
            }
474
            }
474
        }
475
        }
475
        if ( C4::Context->preference('ConsiderOnSiteCheckoutsAsNormalCheckouts') ) {
476
        if ( C4::Context->preference('ConsiderOnSiteCheckoutsAsNormalCheckouts') ) {
476
            if ( $checkout_count >= $max_checkouts_allowed ) {
477
            my $delta = $switch_onsite_checkout ? 1 : 0;
478
            if ( $checkout_count >= $max_checkouts_allowed + $delta ) {
477
                return {
479
                return {
478
                    reason => 'TOO_MANY_CHECKOUTS',
480
                    reason => 'TOO_MANY_CHECKOUTS',
479
                    count => $checkout_count,
481
                    count => $checkout_count,
Lines 892-898 sub CanBookBeIssued { Link Here
892
#
894
#
893
    # JB34 CHECKS IF BORROWERS DON'T HAVE ISSUE TOO MANY BOOKS
895
    # JB34 CHECKS IF BORROWERS DON'T HAVE ISSUE TOO MANY BOOKS
894
    #
896
    #
895
    my $toomany = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout } );
897
    my $switch_onsite_checkout =
898
          C4::Context->preference('SwitchOnSiteCheckouts')
899
      and $issue->{onsite_checkout}
900
      and $issue
901
      and $issue->{borrowernumber} == $borrower->{'borrowernumber'} ? 1 : 0;
902
    my $toomany = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout, switch_onsite_checkout => $switch_onsite_checkout, } );
896
    # if TooMany max_allowed returns 0 the user doesn't have permission to check out this book
903
    # if TooMany max_allowed returns 0 the user doesn't have permission to check out this book
897
    if ( $toomany ) {
904
    if ( $toomany ) {
898
        if ( $toomany->{max_allowed} == 0 ) {
905
        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