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

(-)a/C4/Circulation.pm (-2 / +9 lines)
Lines 386-391 sub TooMany { Link Here
386
	my $item		= shift;
386
	my $item		= shift;
387
    my $params = shift;
387
    my $params = shift;
388
    my $onsite_checkout = $params->{onsite_checkout} || 0;
388
    my $onsite_checkout = $params->{onsite_checkout} || 0;
389
    my $switch_onsite_checkout = $params->{switch_onsite_checkout} || 0;
389
    my $cat_borrower    = $borrower->{'categorycode'};
390
    my $cat_borrower    = $borrower->{'categorycode'};
390
    my $dbh             = C4::Context->dbh;
391
    my $dbh             = C4::Context->dbh;
391
	my $branch;
392
	my $branch;
Lines 476-482 sub TooMany { Link Here
476
            }
477
            }
477
        }
478
        }
478
        if ( C4::Context->preference('ConsiderOnSiteCheckoutsAsNormalCheckouts') ) {
479
        if ( C4::Context->preference('ConsiderOnSiteCheckoutsAsNormalCheckouts') ) {
479
            if ( $checkout_count >= $max_checkouts_allowed ) {
480
            my $delta = $switch_onsite_checkout ? 1 : 0;
481
            if ( $checkout_count >= $max_checkouts_allowed + $delta ) {
480
                return {
482
                return {
481
                    reason => 'TOO_MANY_CHECKOUTS',
483
                    reason => 'TOO_MANY_CHECKOUTS',
482
                    count => $checkout_count,
484
                    count => $checkout_count,
Lines 926-932 sub CanBookBeIssued { Link Here
926
#
928
#
927
    # JB34 CHECKS IF BORROWERS DON'T HAVE ISSUE TOO MANY BOOKS
929
    # JB34 CHECKS IF BORROWERS DON'T HAVE ISSUE TOO MANY BOOKS
928
    #
930
    #
929
    my $toomany = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout } );
931
    my $switch_onsite_checkout =
932
          C4::Context->preference('SwitchOnSiteCheckouts')
933
      and $issue->{onsite_checkout}
934
      and $issue
935
      and $issue->{borrowernumber} == $borrower->{'borrowernumber'} ? 1 : 0;
936
    my $toomany = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout, switch_onsite_checkout => $switch_onsite_checkout, } );
930
    # if TooMany max_allowed returns 0 the user doesn't have permission to check out this book
937
    # if TooMany max_allowed returns 0 the user doesn't have permission to check out this book
931
    if ( $toomany ) {
938
    if ( $toomany ) {
932
        if ( $toomany->{max_allowed} == 0 ) {
939
        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