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

(-)a/C4/Circulation.pm (-21 / +44 lines)
Lines 462-477 sub TooMany { Link Here
462
462
463
        if ( $onsite_checkout ) {
463
        if ( $onsite_checkout ) {
464
            if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed )  {
464
            if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed )  {
465
                return ($onsite_checkout_count, $max_onsite_checkouts_allowed);
465
                return {
466
                    reason => 'TOO_MANY_ONSITE_CHECKOUTS',
467
                    count => $onsite_checkout_count,
468
                    max_allowed => $max_onsite_checkouts_allowed,
469
                }
466
            }
470
            }
467
        }
471
        }
468
        if ( C4::Context->preference('ConsiderOnSiteCheckoutsAsNormalCheckouts') ) {
472
        if ( C4::Context->preference('ConsiderOnSiteCheckoutsAsNormalCheckouts') ) {
469
            if ( $checkout_count >= $max_checkouts_allowed ) {
473
            if ( $checkout_count >= $max_checkouts_allowed ) {
470
                return ($checkout_count, $max_checkouts_allowed);
474
                return {
475
                    reason => 'TOO_MANY_CHECKOUTS',
476
                    count => $checkout_count,
477
                    max_allowed => $max_checkouts_allowed,
478
                };
471
            }
479
            }
472
        } elsif ( not $onsite_checkout ) {
480
        } elsif ( not $onsite_checkout ) {
473
            if ( $checkout_count - $onsite_checkout_count >= $max_checkouts_allowed )  {
481
            if ( $checkout_count - $onsite_checkout_count >= $max_checkouts_allowed )  {
474
                return ($checkout_count - $onsite_checkout_count, $max_checkouts_allowed);
482
                return {
483
                    reason => 'TOO_MANY_CHECKOUTS',
484
                    count => $checkout_count - $onsite_checkout_count,
485
                    max_allowed => $max_checkouts_allowed,
486
                };
475
            }
487
            }
476
        }
488
        }
477
    }
489
    }
Lines 503-518 sub TooMany { Link Here
503
515
504
        if ( $onsite_checkout ) {
516
        if ( $onsite_checkout ) {
505
            if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed )  {
517
            if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed )  {
506
                return ($onsite_checkout_count, $max_onsite_checkouts_allowed);
518
                return {
519
                    reason => 'TOO_MANY_ONSITE_CHECKOUTS',
520
                    count => $onsite_checkout_count,
521
                    max_allowed => $max_onsite_checkouts_allowed,
522
                }
507
            }
523
            }
508
        }
524
        }
509
        if ( C4::Context->preference('ConsiderOnSiteCheckoutsAsNormalCheckouts') ) {
525
        if ( C4::Context->preference('ConsiderOnSiteCheckoutsAsNormalCheckouts') ) {
510
            if ( $checkout_count >= $max_checkouts_allowed ) {
526
            if ( $checkout_count >= $max_checkouts_allowed ) {
511
                return ($checkout_count, $max_checkouts_allowed);
527
                return {
528
                    reason => 'TOO_MANY_CHECKOUTS',
529
                    count => $checkout_count,
530
                    max_allowed => $max_checkouts_allowed,
531
                };
512
            }
532
            }
513
        } elsif ( not $onsite_checkout ) {
533
        } elsif ( not $onsite_checkout ) {
514
            if ( $checkout_count - $onsite_checkout_count >= $max_checkouts_allowed )  {
534
            if ( $checkout_count - $onsite_checkout_count >= $max_checkouts_allowed )  {
515
                return ($checkout_count - $onsite_checkout_count, $max_checkouts_allowed);
535
                return {
536
                    reason => 'TOO_MANY_CHECKOUTS',
537
                    count => $checkout_count - $onsite_checkout_count,
538
                    max_allowed => $max_checkouts_allowed,
539
                };
516
            }
540
            }
517
        }
541
        }
518
    }
542
    }
Lines 861-881 sub CanBookBeIssued { Link Here
861
#
885
#
862
    # JB34 CHECKS IF BORROWERS DON'T HAVE ISSUE TOO MANY BOOKS
886
    # JB34 CHECKS IF BORROWERS DON'T HAVE ISSUE TOO MANY BOOKS
863
    #
887
    #
864
    my ($current_loan_count, $max_loans_allowed) = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout } );
888
    my $toomany = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout } );
865
    # if TooMany max_loans_allowed returns 0 the user doesn't have permission to check out this book
889
    # if TooMany max_allowed returns 0 the user doesn't have permission to check out this book
866
    if (defined $max_loans_allowed && $max_loans_allowed == 0) {
890
    if ( $toomany ) {
867
        $needsconfirmation{PATRON_CANT} = 1;
891
        if ( $toomany->{max_allowed} == 0 ) {
868
    } else {
892
            $needsconfirmation{PATRON_CANT} = 1;
869
        if($max_loans_allowed){
893
        }
870
            if ( C4::Context->preference("AllowTooManyOverride") ) {
894
        if ( C4::Context->preference("AllowTooManyOverride") ) {
871
                $needsconfirmation{TOO_MANY} = 1;
895
            $needsconfirmation{TOO_MANY} = $toomany->{reason};
872
                $needsconfirmation{current_loan_count} = $current_loan_count;
896
            $needsconfirmation{current_loan_count} = $toomany->{count};
873
                $needsconfirmation{max_loans_allowed} = $max_loans_allowed;
897
            $needsconfirmation{max_loans_allowed} = $toomany->{max_allowed};
874
            } else {
898
        } else {
875
                $issuingimpossible{TOO_MANY} = 1;
899
            $needsconfirmation{TOO_MANY} = $toomany->{reason};
876
                $issuingimpossible{current_loan_count} = $current_loan_count;
900
            $issuingimpossible{current_loan_count} = $toomany->{count};
877
                $issuingimpossible{max_loans_allowed} = $max_loans_allowed;
901
            $issuingimpossible{max_loans_allowed} = $toomany->{max_allowed};
878
            }
879
        }
902
        }
880
    }
903
    }
881
904
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-1 / +5 lines)
Lines 252-261 $(document).ready(function() { Link Here
252
    </li>
252
    </li>
253
[% END %]
253
[% END %]
254
254
255
[% IF ( TOO_MANY ) %]
255
[% IF TOO_MANY and TOO_MANY == 'TOO_MANY_CHECKOUTS' %]
256
    <li>Too many checked out. [% current_loan_count %] checked out, only [% max_loans_allowed %] are allowed.</li>
256
    <li>Too many checked out. [% current_loan_count %] checked out, only [% max_loans_allowed %] are allowed.</li>
257
[% END %]
257
[% END %]
258
258
259
[% IF TOO_MANY and TOO_MANY == 'TOO_MANY_ONSITE_CHECKOUTS' %]
260
    <li>Too many on-site checked out. [% current_loan_count %] on-site checked out, only [% max_loans_allowed %] are allowed.</li>
261
[% END %]
262
259
[% IF ( BORRNOTSAMEBRANCH ) %]
263
[% IF ( BORRNOTSAMEBRANCH ) %]
260
    <li>This patrons is from a different library ([% BORRNOTSAMEBRANCH %])</li>
264
    <li>This patrons is from a different library ([% BORRNOTSAMEBRANCH %])</li>
261
[% END %]
265
[% END %]
(-)a/t/db_dependent/Circulation/TooMany.t (-33 / +96 lines)
Lines 101-125 subtest '1 Issuingrule exist 0 0: no issue allowed' => sub { Link Here
101
    });
101
    });
102
    t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0);
102
    t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0);
103
    is_deeply(
103
    is_deeply(
104
        [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ) ],
104
        C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ),
105
        [ 0, 0 ],
105
        {
106
            reason => 'TOO_MANY_CHECKOUTS',
107
            count => 0,
108
            max_allowed => 0,
109
        },
106
        'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
110
        'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
107
    );
111
    );
108
    is_deeply(
112
    is_deeply(
109
        [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ) ],
113
        C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ),
110
        [ 0, 0 ],
114
        {
115
            reason => 'TOO_MANY_ONSITE_CHECKOUTS',
116
            count => 0,
117
            max_allowed => 0,
118
        },
111
        'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
119
        'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
112
    );
120
    );
113
121
114
    t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1);
122
    t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1);
115
    is_deeply(
123
    is_deeply(
116
        [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ) ],
124
        C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ),
117
        [ 0, 0 ],
125
        {
126
            reason => 'TOO_MANY_CHECKOUTS',
127
            count => 0,
128
            max_allowed => 0,
129
        },
118
        'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
130
        'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
119
    );
131
    );
120
    is_deeply(
132
    is_deeply(
121
        [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ) ],
133
        C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ),
122
        [ 0, 0 ],
134
        {
135
            reason => 'TOO_MANY_ONSITE_CHECKOUTS',
136
            count => 0,
137
            max_allowed => 0,
138
        },
123
        'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
139
        'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
124
    );
140
    );
125
141
Lines 183-190 subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed. Do a CO' => sub { Link Here
183
199
184
    t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0);
200
    t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0);
185
    is_deeply(
201
    is_deeply(
186
        [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ) ],
202
        C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ),
187
        [ 1, 1 ],
203
        {
204
            reason => 'TOO_MANY_CHECKOUTS',
205
            count => 1,
206
            max_allowed => 1,
207
        },
188
        'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
208
        'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
189
    );
209
    );
190
    is(
210
    is(
Lines 195-207 subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed. Do a CO' => sub { Link Here
195
215
196
    t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1);
216
    t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1);
197
    is_deeply(
217
    is_deeply(
198
        [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ) ],
218
        C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ),
199
        [ 1, 1 ],
219
        {
220
            reason => 'TOO_MANY_CHECKOUTS',
221
            count => 1,
222
            max_allowed => 1,
223
        },
200
        'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
224
        'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
201
    );
225
    );
202
    is_deeply(
226
    is_deeply(
203
        [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ) ],
227
        C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ),
204
        [ 1, 1 ],
228
        {
229
            reason => 'TOO_MANY_CHECKOUTS',
230
            count => 1,
231
            max_allowed => 1,
232
        },
205
        'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
233
        'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
206
    );
234
    );
207
235
Lines 231-250 subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed, Do a OSCO' => sub { Link Here
231
        'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
259
        'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
232
    );
260
    );
233
    is_deeply(
261
    is_deeply(
234
        [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ) ],
262
        C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ),
235
        [ 1, 1 ],
263
        {
264
            reason => 'TOO_MANY_ONSITE_CHECKOUTS',
265
            count => 1,
266
            max_allowed => 1,
267
        },
236
        'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
268
        'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
237
    );
269
    );
238
270
239
    t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1);
271
    t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1);
240
    is_deeply(
272
    is_deeply(
241
        [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ) ],
273
        C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ),
242
        [ 1, 1 ],
274
        {
275
            reason => 'TOO_MANY_CHECKOUTS',
276
            count => 1,
277
            max_allowed => 1,
278
        },
243
        'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
279
        'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
244
    );
280
    );
245
    is_deeply(
281
    is_deeply(
246
        [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ) ],
282
        C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ),
247
        [ 1, 1 ],
283
        {
284
            reason => 'TOO_MANY_ONSITE_CHECKOUTS',
285
            count => 1,
286
            max_allowed => 1,
287
        },
248
        'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
288
        'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
249
    );
289
    );
250
290
Lines 271-278 subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub { Link Here
271
311
272
    t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0);
312
    t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0);
273
    is_deeply(
313
    is_deeply(
274
        [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ) ],
314
        C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ),
275
        [ 1, 1 ],
315
        {
316
            reason => 'TOO_MANY_CHECKOUTS',
317
            count => 1,
318
            max_allowed => 1,
319
        },
276
        'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
320
        'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
277
    );
321
    );
278
    is(
322
    is(
Lines 283-295 subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub { Link Here
283
327
284
    t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1);
328
    t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1);
285
    is_deeply(
329
    is_deeply(
286
        [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ) ],
330
        C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ),
287
        [ 1, 1 ],
331
        {
332
            reason => 'TOO_MANY_CHECKOUTS',
333
            count => 1,
334
            max_allowed => 1,
335
        },
288
        'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
336
        'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
289
    );
337
    );
290
    is_deeply(
338
    is_deeply(
291
        [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ) ],
339
        C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ),
292
        [ 1, 1 ],
340
        {
341
            reason => 'TOO_MANY_CHECKOUTS',
342
            count => 1,
343
            max_allowed => 1,
344
        },
293
        'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
345
        'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
294
    );
346
    );
295
347
Lines 305-324 subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub { Link Here
305
        'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
357
        'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
306
    );
358
    );
307
    is_deeply(
359
    is_deeply(
308
        [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ) ],
360
        C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ),
309
        [ 1, 1 ],
361
        {
362
            reason => 'TOO_MANY_ONSITE_CHECKOUTS',
363
            count => 1,
364
            max_allowed => 1,
365
        },
310
        'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
366
        'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0'
311
    );
367
    );
312
368
313
    t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1);
369
    t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1);
314
    is_deeply(
370
    is_deeply(
315
        [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ) ],
371
        C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ),
316
        [ 1, 1 ],
372
        {
373
            reason => 'TOO_MANY_CHECKOUTS',
374
            count => 1,
375
            max_allowed => 1,
376
        },
317
        'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
377
        'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
318
    );
378
    );
319
    is_deeply(
379
    is_deeply(
320
        [ C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ) ],
380
        C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ),
321
        [ 1, 1 ],
381
        {
382
            reason => 'TOO_MANY_ONSITE_CHECKOUTS',
383
            count => 1,
384
            max_allowed => 1,
385
        },
322
        'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
386
        'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1'
323
    );
387
    );
324
388
325
- 

Return to bug 14045