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 870-890 sub CanBookBeIssued { Link Here
870
#
894
#
871
    # JB34 CHECKS IF BORROWERS DONT HAVE ISSUE TOO MANY BOOKS
895
    # JB34 CHECKS IF BORROWERS DONT HAVE ISSUE TOO MANY BOOKS
872
    #
896
    #
873
    my ($current_loan_count, $max_loans_allowed) = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout } );
897
    my $toomany = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout } );
874
    # if TooMany max_loans_allowed returns 0 the user doesn't have permission to check out this book
898
    # if TooMany max_allowed returns 0 the user doesn't have permission to check out this book
875
    if (defined $max_loans_allowed && $max_loans_allowed == 0) {
899
    if ( $toomany ) {
876
        $needsconfirmation{PATRON_CANT} = 1;
900
        if ( $toomany->{max_allowed} == 0 ) {
877
    } else {
901
            $needsconfirmation{PATRON_CANT} = 1;
878
        if($max_loans_allowed){
902
        }
879
            if ( C4::Context->preference("AllowTooManyOverride") ) {
903
        if ( C4::Context->preference("AllowTooManyOverride") ) {
880
                $needsconfirmation{TOO_MANY} = 1;
904
            $needsconfirmation{TOO_MANY} = $toomany->{reason};
881
                $needsconfirmation{current_loan_count} = $current_loan_count;
905
            $needsconfirmation{current_loan_count} = $toomany->{count};
882
                $needsconfirmation{max_loans_allowed} = $max_loans_allowed;
906
            $needsconfirmation{max_loans_allowed} = $toomany->{max_allowed};
883
            } else {
907
        } else {
884
                $issuingimpossible{TOO_MANY} = 1;
908
            $needsconfirmation{TOO_MANY} = $toomany->{reason};
885
                $issuingimpossible{current_loan_count} = $current_loan_count;
909
            $issuingimpossible{current_loan_count} = $toomany->{count};
886
                $issuingimpossible{max_loans_allowed} = $max_loans_allowed;
910
            $issuingimpossible{max_loans_allowed} = $toomany->{max_allowed};
887
            }
888
        }
911
        }
889
    }
912
    }
890
913
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-1 / +5 lines)
Lines 241-250 $(document).ready(function() { Link Here
241
    </li>
241
    </li>
242
[% END %]
242
[% END %]
243
243
244
[% IF ( TOO_MANY ) %]
244
[% IF TOO_MANY and TOO_MANY == 'TOO_MANY_CHECKOUTS' %]
245
    <li>Too many checked out. [% current_loan_count %] checked out, only [% max_loans_allowed %] are allowed.</li>
245
    <li>Too many checked out. [% current_loan_count %] checked out, only [% max_loans_allowed %] are allowed.</li>
246
[% END %]
246
[% END %]
247
247
248
[% IF TOO_MANY and TOO_MANY == 'TOO_MANY_ONSITE_CHECKOUTS' %]
249
    <li>Too many on-site checked out. [% current_loan_count %] on-site checked out, only [% max_loans_allowed %] are allowed.</li>
250
[% END %]
251
248
[% IF ( BORRNOTSAMEBRANCH ) %]
252
[% IF ( BORRNOTSAMEBRANCH ) %]
249
    <li>This patrons is from a different library ([% BORRNOTSAMEBRANCH %])</li>
253
    <li>This patrons is from a different library ([% BORRNOTSAMEBRANCH %])</li>
250
[% END %]
254
[% 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