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

(-)a/C4/Circulation.pm (-31 / +18 lines)
Lines 385-390 sub TooMany { Link Here
385
	# Get which branchcode we need
385
	# Get which branchcode we need
386
    $branch = _GetCircControlBranch($item_object->unblessed,$borrower);
386
    $branch = _GetCircControlBranch($item_object->unblessed,$borrower);
387
    my $type = $item_object->effective_itemtype;
387
    my $type = $item_object->effective_itemtype;
388
    my $checkout_type = $onsite_checkout
389
        ? $switch_onsite_checkout
390
            ? $Koha::Checkouts::type->{checkout}
391
            : $Koha::Checkouts::type->{onsite_checkout}
392
        : $Koha::Checkouts::type->{checkout};
388
393
389
    # given branch, patron category, and item type, determine
394
    # given branch, patron category, and item type, determine
390
    # applicable issuing rule
395
    # applicable issuing rule
Lines 396-409 sub TooMany { Link Here
396
            rule_name    => 'maxissueqty',
401
            rule_name    => 'maxissueqty',
397
        }
402
        }
398
    );
403
    );
399
    my $maxonsiteissueqty_rule = Koha::CirculationRules->get_effective_rule(
400
        {
401
            categorycode => $cat_borrower,
402
            itemtype     => $type,
403
            branchcode   => $branch,
404
            rule_name    => 'maxonsiteissueqty',
405
        }
406
    );
407
404
408
405
409
    # if a rule is found and has a loan limit set, count
406
    # if a rule is found and has a loan limit set, count
Lines 473-486 sub TooMany { Link Here
473
        my ( $checkout_count, $onsite_checkout_count ) = $dbh->selectrow_array( $count_query, {}, @bind_params );
470
        my ( $checkout_count, $onsite_checkout_count ) = $dbh->selectrow_array( $count_query, {}, @bind_params );
474
471
475
        my $max_checkouts_allowed = $maxissueqty_rule ? $maxissueqty_rule->rule_value : undef;
472
        my $max_checkouts_allowed = $maxissueqty_rule ? $maxissueqty_rule->rule_value : undef;
476
        my $max_onsite_checkouts_allowed = $maxonsiteissueqty_rule ? $maxonsiteissueqty_rule->rule_value : undef;
477
473
478
        if ( $onsite_checkout and $max_onsite_checkouts_allowed ne '' ) {
474
        if ( $onsite_checkout and $max_checkouts_allowed ne '' ) {
479
            if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed )  {
475
            if ( $onsite_checkout_count >= $max_checkouts_allowed )  {
480
                return {
476
                return {
481
                    reason => 'TOO_MANY_ONSITE_CHECKOUTS',
477
                    reason => 'TOO_MANY_ONSITE_CHECKOUTS',
482
                    count => $onsite_checkout_count,
478
                    count => $onsite_checkout_count,
483
                    max_allowed => $max_onsite_checkouts_allowed,
479
                    max_allowed => $max_checkouts_allowed,
484
                }
480
                }
485
            }
481
            }
486
        }
482
        }
Lines 505-511 sub TooMany { Link Here
505
    }
501
    }
506
502
507
    # Now count total loans against the limit for the branch
503
    # Now count total loans against the limit for the branch
508
    my $branch_borrower_circ_rule = GetBranchBorrowerCircRule($branch, $cat_borrower);
504
    my $branch_borrower_circ_rule = GetBranchBorrowerCircRule($branch, $cat_borrower, $checkout_type );
509
    if (defined($branch_borrower_circ_rule->{patron_maxissueqty}) and $branch_borrower_circ_rule->{patron_maxissueqty} ne '') {
505
    if (defined($branch_borrower_circ_rule->{patron_maxissueqty}) and $branch_borrower_circ_rule->{patron_maxissueqty} ne '') {
510
        my @bind_params = ();
506
        my @bind_params = ();
511
        my $branch_count_query = qq|
507
        my $branch_count_query = qq|
Lines 527-540 sub TooMany { Link Here
527
        }
523
        }
528
        my ( $checkout_count, $onsite_checkout_count ) = $dbh->selectrow_array( $branch_count_query, {}, @bind_params );
524
        my ( $checkout_count, $onsite_checkout_count ) = $dbh->selectrow_array( $branch_count_query, {}, @bind_params );
529
        my $max_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxissueqty};
525
        my $max_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxissueqty};
530
        my $max_onsite_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxonsiteissueqty};
531
526
532
        if ( $onsite_checkout and $max_onsite_checkouts_allowed ne '' ) {
527
        if ( $onsite_checkout and $max_checkouts_allowed ne '' ) {
533
            if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed )  {
528
            if ( $onsite_checkout_count >= $max_checkouts_allowed )  {
534
                return {
529
                return {
535
                    reason => 'TOO_MANY_ONSITE_CHECKOUTS',
530
                    reason => 'TOO_MANY_ONSITE_CHECKOUTS',
536
                    count => $onsite_checkout_count,
531
                    count => $onsite_checkout_count,
537
                    max_allowed => $max_onsite_checkouts_allowed,
532
                    max_allowed => $max_checkouts_allowed,
538
                }
533
                }
539
            }
534
            }
540
        }
535
        }
Lines 1601-1607 sub GetHardDueDate { Link Here
1601
1596
1602
=head2 GetBranchBorrowerCircRule
1597
=head2 GetBranchBorrowerCircRule
1603
1598
1604
  my $branch_cat_rule = GetBranchBorrowerCircRule($branchcode, $categorycode);
1599
  my $branch_cat_rule = GetBranchBorrowerCircRule($branchcode, $categorycode, $checkout_type);
1605
1600
1606
Retrieves circulation rule attributes that apply to the given
1601
Retrieves circulation rule attributes that apply to the given
1607
branch and patron category, regardless of item type.  
1602
branch and patron category, regardless of item type.  
Lines 1611-1631 patron_maxissueqty - maximum number of loans that a Link Here
1611
patron of the given category can have at the given
1606
patron of the given category can have at the given
1612
branch.  If the value is undef, no limit.
1607
branch.  If the value is undef, no limit.
1613
1608
1614
patron_maxonsiteissueqty - maximum of on-site checkouts that a
1609
The order in which rules are searched is defined in circulation
1615
patron of the given category can have at the given
1610
rules user interface.
1616
branch.  If the value is undef, no limit.
1617
1618
This will check for different branch/category combinations in the following order:
1619
branch and category
1620
branch only
1621
category only
1622
default branch and category
1623
1611
1624
If no rule has been found in the database, it will default to
1612
If no rule has been found in the database, it will default to
1625
the buillt in rule:
1613
the buillt in rule:
1626
1614
1627
patron_maxissueqty - undef
1615
patron_maxissueqty - undef
1628
patron_maxonsiteissueqty - undef
1629
1616
1630
C<$branchcode> and C<$categorycode> should contain the
1617
C<$branchcode> and C<$categorycode> should contain the
1631
literal branch code and patron category code, respectively - no
1618
literal branch code and patron category code, respectively - no
Lines 1634-1654 wildcards. Link Here
1634
=cut
1621
=cut
1635
1622
1636
sub GetBranchBorrowerCircRule {
1623
sub GetBranchBorrowerCircRule {
1637
    my ( $branchcode, $categorycode ) = @_;
1624
    my ( $branchcode, $categorycode, $checkout_type ) = @_;
1638
1625
1639
    # Initialize default values
1626
    # Initialize default values
1640
    my $rules = {
1627
    my $rules = {
1641
        patron_maxissueqty       => undef,
1628
        patron_maxissueqty       => undef,
1642
        patron_maxonsiteissueqty => undef,
1643
    };
1629
    };
1644
1630
1645
    # Search for rules!
1631
    # Search for rules!
1646
    foreach my $rule_name (qw( patron_maxissueqty patron_maxonsiteissueqty )) {
1632
    foreach my $rule_name (qw( patron_maxissueqty )) {
1647
        my $rule = Koha::CirculationRules->get_effective_rule(
1633
        my $rule = Koha::CirculationRules->get_effective_rule(
1648
            {
1634
            {
1649
                categorycode => $categorycode,
1635
                categorycode => $categorycode,
1650
                itemtype     => undef,
1636
                itemtype     => undef,
1651
                branchcode   => $branchcode,
1637
                branchcode   => $branchcode,
1638
                checkout_type => $checkout_type,
1652
                rule_name    => $rule_name,
1639
                rule_name    => $rule_name,
1653
            }
1640
            }
1654
        );
1641
        );
(-)a/Koha/CirculationRules.pm (-6 lines)
Lines 53-61 our $RULE_KINDS = { Link Here
53
    patron_maxissueqty => {
53
    patron_maxissueqty => {
54
        scope => [ 'branchcode', 'categorycode', 'checkout_type' ],
54
        scope => [ 'branchcode', 'categorycode', 'checkout_type' ],
55
    },
55
    },
56
    patron_maxonsiteissueqty => {
57
        scope => [ 'branchcode', 'categorycode' ],
58
    },
59
    max_holds => {
56
    max_holds => {
60
        scope => [ 'branchcode', 'categorycode' ],
57
        scope => [ 'branchcode', 'categorycode' ],
61
    },
58
    },
Lines 115-123 our $RULE_KINDS = { Link Here
115
    maxissueqty => {
112
    maxissueqty => {
116
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ],
113
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ],
117
    },
114
    },
118
    maxonsiteissueqty => {
119
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
120
    },
121
    maxsuspensiondays => {
115
    maxsuspensiondays => {
122
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ],
116
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'checkout_type' ],
123
    },
117
    },
(-)a/admin/smart-rules.pl (-18 / +1 lines)
Lines 84-90 if ($op eq 'delete') { Link Here
84
            itemtype     => $itemtype eq '*' ? undef : $itemtype,
84
            itemtype     => $itemtype eq '*' ? undef : $itemtype,
85
            rules        => {
85
            rules        => {
86
                maxissueqty                      => undef,
86
                maxissueqty                      => undef,
87
                maxonsiteissueqty                => undef,
88
                rentaldiscount                   => undef,
87
                rentaldiscount                   => undef,
89
                fine                             => undef,
88
                fine                             => undef,
90
                finedays                         => undef,
89
                finedays                         => undef,
Lines 127-133 elsif ($op eq 'delete-branch-cat') { Link Here
127
                    rules        => {
126
                    rules        => {
128
                        max_holds                      => undef,
127
                        max_holds                      => undef,
129
                        patron_maxissueqty             => undef,
128
                        patron_maxissueqty             => undef,
130
                        patron_maxonsiteissueqty       => undef,
131
                    }
129
                    }
132
                }
130
                }
133
            );
131
            );
Lines 150-156 elsif ($op eq 'delete-branch-cat') { Link Here
150
                    rules        => {
148
                    rules        => {
151
                        max_holds                => undef,
149
                        max_holds                => undef,
152
                        patron_maxissueqty       => undef,
150
                        patron_maxissueqty       => undef,
153
                        patron_maxonsiteissueqty => undef,
154
                    }
151
                    }
155
                }
152
                }
156
            );
153
            );
Lines 162-168 elsif ($op eq 'delete-branch-cat') { Link Here
162
                categorycode => undef,
159
                categorycode => undef,
163
                rules        => {
160
                rules        => {
164
                    patron_maxissueqty       => undef,
161
                    patron_maxissueqty       => undef,
165
                    patron_maxonsiteissueqty => undef,
166
                }
162
                }
167
            }
163
            }
168
        );
164
        );
Lines 185-191 elsif ($op eq 'delete-branch-cat') { Link Here
185
                rules        => {
181
                rules        => {
186
                    max_holds         => undef,
182
                    max_holds         => undef,
187
                    patron_maxissueqty       => undef,
183
                    patron_maxissueqty       => undef,
188
                    patron_maxonsiteissueqty => undef,
189
                }
184
                }
190
            }
185
            }
191
        );
186
        );
Lines 260-266 elsif ($op eq 'add') { Link Here
260
    my $chargeperiod = $input->param('chargeperiod');
255
    my $chargeperiod = $input->param('chargeperiod');
261
    my $chargeperiod_charge_at = $input->param('chargeperiod_charge_at');
256
    my $chargeperiod_charge_at = $input->param('chargeperiod_charge_at');
262
    my $maxissueqty  = strip_non_numeric($input->param('maxissueqty'));
257
    my $maxissueqty  = strip_non_numeric($input->param('maxissueqty'));
263
    my $maxonsiteissueqty  = strip_non_numeric($input->param('maxonsiteissueqty'));
264
    my $renewalsallowed  = $input->param('renewalsallowed');
258
    my $renewalsallowed  = $input->param('renewalsallowed');
265
    my $renewalperiod    = $input->param('renewalperiod');
259
    my $renewalperiod    = $input->param('renewalperiod');
266
    my $norenewalbefore  = $input->param('norenewalbefore');
260
    my $norenewalbefore  = $input->param('norenewalbefore');
Lines 288-298 elsif ($op eq 'add') { Link Here
288
    my $overduefinescap = $input->param('overduefinescap') || '';
282
    my $overduefinescap = $input->param('overduefinescap') || '';
289
    my $cap_fine_to_replacement_price = $input->param('cap_fine_to_replacement_price') eq 'on';
283
    my $cap_fine_to_replacement_price = $input->param('cap_fine_to_replacement_price') eq 'on';
290
    my $note = $input->param('note');
284
    my $note = $input->param('note');
291
    $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price";
285
    $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $cap_fine_to_replacement_price";
292
286
293
    my $rules = {
287
    my $rules = {
294
        maxissueqty                   => $maxissueqty,
288
        maxissueqty                   => $maxissueqty,
295
        maxonsiteissueqty             => $maxonsiteissueqty,
296
        rentaldiscount                => $rentaldiscount,
289
        rentaldiscount                => $rentaldiscount,
297
        fine                          => $fine,
290
        fine                          => $fine,
298
        finedays                      => $finedays,
291
        finedays                      => $finedays,
Lines 335-342 elsif ($op eq 'add') { Link Here
335
elsif ($op eq "set-branch-defaults") {
328
elsif ($op eq "set-branch-defaults") {
336
    my $categorycode  = $input->param('categorycode');
329
    my $categorycode  = $input->param('categorycode');
337
    my $patron_maxissueqty   = strip_non_numeric($input->param('patron_maxissueqty'));
330
    my $patron_maxissueqty   = strip_non_numeric($input->param('patron_maxissueqty'));
338
    my $patron_maxonsiteissueqty = $input->param('patron_maxonsiteissueqty');
339
    $patron_maxonsiteissueqty = strip_non_numeric($patron_maxonsiteissueqty);
340
    my $holdallowed   = $input->param('holdallowed');
331
    my $holdallowed   = $input->param('holdallowed');
341
    my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy');
332
    my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy');
342
    my $returnbranch  = $input->param('returnbranch');
333
    my $returnbranch  = $input->param('returnbranch');
Lines 362-368 elsif ($op eq "set-branch-defaults") { Link Here
362
                branchcode   => undef,
353
                branchcode   => undef,
363
                rules        => {
354
                rules        => {
364
                    patron_maxissueqty             => $patron_maxissueqty,
355
                    patron_maxissueqty             => $patron_maxissueqty,
365
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
366
                }
356
                }
367
            }
357
            }
368
        );
358
        );
Lines 384-390 elsif ($op eq "set-branch-defaults") { Link Here
384
                branchcode   => $branch,
374
                branchcode   => $branch,
385
                rules        => {
375
                rules        => {
386
                    patron_maxissueqty             => $patron_maxissueqty,
376
                    patron_maxissueqty             => $patron_maxissueqty,
387
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
388
                }
377
                }
389
            }
378
            }
390
        );
379
        );
Lines 401-408 elsif ($op eq "set-branch-defaults") { Link Here
401
elsif ($op eq "add-branch-cat") {
390
elsif ($op eq "add-branch-cat") {
402
    my $categorycode  = $input->param('categorycode');
391
    my $categorycode  = $input->param('categorycode');
403
    my $patron_maxissueqty = strip_non_numeric($input->param('patron_maxissueqty'));
392
    my $patron_maxissueqty = strip_non_numeric($input->param('patron_maxissueqty'));
404
    my $patron_maxonsiteissueqty = $input->param('patron_maxonsiteissueqty');
405
    $patron_maxonsiteissueqty = strip_non_numeric($patron_maxonsiteissueqty);
406
    my $max_holds = $input->param('max_holds');
393
    my $max_holds = $input->param('max_holds');
407
    $max_holds =~ s/\s//g;
394
    $max_holds =~ s/\s//g;
408
    $max_holds = undef if $max_holds !~ /^\d+/;
395
    $max_holds = undef if $max_holds !~ /^\d+/;
Lines 416-422 elsif ($op eq "add-branch-cat") { Link Here
416
                    rules        => {
403
                    rules        => {
417
                        max_holds         => $max_holds,
404
                        max_holds         => $max_holds,
418
                        patron_maxissueqty       => $patron_maxissueqty,
405
                        patron_maxissueqty       => $patron_maxissueqty,
419
                        patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
420
                    }
406
                    }
421
                }
407
                }
422
            );
408
            );
Lines 428-434 elsif ($op eq "add-branch-cat") { Link Here
428
                    rules        => {
414
                    rules        => {
429
                        max_holds         => $max_holds,
415
                        max_holds         => $max_holds,
430
                        patron_maxissueqty       => $patron_maxissueqty,
416
                        patron_maxissueqty       => $patron_maxissueqty,
431
                        patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
432
                    }
417
                    }
433
                }
418
                }
434
            );
419
            );
Lines 441-447 elsif ($op eq "add-branch-cat") { Link Here
441
                rules        => {
426
                rules        => {
442
                    max_holds         => $max_holds,
427
                    max_holds         => $max_holds,
443
                    patron_maxissueqty       => $patron_maxissueqty,
428
                    patron_maxissueqty       => $patron_maxissueqty,
444
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
445
                }
429
                }
446
            }
430
            }
447
        );
431
        );
Lines 453-459 elsif ($op eq "add-branch-cat") { Link Here
453
                rules        => {
437
                rules        => {
454
                    max_holds         => $max_holds,
438
                    max_holds         => $max_holds,
455
                    patron_maxissueqty       => $patron_maxissueqty,
439
                    patron_maxissueqty       => $patron_maxissueqty,
456
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
457
                }
440
                }
458
            }
441
            }
459
        );
442
        );
(-)a/installer/data/mysql/atomicupdate/bug_24101_2_convert_circulation_rules.perl (+33 lines)
Line 0 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
4
    # First, convert maxonsiteissueqty to maxissueqty
5
    my $update_sth = $dbh->prepare(q|
6
        UPDATE circulation_rules
7
        SET checkout_type = ?,
8
            rule_name = ?
9
        WHERE rule_name=?
10
    |);
11
    $update_sth->execute(
12
        'OS',                       # checkout_type => 'OS' (on-site checkout)
13
        'maxissueqty',
14
        'maxonsiteissueqty'
15
    );
16
17
    # Then, convert patron_maxonsiteissueqty to patron_maxissueqty
18
    $update_sth = $dbh->prepare(q|
19
        UPDATE circulation_rules
20
        SET checkout_type = ?,
21
            rule_name = ?
22
        WHERE rule_name=?
23
    |);
24
    $update_sth->execute(
25
        'OS',                       # checkout_type => 'OS' (on-site checkout)
26
        'patron_maxissueqty',
27
        'patron_maxonsiteissueqty'
28
    );
29
30
    # Always end with this (adjust the bug info)
31
    SetVersion( $DBversion );
32
    print "Upgrade to $DBversion done (Bug 24101 - Convert maxonsiteissueqty to maxissueqty )\n";
33
}
(-)a/installer/onboarding.pl (-2 lines)
Lines 273-279 if ( $step == 5 ) { Link Here
273
                holds_per_day                    => $holds_per_day,
273
                holds_per_day                    => $holds_per_day,
274
                holds_per_record                 => $holds_per_record,
274
                holds_per_record                 => $holds_per_record,
275
                maxissueqty                      => "",
275
                maxissueqty                      => "",
276
                maxonsiteissueqty                => "",
277
                maxsuspensiondays                => "",
276
                maxsuspensiondays                => "",
278
                no_auto_renewal_after            => "",
277
                no_auto_renewal_after            => "",
279
                no_auto_renewal_after_hard_limit => "",
278
                no_auto_renewal_after_hard_limit => "",
Lines 291-297 if ( $step == 5 ) { Link Here
291
            categorycode => $categorycode,
290
            categorycode => $categorycode,
292
            rules        => {
291
            rules        => {
293
                patron_maxissueqty       => "",
292
                patron_maxissueqty       => "",
294
                patron_maxonsiteissueqty => "",
295
                max_holds                => "",
293
                max_holds                => "",
296
            }
294
            }
297
        };
295
        };
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-32 / +5 lines)
Lines 91-97 Link Here
91
                <th>Actions</th>
91
                <th>Actions</th>
92
                <th>Note</th>
92
                <th>Note</th>
93
                <th>Current checkouts allowed</th>
93
                <th>Current checkouts allowed</th>
94
                <th>Current on-site checkouts allowed</th>
95
                <th>Loan period</th>
94
                <th>Loan period</th>
96
                <th>Unit</th>
95
                <th>Unit</th>
97
                <th>Hard due date</th>
96
                <th>Hard due date</th>
Lines 128-134 Link Here
128
                        [% SET i = '' UNLESS i.defined %]
127
                        [% SET i = '' UNLESS i.defined %]
129
                        [% SET note = all_rules.$c.$i.note %]
128
                        [% SET note = all_rules.$c.$i.note %]
130
                        [% SET maxissueqty = all_rules.$c.$i.maxissueqty %]
129
                        [% SET maxissueqty = all_rules.$c.$i.maxissueqty %]
131
                        [% SET maxonsiteissueqty = all_rules.$c.$i.maxonsiteissueqty %]
132
                        [% SET issuelength = all_rules.$c.$i.issuelength %]
130
                        [% SET issuelength = all_rules.$c.$i.issuelength %]
133
                        [% SET lengthunit = all_rules.$c.$i.lengthunit %]
131
                        [% SET lengthunit = all_rules.$c.$i.lengthunit %]
134
                        [% SET hardduedate = all_rules.$c.$i.hardduedate %]
132
                        [% SET hardduedate = all_rules.$c.$i.hardduedate %]
Lines 156-162 Link Here
156
                        [% SET article_requests = all_rules.$c.$i.article_requests %]
154
                        [% SET article_requests = all_rules.$c.$i.article_requests %]
157
                        [% SET rentaldiscount = all_rules.$c.$i.rentaldiscount %]
155
                        [% SET rentaldiscount = all_rules.$c.$i.rentaldiscount %]
158
156
159
                        [% SET show_rule = maxissueqty || maxonsiteissueqty || issuelength || lengthunit || hardduedate || hardduedatebefore || hardduedateexact || fine || chargeperiod || chargeperiod_charge_at || firstremind || overduefinescap || cap_fine_to_replacement_price || finedays || maxsuspensiondays || suspension_chargeperiod || renewalsallowed || renewalsallowed || norenewalbefore || auto_renew || no_auto_renewal_after || no_auto_renewal_after_hard_limit || reservesallowed || holds_per_day || holds_per_record || onshelfholds || opacitemholds || article_requests || article_requests %]
157
                        [% SET show_rule = maxissueqty || issuelength || lengthunit || hardduedate || hardduedatebefore || hardduedateexact || fine || chargeperiod || chargeperiod_charge_at || firstremind || overduefinescap || cap_fine_to_replacement_price || finedays || maxsuspensiondays || suspension_chargeperiod || renewalsallowed || renewalsallowed || norenewalbefore || auto_renew || no_auto_renewal_after || no_auto_renewal_after_hard_limit || reservesallowed || holds_per_day || holds_per_record || onshelfholds || opacitemholds || article_requests || article_requests %]
160
                        [% IF show_rule %]
158
                        [% IF show_rule %]
161
                            [% SET row_count = row_count + 1 %]
159
                            [% SET row_count = row_count + 1 %]
162
                            <tr row_countd="row_[% row_count | html %]">
160
                            <tr row_countd="row_[% row_count | html %]">
Lines 190-202 Link Here
190
                                            <span>Unlimited</span>
188
                                            <span>Unlimited</span>
191
                                        [% END %]
189
                                        [% END %]
192
                                    </td>
190
                                    </td>
193
                                    <td>
194
                                        [% IF maxonsiteissueqty.defined && maxonsiteissueqty != ''  %]
195
                                            [% maxonsiteissueqty | html %]
196
                                        [% ELSE %]
197
                                            <span>Unlimited</span>
198
                                        [% END %]
199
                                    </td>
200
                                    <td>[% issuelength | html %]</td>
191
                                    <td>[% issuelength | html %]</td>
201
                                    <td>
192
                                    <td>
202
                                        [% IF ( lengthunit == 'days' ) %]
193
                                        [% IF ( lengthunit == 'days' ) %]
Lines 333-339 Link Here
333
                    </td>
324
                    </td>
334
                    <td><input type="text" name="note" id="note" size="15" value="" maxlength="100"></td>
325
                    <td><input type="text" name="note" id="note" size="15" value="" maxlength="100"></td>
335
                    <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td>
326
                    <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td>
336
                    <td><input type="text" name="maxonsiteissueqty" id="maxonsiteissueqty" size="3" /></td>
337
                    <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td>
327
                    <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td>
338
                    <td>
328
                    <td>
339
                      <select name="lengthunit" id="lengthunit">
329
                      <select name="lengthunit" id="lengthunit">
Lines 417-423 Link Here
417
                      <th>&nbsp;</th>
407
                      <th>&nbsp;</th>
418
                      <th>Note</th>
408
                      <th>Note</th>
419
                      <th>Current checkouts allowed</th>
409
                      <th>Current checkouts allowed</th>
420
                      <th>Current on-site checkouts allowed</th>
421
                      <th>Loan period</th>
410
                      <th>Loan period</th>
422
                      <th>Unit</th>
411
                      <th>Unit</th>
423
                      <th>Hard due date</th>
412
                      <th>Hard due date</th>
Lines 460-466 Link Here
460
                <tr>
449
                <tr>
461
                    <th>&nbsp;</th>
450
                    <th>&nbsp;</th>
462
                    <th>Total current checkouts allowed</th>
451
                    <th>Total current checkouts allowed</th>
463
                    <th>Total current on-site checkouts allowed</th>
464
                    <th>Maximum total holds allowed (count)</th>
452
                    <th>Maximum total holds allowed (count)</th>
465
                    <th>Hold policy</th>
453
                    <th>Hold policy</th>
466
                    <th>Hold pickup library match</th>
454
                    <th>Hold pickup library match</th>
Lines 473-482 Link Here
473
                        [% SET patron_maxissueqty = CirculationRules.Search( current_branch, undef, undef, 'patron_maxissueqty' ) %]
461
                        [% SET patron_maxissueqty = CirculationRules.Search( current_branch, undef, undef, 'patron_maxissueqty' ) %]
474
                        <input type="text" name="patron_maxissueqty" size="3" value="[% patron_maxissueqty | html %]"/>
462
                        <input type="text" name="patron_maxissueqty" size="3" value="[% patron_maxissueqty | html %]"/>
475
                    </td>
463
                    </td>
476
                    <td>
477
                        [% SET patron_maxonsiteissueqty = CirculationRules.Search( current_branch, undef, undef, 'patron_maxonsiteissueqty' ) %]
478
                        <input type="text" name="patron_maxonsiteissueqty" size="3" value="[% patron_maxonsiteissueqty | html %]"/>
479
                    </td>
480
                    <td>
464
                    <td>
481
                        [% SET rule_value = CirculationRules.Search( current_branch, undef , undef, 'max_holds' ) %]
465
                        [% SET rule_value = CirculationRules.Search( current_branch, undef , undef, 'max_holds' ) %]
482
                        <input name="max_holds" size="3" value="[% rule_value | html %]" />
466
                        <input name="max_holds" size="3" value="[% rule_value | html %]" />
Lines 635-651 Link Here
635
                <tr>
619
                <tr>
636
                    <th>Patron category</th>
620
                    <th>Patron category</th>
637
                    <th>Total current checkouts allowed</th>
621
                    <th>Total current checkouts allowed</th>
638
                    <th>Total current on-site checkouts allowed</th>
639
                    <th>Total holds allowed</th>
622
                    <th>Total holds allowed</th>
640
                    <th>&nbsp;</th>
623
                    <th>&nbsp;</th>
641
                </tr>
624
                </tr>
642
                [% FOREACH c IN categorycodes %]
625
                [% FOREACH c IN categorycodes %]
643
                    [% NEXT UNLESS c %]
626
                    [% NEXT UNLESS c %]
644
                    [% SET patron_maxissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxissueqty' ) %]
627
                    [% SET patron_maxissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxissueqty' ) %]
645
                    [% SET patron_maxonsiteissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxonsiteissueqty' ) %]
646
                    [% SET max_holds = CirculationRules.Search( branchcode, c, undef, 'max_holds' ) %]
628
                    [% SET max_holds = CirculationRules.Search( branchcode, c, undef, 'max_holds' ) %]
647
629
648
                    [% IF  ( patron_maxissueqty.defined && patron_maxissueqty != '' ) || ( patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' ) || ( max_holds.defined && max_holds != '' ) %]
630
                    [% IF  ( patron_maxissueqty.defined && patron_maxissueqty != '' ) || ( max_holds.defined && max_holds != '' ) %]
649
                    <tr>
631
                    <tr>
650
                        <td>
632
                        <td>
651
                            [% IF c == undef %]
633
                            [% IF c == undef %]
Lines 661-673 Link Here
661
                                <span>Unlimited</span>
643
                                <span>Unlimited</span>
662
                            [% END %]
644
                            [% END %]
663
                        </td>
645
                        </td>
664
                        <td>
665
                            [% IF patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' %]
666
                                [% patron_maxonsiteissueqty | html %]
667
                            [% ELSE %]
668
                                <span>Unlimited</span>
669
                            [% END %]
670
                        </td>
671
                        <td>
646
                        <td>
672
                            [% IF max_holds.defined && max_holds != '' %]
647
                            [% IF max_holds.defined && max_holds != '' %]
673
                                [% max_holds | html %]
648
                                [% max_holds | html %]
Lines 691-697 Link Here
691
                        </select>
666
                        </select>
692
                    </td>
667
                    </td>
693
                    <td><input name="patron_maxissueqty" size="3" type="text" /></td>
668
                    <td><input name="patron_maxissueqty" size="3" type="text" /></td>
694
                    <td><input name="patron_maxonsiteissueqty" size="3" type="text" /></td>
695
                    <td><input name="max_holds" size="3" type="text" /></td>
669
                    <td><input name="max_holds" size="3" type="text" /></td>
696
                    <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</td>
670
                    <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</td>
697
                </tr>
671
                </tr>
Lines 988-994 Link Here
988
                        // specific processing for the Note column
962
                        // specific processing for the Note column
989
                        var note = $(this).find("a[name='viewnote']").data("content");
963
                        var note = $(this).find("a[name='viewnote']").data("content");
990
                        $(current_column).find("input[type='text']").val(note);
964
                        $(current_column).find("input[type='text']").val(note);
991
                    } else if ( i == 8 ) {
965
                    } else if ( i == 7 ) {
992
                        // specific processing for the Hard due date column
966
                        // specific processing for the Hard due date column
993
                        var select_value = $(this).find("input[type='hidden'][name='hardduedatecomparebackup']").val();
967
                        var select_value = $(this).find("input[type='hidden'][name='hardduedatecomparebackup']").val();
994
                        var input_value = '';
968
                        var input_value = '';
Lines 999-1005 Link Here
999
                        }
973
                        }
1000
                        $(current_column).find("input[type='text']").val(input_value);
974
                        $(current_column).find("input[type='text']").val(input_value);
1001
                        $(current_column).find("select").val(select_value);
975
                        $(current_column).find("select").val(select_value);
1002
                    } else if ( i == 14 ) {
976
                    } else if ( i == 13 ) {
1003
                        // specific processing for cap_fine_to_replacement_price
977
                        // specific processing for cap_fine_to_replacement_price
1004
                        var cap_fine_to_replacement_price = $(this).find("input[type='checkbox']");
978
                        var cap_fine_to_replacement_price = $(this).find("input[type='checkbox']");
1005
                        $('#cap_fine_to_replacement_price').prop('checked', cap_fine_to_replacement_price.is(':checked') );
979
                        $('#cap_fine_to_replacement_price').prop('checked', cap_fine_to_replacement_price.is(':checked') );
Lines 1024-1033 Link Here
1024
                            // Remove potential previous input added
998
                            // Remove potential previous input added
1025
                            $(current_column).find("input").remove();
999
                            $(current_column).find("input").remove();
1026
                            $(current_column).append("<input type='hidden' name='"+name+"' value='"+val+"' />");
1000
                            $(current_column).append("<input type='hidden' name='"+name+"' value='"+val+"' />");
1027
                        } else if ( i == 4 || i == 5 || i == 24 || i == 25 || i == 26 ) {
1001
                        } else if ( i == 4 || i == 23 || i == 24 || i == 25 ) {
1028
                            // If the value is not an integer for
1002
                            // If the value is not an integer for
1029
                            //     - "Current checkouts allowed"
1003
                            //     - "Current checkouts allowed"
1030
                            //     - "Current on-site checkouts allowed"
1031
                            //     - "Holds allowed (total)"
1004
                            //     - "Holds allowed (total)"
1032
                            //     - "Holds allowed (daily)"
1005
                            //     - "Holds allowed (daily)"
1033
                            //     - "Holds per record (count)"
1006
                            //     - "Holds per record (count)"
(-)a/t/db_dependent/Circulation/Branch.t (-14 / +33 lines)
Lines 25-31 use Koha::CirculationRules; Link Here
25
25
26
use Koha::Patrons;
26
use Koha::Patrons;
27
27
28
use Test::More tests => 14;
28
use Test::More tests => 15;
29
use t::lib::Mocks;
29
use t::lib::Mocks;
30
use t::lib::TestBuilder;
30
use t::lib::TestBuilder;
31
31
Lines 143-171 my $borrower_id1 = Koha::Patron->new({ Link Here
143
143
144
is_deeply(
144
is_deeply(
145
    GetBranchBorrowerCircRule(),
145
    GetBranchBorrowerCircRule(),
146
    { patron_maxissueqty => undef, patron_maxonsiteissueqty => undef },
146
    { patron_maxissueqty => undef },
147
"Without parameter, GetBranchBorrower returns undef (unilimited) for patron_maxissueqty and patron_maxonsiteissueqty if no rules defined"
147
"Without parameter, GetBranchBorrower returns undef (unilimited) for patron_maxissueqty if no rules defined"
148
);
148
);
149
149
150
Koha::CirculationRules->set_rules(
150
Koha::CirculationRules->set_rules(
151
    {
151
    {
152
        branchcode   => $samplebranch1->{branchcode},
152
        branchcode   => $samplebranch1->{branchcode},
153
        categorycode => $samplecat->{categorycode},
153
        categorycode => $samplecat->{categorycode},
154
        checkout_type => undef,
154
        rules        => {
155
        rules        => {
155
            patron_maxissueqty       => 5,
156
            patron_maxissueqty       => 5,
156
            patron_maxonsiteissueqty => 6,
157
        }
157
        }
158
    }
158
    }
159
);
159
);
160
160
161
Koha::CirculationRules->set_rules(
162
    {
163
        branchcode   => $samplebranch1->{branchcode},
164
        categorycode => $samplecat->{categorycode},
165
        checkout_type => $Koha::Checkouts::type->{onsite_checkout},
166
        rules        => {
167
            patron_maxissueqty       => 9001,
168
        }
169
    }
170
);
161
171
162
Koha::CirculationRules->set_rules(
172
Koha::CirculationRules->set_rules(
163
    {
173
    {
164
        branchcode   => $samplebranch2->{branchcode},
174
        branchcode   => $samplebranch2->{branchcode},
165
        categorycode => undef,
175
        categorycode => undef,
176
        checkout_type => undef,
166
        rules        => {
177
        rules        => {
167
            patron_maxissueqty       => 3,
178
            patron_maxissueqty       => 3,
168
            patron_maxonsiteissueqty => 2,
169
        }
179
        }
170
    }
180
    }
171
);
181
);
Lines 184-192 Koha::CirculationRules->set_rules( Link Here
184
    {
194
    {
185
        branchcode   => undef,
195
        branchcode   => undef,
186
        categorycode => undef,
196
        categorycode => undef,
197
        checkout_type => undef,
187
        rules        => {
198
        rules        => {
188
            patron_maxissueqty       => 4,
199
            patron_maxissueqty       => 4,
189
            patron_maxonsiteissueqty => 5,
190
        }
200
        }
191
    }
201
    }
192
);
202
);
Lines 235-260 Koha::CirculationRules->set_rules( Link Here
235
#Test GetBranchBorrowerCircRule
245
#Test GetBranchBorrowerCircRule
236
is_deeply(
246
is_deeply(
237
    GetBranchBorrowerCircRule(),
247
    GetBranchBorrowerCircRule(),
238
    { patron_maxissueqty => 4, patron_maxonsiteissueqty => 5 },
248
    { patron_maxissueqty => 4 },
239
"Without parameter, GetBranchBorrower returns the patron_maxissueqty and patron_maxonsiteissueqty of default_circ_rules"
249
"Without parameter, GetBranchBorrower returns the patron_maxissueqty of default_circ_rules"
240
);
250
);
241
is_deeply(
251
is_deeply(
242
    GetBranchBorrowerCircRule( $samplebranch2->{branchcode} ),
252
    GetBranchBorrowerCircRule( $samplebranch2->{branchcode} ),
243
    { patron_maxissueqty => 3, patron_maxonsiteissueqty => 2 },
253
    { patron_maxissueqty => 3 },
244
"Without only the branchcode specified, GetBranchBorrower returns the patron_maxissueqty and patron_maxonsiteissueqty corresponding"
254
"Without only the branchcode specified, GetBranchBorrower returns the patron_maxissueqty corresponding"
245
);
255
);
246
is_deeply(
256
is_deeply(
247
    GetBranchBorrowerCircRule(
257
    GetBranchBorrowerCircRule(
248
        $samplebranch1->{branchcode},
258
        $samplebranch1->{branchcode},
249
        $samplecat->{categorycode}
259
        $samplecat->{categorycode}
250
    ),
260
    ),
251
    { patron_maxissueqty => 5, patron_maxonsiteissueqty => 6 },
261
    { patron_maxissueqty => 5 },
252
    "GetBranchBorrower returns the patron_maxissueqty and patron_maxonsiteissueqty of the branch1 and the category1"
262
    "GetBranchBorrower returns the patron_maxissueqty of the branch1 and the category1"
263
);
264
is_deeply(
265
    GetBranchBorrowerCircRule(
266
        $samplebranch1->{branchcode},
267
        $samplecat->{categorycode},
268
        $Koha::Checkouts::type->{onsite_checkout}
269
    ),
270
    { patron_maxissueqty => 9001 },
271
     "GetBranchBorrower returns the patron_maxissueqty of the branch1 and the category1 and checkout_type on-site"
253
);
272
);
254
is_deeply(
273
is_deeply(
255
    GetBranchBorrowerCircRule( -1, -1 ),
274
    GetBranchBorrowerCircRule( -1, -1 ),
256
    { patron_maxissueqty => 4, patron_maxonsiteissueqty => 5 },
275
    { patron_maxissueqty => 4 },
257
"GetBranchBorrower with wrong parameters returns the patron_maxissueqty and patron_maxonsiteissueqty of default_circ_rules"
276
"GetBranchBorrower with wrong parameters returns the patron_maxissueqty of default_circ_rules"
258
);
277
);
259
278
260
#Test GetBranchItemRule
279
#Test GetBranchItemRule
(-)a/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t (-2 / +24 lines)
Lines 87-95 Koha::CirculationRules->set_rules( Link Here
87
        branchcode   => $branch->{branchcode},
87
        branchcode   => $branch->{branchcode},
88
        categorycode => undef,
88
        categorycode => undef,
89
        itemtype     => undef,
89
        itemtype     => undef,
90
        checkout_type => undef,
90
        rules        => {
91
        rules        => {
91
            maxissueqty       => 2,
92
            maxissueqty       => 2,
92
            maxonsiteissueqty => 1,
93
            lengthunit        => 'days',
93
            lengthunit        => 'days',
94
            issuelength       => 5,
94
            issuelength       => 5,
95
            hardduedate        => undef,
95
            hardduedate        => undef,
Lines 97-102 Koha::CirculationRules->set_rules( Link Here
97
        }
97
        }
98
    }
98
    }
99
);
99
);
100
Koha::CirculationRules->set_rules(
101
    {
102
        branchcode   => $branch->{branchcode},
103
        categorycode => undef,
104
        itemtype     => undef,
105
        checkout_type => $Koha::Checkouts::type->{onsite_checkout},
106
        rules        => {
107
            maxissueqty       => 1,
108
        }
109
    }
110
);
100
111
101
t::lib::Mocks::mock_userenv({ patron => $patron });
112
t::lib::Mocks::mock_userenv({ patron => $patron });
102
113
Lines 159-167 Koha::CirculationRules->set_rules( Link Here
159
        branchcode   => $branch->{branchcode},
170
        branchcode   => $branch->{branchcode},
160
        categorycode => undef,
171
        categorycode => undef,
161
        itemtype     => undef,
172
        itemtype     => undef,
173
        checkout_type => undef,
174
        rules        => {
175
            maxissueqty       => 2,
176
        }
177
    }
178
);
179
Koha::CirculationRules->set_rules(
180
    {
181
        branchcode   => $branch->{branchcode},
182
        categorycode => undef,
183
        itemtype     => undef,
184
        checkout_type => $Koha::Checkouts::type->{onsite_checkout},
162
        rules        => {
185
        rules        => {
163
            maxissueqty       => 2,
186
            maxissueqty       => 2,
164
            maxonsiteissueqty => 1,
165
        }
187
        }
166
    }
188
    }
167
);
189
);
(-)a/t/db_dependent/Circulation/TooMany.t (-13 / +24 lines)
Lines 108-116 subtest '1 Issuingrule exist 0 0: no issue allowed' => sub { Link Here
108
            branchcode   => $branch->{branchcode},
108
            branchcode   => $branch->{branchcode},
109
            categorycode => $category->{categorycode},
109
            categorycode => $category->{categorycode},
110
            itemtype     => undef,
110
            itemtype     => undef,
111
            checkout_type => undef,
111
            rules        => {
112
            rules        => {
112
                maxissueqty       => 0,
113
                maxissueqty       => 0,
113
                maxonsiteissueqty => 0,
114
            }
114
            }
115
        },
115
        },
116
    );
116
    );
Lines 165-173 subtest '1 Issuingrule exist with onsiteissueqty=unlimited' => sub { Link Here
165
            branchcode   => $branch->{branchcode},
165
            branchcode   => $branch->{branchcode},
166
            categorycode => $category->{categorycode},
166
            categorycode => $category->{categorycode},
167
            itemtype     => undef,
167
            itemtype     => undef,
168
            checkout_type => undef,
168
            rules        => {
169
            rules        => {
169
                maxissueqty       => 1,
170
                maxissueqty       => 1,
170
                maxonsiteissueqty => undef,
171
            }
172
        },
173
    );
174
    Koha::CirculationRules->set_rules(
175
        {
176
            branchcode   => $branch->{branchcode},
177
            categorycode => $category->{categorycode},
178
            itemtype     => undef,
179
            checkout_type => $Koha::Checkouts::type->{onsite_checkout},
180
            rules        => {
181
                maxissueqty       => undef,
171
            }
182
            }
172
        },
183
        },
173
    );
184
    );
Lines 220-228 subtest '1 Issuingrule exist 1 1: issue is allowed' => sub { Link Here
220
            branchcode   => $branch->{branchcode},
231
            branchcode   => $branch->{branchcode},
221
            categorycode => $category->{categorycode},
232
            categorycode => $category->{categorycode},
222
            itemtype     => undef,
233
            itemtype     => undef,
234
            checkout_type => undef,
223
            rules        => {
235
            rules        => {
224
                maxissueqty       => 1,
236
                maxissueqty       => 1,
225
                maxonsiteissueqty => 1,
226
            }
237
            }
227
        }
238
        }
228
    );
239
    );
Lines 260-268 subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed. Do a CO' => sub { Link Here
260
            branchcode   => $branch->{branchcode},
271
            branchcode   => $branch->{branchcode},
261
            categorycode => $category->{categorycode},
272
            categorycode => $category->{categorycode},
262
            itemtype     => undef,
273
            itemtype     => undef,
274
            checkout_type => undef,
263
            rules        => {
275
            rules        => {
264
                maxissueqty       => 1,
276
                maxissueqty       => 1,
265
                maxonsiteissueqty => 1,
266
            }
277
            }
267
        }
278
        }
268
    );
279
    );
Lines 316-324 subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed, Do a OSCO' => sub { Link Here
316
            branchcode   => $branch->{branchcode},
327
            branchcode   => $branch->{branchcode},
317
            categorycode => $category->{categorycode},
328
            categorycode => $category->{categorycode},
318
            itemtype     => undef,
329
            itemtype     => undef,
330
            checkout_type => undef,
319
            rules        => {
331
            rules        => {
320
                maxissueqty       => 1,
332
                maxissueqty       => 1,
321
                maxonsiteissueqty => 1,
322
            }
333
            }
323
        }
334
        }
324
    );
335
    );
Lines 375-383 subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub { Link Here
375
            branchcode   => $branch->{branchcode},
386
            branchcode   => $branch->{branchcode},
376
            categorycode => $category->{categorycode},
387
            categorycode => $category->{categorycode},
377
            itemtype     => undef,
388
            itemtype     => undef,
389
            checkout_type => undef,
378
            rules        => {
390
            rules        => {
379
                maxissueqty       => 1,
391
                maxissueqty       => 1,
380
                maxonsiteissueqty => 1,
381
            }
392
            }
382
        }
393
        }
383
    );
394
    );
Lines 427-435 subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub { Link Here
427
            branchcode   => $branch->{branchcode},
438
            branchcode   => $branch->{branchcode},
428
            categorycode => $category->{categorycode},
439
            categorycode => $category->{categorycode},
429
            itemtype     => undef,
440
            itemtype     => undef,
441
            checkout_type => undef,
430
            rules        => {
442
            rules        => {
431
                maxissueqty       => 1,
443
                maxissueqty       => 1,
432
                maxonsiteissueqty => 1,
433
            }
444
            }
434
        }
445
        }
435
    );
446
    );
Lines 505-510 subtest 'General vs specific rules limit quantity correctly' => sub { Link Here
505
            categorycode => '*',
516
            categorycode => '*',
506
            itemtype     => $itemtype->{itemtype},
517
            itemtype     => $itemtype->{itemtype},
507
            branchcode   => '*',
518
            branchcode   => '*',
519
            checkout_type => '*',
508
            rules        => {
520
            rules        => {
509
                issuelength => 1,
521
                issuelength => 1,
510
                firstremind => 1,        # 1 day of grace
522
                firstremind => 1,        # 1 day of grace
Lines 519-528 subtest 'General vs specific rules limit quantity correctly' => sub { Link Here
519
        {
531
        {
520
            branchcode   => '*',
532
            branchcode   => '*',
521
            categorycode => '*',
533
            categorycode => '*',
534
            checkout_type => '*',
522
            itemtype     => $itemtype->{itemtype},
535
            itemtype     => $itemtype->{itemtype},
523
            rules        => {
536
            rules        => {
524
                maxissueqty       => 1,
537
                maxissueqty       => 1,
525
                maxonsiteissueqty => 1,
526
            }
538
            }
527
        }
539
        }
528
    );
540
    );
Lines 573-581 subtest 'General vs specific rules limit quantity correctly' => sub { Link Here
573
            branchcode   => $branch->{branchcode},
585
            branchcode   => $branch->{branchcode},
574
            categorycode => $category->{categorycode},
586
            categorycode => $category->{categorycode},
575
            itemtype     => $itemtype->{itemtype},
587
            itemtype     => $itemtype->{itemtype},
588
            checkout_type => undef,
576
            rules        => {
589
            rules        => {
577
                maxissueqty       => 1,
590
                maxissueqty       => 1,
578
                maxonsiteissueqty => 1,
579
            }
591
            }
580
        }
592
        }
581
    );
593
    );
Lines 669-677 subtest 'General vs specific rules limit quantity correctly' => sub { Link Here
669
            branchcode   => $branch2->{branchcode},
681
            branchcode   => $branch2->{branchcode},
670
            categorycode => $category->{categorycode},
682
            categorycode => $category->{categorycode},
671
            itemtype     => $itemtype->{itemtype},
683
            itemtype     => $itemtype->{itemtype},
684
            checkout_type => undef,
672
            rules        => {
685
            rules        => {
673
                maxissueqty       => 1,
686
                maxissueqty       => 1,
674
                maxonsiteissueqty => 1,
675
            }
687
            }
676
        }
688
        }
677
    );
689
    );
Lines 691-699 subtest 'empty string means unlimited' => sub { Link Here
691
            branchcode   => '*',
703
            branchcode   => '*',
692
            categorycode => '*',
704
            categorycode => '*',
693
            itemtype     => '*',
705
            itemtype     => '*',
706
            checkout_type => '*',
694
            rules        => {
707
            rules        => {
695
                maxissueqty       => '',
708
                maxissueqty       => '',
696
                maxonsiteissueqty => '',
697
            }
709
            }
698
        },
710
        },
699
    );
711
    );
Lines 706-712 subtest 'empty string means unlimited' => sub { Link Here
706
    is(
718
    is(
707
        C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ),
719
        C4::Circulation::TooMany( $patron, $item_object, { onsite_checkout => 1 } ),
708
        undef,
720
        undef,
709
        'maxonsiteissueqty="" should mean unlimited'
721
        'maxissueqty="" should mean unlimited'
710
    );
722
    );
711
723
712
    teardown();
724
    teardown();
713
- 

Return to bug 25089