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

(-)a/C4/Circulation.pm (-34 / +15 lines)
Lines 417-422 sub TooMany { Link Here
417
            categorycode => $cat_borrower,
417
            categorycode => $cat_borrower,
418
            itemtype     => $parent_type,
418
            itemtype     => $parent_type,
419
            branchcode   => $branch,
419
            branchcode   => $branch,
420
            onsite_checkout => $onsite_checkout,
420
            rule_name    => 'maxissueqty',
421
            rule_name    => 'maxissueqty',
421
        }
422
        }
422
    ) if $parent_type;
423
    ) if $parent_type;
Lines 428-447 sub TooMany { Link Here
428
            categorycode => $cat_borrower,
429
            categorycode => $cat_borrower,
429
            itemtype     => $type,
430
            itemtype     => $type,
430
            branchcode   => $branch,
431
            branchcode   => $branch,
432
            onsite_checkout => $onsite_checkout,
431
            rule_name    => 'maxissueqty',
433
            rule_name    => 'maxissueqty',
432
        }
434
        }
433
    );
435
    );
434
436
435
    my $maxonsiteissueqty_rule = Koha::CirculationRules->get_effective_rule(
436
        {
437
            categorycode => $cat_borrower,
438
            itemtype     => $type,
439
            branchcode   => $branch,
440
            rule_name    => 'maxonsiteissueqty',
441
        }
442
    );
443
444
445
    my $patron = Koha::Patrons->find($borrower->{borrowernumber});
437
    my $patron = Koha::Patrons->find($borrower->{borrowernumber});
446
    # if a rule is found and has a loan limit set, count
438
    # if a rule is found and has a loan limit set, count
447
    # how many loans the patron already has that meet that
439
    # how many loans the patron already has that meet that
Lines 477-482 sub TooMany { Link Here
477
                        branchcode => $maxissueqty_rule->branchcode,
469
                        branchcode => $maxissueqty_rule->branchcode,
478
                        categorycode => [ $maxissueqty_rule->categorycode, $cat_borrower ],
470
                        categorycode => [ $maxissueqty_rule->categorycode, $cat_borrower ],
479
                        itemtype  => { '!=' => undef },
471
                        itemtype  => { '!=' => undef },
472
                        onsite_checkout => $onsite_checkout,
480
                        rule_name => 'maxissueqty'
473
                        rule_name => 'maxissueqty'
481
                    }
474
                    }
482
                )->get_column('itemtype');
475
                )->get_column('itemtype');
Lines 512-518 sub TooMany { Link Here
512
            onsite_checkout_count        => $onsite_checkout_count,
505
            onsite_checkout_count        => $onsite_checkout_count,
513
            onsite_checkout              => $onsite_checkout,
506
            onsite_checkout              => $onsite_checkout,
514
            max_checkouts_allowed        => $maxissueqty_rule ? $maxissueqty_rule->rule_value : undef,
507
            max_checkouts_allowed        => $maxissueqty_rule ? $maxissueqty_rule->rule_value : undef,
515
            max_onsite_checkouts_allowed => $maxonsiteissueqty_rule ? $maxonsiteissueqty_rule->rule_value : undef,
516
            switch_onsite_checkout       => $switch_onsite_checkout,
508
            switch_onsite_checkout       => $switch_onsite_checkout,
517
        };
509
        };
518
        # If parent rules exists
510
        # If parent rules exists
Lines 535-541 sub TooMany { Link Here
535
    }
527
    }
536
528
537
    # Now count total loans against the limit for the branch
529
    # Now count total loans against the limit for the branch
538
    my $branch_borrower_circ_rule = GetBranchBorrowerCircRule($branch, $cat_borrower);
530
    my $branch_borrower_circ_rule = GetBranchBorrowerCircRule($branch, $cat_borrower, $onsite_checkout );
539
    if (defined($branch_borrower_circ_rule->{patron_maxissueqty}) and $branch_borrower_circ_rule->{patron_maxissueqty} ne '') {
531
    if (defined($branch_borrower_circ_rule->{patron_maxissueqty}) and $branch_borrower_circ_rule->{patron_maxissueqty} ne '') {
540
        my $checkouts;
532
        my $checkouts;
541
        if ( C4::Context->preference('CircControl') eq 'PickupLibrary' ) {
533
        if ( C4::Context->preference('CircControl') eq 'PickupLibrary' ) {
Lines 551-557 sub TooMany { Link Here
551
        my $checkout_count = $checkouts->count;
543
        my $checkout_count = $checkouts->count;
552
        my $onsite_checkout_count = $checkouts->search({ onsite_checkout => 1 })->count;
544
        my $onsite_checkout_count = $checkouts->search({ onsite_checkout => 1 })->count;
553
        my $max_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxissueqty};
545
        my $max_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxissueqty};
554
        my $max_onsite_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxonsiteissueqty} || undef;
555
546
556
        my $qty_over = _check_max_qty(
547
        my $qty_over = _check_max_qty(
557
            {
548
            {
Lines 559-565 sub TooMany { Link Here
559
                onsite_checkout_count        => $onsite_checkout_count,
550
                onsite_checkout_count        => $onsite_checkout_count,
560
                onsite_checkout              => $onsite_checkout,
551
                onsite_checkout              => $onsite_checkout,
561
                max_checkouts_allowed        => $max_checkouts_allowed,
552
                max_checkouts_allowed        => $max_checkouts_allowed,
562
                max_onsite_checkouts_allowed => $max_onsite_checkouts_allowed,
563
                switch_onsite_checkout       => $switch_onsite_checkout
553
                switch_onsite_checkout       => $switch_onsite_checkout
564
            }
554
            }
565
        );
555
        );
Lines 580-595 sub _check_max_qty { Link Here
580
    my $onsite_checkout_count        = $params->{onsite_checkout_count};
570
    my $onsite_checkout_count        = $params->{onsite_checkout_count};
581
    my $onsite_checkout              = $params->{onsite_checkout};
571
    my $onsite_checkout              = $params->{onsite_checkout};
582
    my $max_checkouts_allowed        = $params->{max_checkouts_allowed};
572
    my $max_checkouts_allowed        = $params->{max_checkouts_allowed};
583
    my $max_onsite_checkouts_allowed = $params->{max_onsite_checkouts_allowed};
584
    my $switch_onsite_checkout       = $params->{switch_onsite_checkout};
573
    my $switch_onsite_checkout       = $params->{switch_onsite_checkout};
585
574
586
    if ( $onsite_checkout and defined $max_onsite_checkouts_allowed ) {
575
    if ( $onsite_checkout and defined $max_checkouts_allowed ) {
587
        if ( $max_onsite_checkouts_allowed eq '' ) { return; }
576
        if ( $max_checkouts_allowed eq '' ) { return; }
588
        if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed ) {
577
        if ( $onsite_checkout_count >= $max_checkouts_allowed ) {
589
            return {
578
            return {
590
                reason      => 'TOO_MANY_ONSITE_CHECKOUTS',
579
                reason      => 'TOO_MANY_ONSITE_CHECKOUTS',
591
                count       => $onsite_checkout_count,
580
                count       => $onsite_checkout_count,
592
                max_allowed => $max_onsite_checkouts_allowed,
581
                max_allowed => $max_checkouts_allowed,
593
            };
582
            };
594
        }
583
        }
595
    }
584
    }
Lines 1679-1709 sub GetHardDueDate { Link Here
1679
1668
1680
=head2 GetBranchBorrowerCircRule
1669
=head2 GetBranchBorrowerCircRule
1681
1670
1682
  my $branch_cat_rule = GetBranchBorrowerCircRule($branchcode, $categorycode);
1671
  my $branch_cat_rule = GetBranchBorrowerCircRule($branchcode, $categorycode, $onsite_checkout);
1683
1672
1684
Retrieves circulation rule attributes that apply to the given
1673
Retrieves circulation rule attributes that apply to the given
1685
branch and patron category, regardless of item type.  
1674
branch, patron category and checkout type, regardless of item type.
1686
The return value is a hashref containing the following key:
1675
The return value is a hashref containing the following key:
1687
1676
1688
patron_maxissueqty - maximum number of loans that a
1677
patron_maxissueqty - maximum number of loans that a
1689
patron of the given category can have at the given
1678
patron of the given category can have at the given
1690
branch.  If the value is undef, no limit.
1679
branch.  If the value is undef, no limit.
1691
1680
1692
patron_maxonsiteissueqty - maximum of on-site checkouts that a
1681
The order in which rules are searched is defined in
1693
patron of the given category can have at the given
1682
C<Koha::CirculationRules->get_effective_rule()>
1694
branch.  If the value is undef, no limit.
1695
1696
This will check for different branch/category combinations in the following order:
1697
branch and category
1698
branch only
1699
category only
1700
default branch and category
1701
1683
1702
If no rule has been found in the database, it will default to
1684
If no rule has been found in the database, it will default to
1703
the buillt in rule:
1685
the buillt in rule:
1704
1686
1705
patron_maxissueqty - undef
1687
patron_maxissueqty - undef
1706
patron_maxonsiteissueqty - undef
1707
1688
1708
C<$branchcode> and C<$categorycode> should contain the
1689
C<$branchcode> and C<$categorycode> should contain the
1709
literal branch code and patron category code, respectively - no
1690
literal branch code and patron category code, respectively - no
Lines 1712-1732 wildcards. Link Here
1712
=cut
1693
=cut
1713
1694
1714
sub GetBranchBorrowerCircRule {
1695
sub GetBranchBorrowerCircRule {
1715
    my ( $branchcode, $categorycode ) = @_;
1696
    my ( $branchcode, $categorycode, $onsite_checkout ) = @_;
1716
1697
1717
    # Initialize default values
1698
    # Initialize default values
1718
    my $rules = {
1699
    my $rules = {
1719
        patron_maxissueqty       => undef,
1700
        patron_maxissueqty       => undef,
1720
        patron_maxonsiteissueqty => undef,
1721
    };
1701
    };
1722
1702
1723
    # Search for rules!
1703
    # Search for rules!
1724
    foreach my $rule_name (qw( patron_maxissueqty patron_maxonsiteissueqty )) {
1704
    foreach my $rule_name (qw( patron_maxissueqty )) {
1725
        my $rule = Koha::CirculationRules->get_effective_rule(
1705
        my $rule = Koha::CirculationRules->get_effective_rule(
1726
            {
1706
            {
1727
                categorycode => $categorycode,
1707
                categorycode => $categorycode,
1728
                itemtype     => undef,
1708
                itemtype     => undef,
1729
                branchcode   => $branchcode,
1709
                branchcode   => $branchcode,
1710
                onsite_checkout => $onsite_checkout,
1730
                rule_name    => $rule_name,
1711
                rule_name    => $rule_name,
1731
            }
1712
            }
1732
        );
1713
        );
(-)a/Koha/CirculationRules.pm (-6 lines)
Lines 53-61 our $RULE_KINDS = { Link Here
53
    patron_maxissueqty => {
53
    patron_maxissueqty => {
54
        scope => [ 'branchcode', 'categorycode', 'onsite_checkout' ],
54
        scope => [ 'branchcode', 'categorycode', 'onsite_checkout' ],
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 121-129 our $RULE_KINDS = { Link Here
121
    maxissueqty => {
118
    maxissueqty => {
122
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
119
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
123
    },
120
    },
124
    maxonsiteissueqty => {
125
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
126
    },
127
    maxsuspensiondays => {
121
    maxsuspensiondays => {
128
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
122
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
129
    },
123
    },
(-)a/installer/data/mysql/atomicupdate/bug_26814_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 onsite_checkout = ?,
8
            rule_name = ?
9
        WHERE rule_name=?
10
    |);
11
    $update_sth->execute(
12
        1,
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 onsite_checkout = ?,
21
            rule_name = ?
22
        WHERE rule_name=?
23
    |);
24
    $update_sth->execute(
25
        1,
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 26814 - Convert maxonsiteissueqty to maxissueqty )\n";
33
}
(-)a/installer/onboarding.pl (-1 lines)
Lines 277-283 if ( $step == 5 ) { Link Here
277
                holds_per_day                    => $holds_per_day,
277
                holds_per_day                    => $holds_per_day,
278
                holds_per_record                 => $holds_per_record,
278
                holds_per_record                 => $holds_per_record,
279
                maxissueqty                      => $maxissueqty,
279
                maxissueqty                      => $maxissueqty,
280
                maxonsiteissueqty                => "",
281
                maxsuspensiondays                => "",
280
                maxsuspensiondays                => "",
282
                no_auto_renewal_after            => "",
281
                no_auto_renewal_after            => "",
283
                no_auto_renewal_after_hard_limit => "",
282
                no_auto_renewal_after_hard_limit => "",
(-)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 => 15;
28
use Test::More tests => 16;
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
        onsite_checkout => 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
        onsite_checkout => 1,
166
        rules        => {
167
            patron_maxissueqty       => 6,
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
        onsite_checkout => 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
        onsite_checkout => 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
        1,
269
    ),
270
    { patron_maxissueqty => 6 },
271
     "GetBranchBorrower returns the patron_maxissueqty of the branch1 and the category1 and onsite_checkout 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 69-77 Koha::CirculationRules->set_rules( Link Here
69
        branchcode   => $branch->{branchcode},
69
        branchcode   => $branch->{branchcode},
70
        categorycode => undef,
70
        categorycode => undef,
71
        itemtype     => undef,
71
        itemtype     => undef,
72
        onsite_checkout => undef,
72
        rules        => {
73
        rules        => {
73
            maxissueqty       => 2,
74
            maxissueqty       => 2,
74
            maxonsiteissueqty => 1,
75
            lengthunit        => 'days',
75
            lengthunit        => 'days',
76
            issuelength       => 5,
76
            issuelength       => 5,
77
            hardduedate        => undef,
77
            hardduedate        => undef,
Lines 79-84 Koha::CirculationRules->set_rules( Link Here
79
        }
79
        }
80
    }
80
    }
81
);
81
);
82
Koha::CirculationRules->set_rules(
83
    {
84
        branchcode   => $branch->{branchcode},
85
        categorycode => undef,
86
        itemtype     => undef,
87
        onsite_checkout => 1,
88
        rules        => {
89
            maxissueqty       => 1,
90
        }
91
    }
92
);
82
93
83
t::lib::Mocks::mock_userenv({ patron => $patron });
94
t::lib::Mocks::mock_userenv({ patron => $patron });
84
95
Lines 132-140 Koha::CirculationRules->set_rules( Link Here
132
        branchcode   => $branch->{branchcode},
143
        branchcode   => $branch->{branchcode},
133
        categorycode => undef,
144
        categorycode => undef,
134
        itemtype     => undef,
145
        itemtype     => undef,
146
        onsite_checkout => undef,
147
        rules        => {
148
            maxissueqty       => 2,
149
        }
150
    }
151
);
152
Koha::CirculationRules->set_rules(
153
    {
154
        branchcode   => $branch->{branchcode},
155
        categorycode => undef,
156
        itemtype     => undef,
157
        onsite_checkout => 1,
135
        rules        => {
158
        rules        => {
136
            maxissueqty       => 2,
159
            maxissueqty       => 2,
137
            maxonsiteissueqty => 1,
138
        }
160
        }
139
    }
161
    }
140
);
162
);
(-)a/t/db_dependent/Circulation/TooMany.t (-15 / +30 lines)
Lines 99-107 subtest '1 Issuingrule exist 0 0: no issue allowed' => sub { Link Here
99
            branchcode   => $branch->{branchcode},
99
            branchcode   => $branch->{branchcode},
100
            categorycode => $category->{categorycode},
100
            categorycode => $category->{categorycode},
101
            itemtype     => undef,
101
            itemtype     => undef,
102
            onsite_checkout => undef,
102
            rules        => {
103
            rules        => {
103
                maxissueqty       => 0,
104
                maxissueqty       => 0,
104
                maxonsiteissueqty => 0,
105
            }
105
            }
106
        },
106
        },
107
    );
107
    );
Lines 156-164 subtest '1 Issuingrule exist with onsiteissueqty=unlimited' => sub { Link Here
156
            branchcode   => $branch->{branchcode},
156
            branchcode   => $branch->{branchcode},
157
            categorycode => $category->{categorycode},
157
            categorycode => $category->{categorycode},
158
            itemtype     => undef,
158
            itemtype     => undef,
159
            onsite_checkout => undef,
159
            rules        => {
160
            rules        => {
160
                maxissueqty       => 1,
161
                maxissueqty       => 1,
161
                maxonsiteissueqty => undef,
162
            }
163
        },
164
    );
165
    Koha::CirculationRules->set_rules(
166
        {
167
            branchcode   => $branch->{branchcode},
168
            categorycode => $category->{categorycode},
169
            itemtype     => undef,
170
            onsite_checkout => 1,
171
            rules        => {
172
                maxissueqty       => undef,
162
            }
173
            }
163
        },
174
        },
164
    );
175
    );
Lines 211-219 subtest '1 Issuingrule exist 1 1: issue is allowed' => sub { Link Here
211
            branchcode   => $branch->{branchcode},
222
            branchcode   => $branch->{branchcode},
212
            categorycode => $category->{categorycode},
223
            categorycode => $category->{categorycode},
213
            itemtype     => undef,
224
            itemtype     => undef,
225
            onsite_checkout => undef,
214
            rules        => {
226
            rules        => {
215
                maxissueqty       => 1,
227
                maxissueqty       => 1,
216
                maxonsiteissueqty => 1,
217
            }
228
            }
218
        }
229
        }
219
    );
230
    );
Lines 251-259 subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed. Do a CO' => sub { Link Here
251
            branchcode   => $branch->{branchcode},
262
            branchcode   => $branch->{branchcode},
252
            categorycode => $category->{categorycode},
263
            categorycode => $category->{categorycode},
253
            itemtype     => undef,
264
            itemtype     => undef,
265
            onsite_checkout => undef,
254
            rules        => {
266
            rules        => {
255
                maxissueqty       => 1,
267
                maxissueqty       => 1,
256
                maxonsiteissueqty => 1,
257
            }
268
            }
258
        }
269
        }
259
    );
270
    );
Lines 307-315 subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed, Do a OSCO' => sub { Link Here
307
            branchcode   => $branch->{branchcode},
318
            branchcode   => $branch->{branchcode},
308
            categorycode => $category->{categorycode},
319
            categorycode => $category->{categorycode},
309
            itemtype     => undef,
320
            itemtype     => undef,
321
            onsite_checkout => undef,
310
            rules        => {
322
            rules        => {
311
                maxissueqty       => 1,
323
                maxissueqty       => 1,
312
                maxonsiteissueqty => 1,
313
            }
324
            }
314
        }
325
        }
315
    );
326
    );
Lines 366-374 subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub { Link Here
366
            branchcode   => $branch->{branchcode},
377
            branchcode   => $branch->{branchcode},
367
            categorycode => $category->{categorycode},
378
            categorycode => $category->{categorycode},
368
            itemtype     => undef,
379
            itemtype     => undef,
380
            onsite_checkout => undef,
369
            rules        => {
381
            rules        => {
370
                maxissueqty       => 1,
382
                maxissueqty       => 1,
371
                maxonsiteissueqty => 1,
372
            }
383
            }
373
        }
384
        }
374
    );
385
    );
Lines 418-426 subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub { Link Here
418
            branchcode   => $branch->{branchcode},
429
            branchcode   => $branch->{branchcode},
419
            categorycode => $category->{categorycode},
430
            categorycode => $category->{categorycode},
420
            itemtype     => undef,
431
            itemtype     => undef,
432
            onsite_checkout => undef,
421
            rules        => {
433
            rules        => {
422
                maxissueqty       => 1,
434
                maxissueqty       => 1,
423
                maxonsiteissueqty => 1,
424
            }
435
            }
425
        }
436
        }
426
    );
437
    );
Lines 496-501 subtest 'General vs specific rules limit quantity correctly' => sub { Link Here
496
            categorycode => '*',
507
            categorycode => '*',
497
            itemtype     => $itemtype->{itemtype},
508
            itemtype     => $itemtype->{itemtype},
498
            branchcode   => '*',
509
            branchcode   => '*',
510
            onsite_checkout => '*',
499
            rules        => {
511
            rules        => {
500
                issuelength => 1,
512
                issuelength => 1,
501
                firstremind => 1,        # 1 day of grace
513
                firstremind => 1,        # 1 day of grace
Lines 511-519 subtest 'General vs specific rules limit quantity correctly' => sub { Link Here
511
            branchcode   => '*',
523
            branchcode   => '*',
512
            categorycode => '*',
524
            categorycode => '*',
513
            itemtype     => $itemtype->{itemtype},
525
            itemtype     => $itemtype->{itemtype},
526
            onsite_checkout => '*',
514
            rules        => {
527
            rules        => {
515
                maxissueqty       => 1,
528
                maxissueqty       => 1,
516
                maxonsiteissueqty => 1,
517
            }
529
            }
518
        }
530
        }
519
    );
531
    );
Lines 564-572 subtest 'General vs specific rules limit quantity correctly' => sub { Link Here
564
            branchcode   => $branch->{branchcode},
576
            branchcode   => $branch->{branchcode},
565
            categorycode => $category->{categorycode},
577
            categorycode => $category->{categorycode},
566
            itemtype     => $itemtype->{itemtype},
578
            itemtype     => $itemtype->{itemtype},
579
            onsite_checkout => undef,
567
            rules        => {
580
            rules        => {
568
                maxissueqty       => 1,
581
                maxissueqty       => 1,
569
                maxonsiteissueqty => 1,
570
            }
582
            }
571
        }
583
        }
572
    );
584
    );
Lines 660-668 subtest 'General vs specific rules limit quantity correctly' => sub { Link Here
660
            branchcode   => $branch2->{branchcode},
672
            branchcode   => $branch2->{branchcode},
661
            categorycode => $category->{categorycode},
673
            categorycode => $category->{categorycode},
662
            itemtype     => $itemtype->{itemtype},
674
            itemtype     => $itemtype->{itemtype},
675
            onsite_checkout => undef,
663
            rules        => {
676
            rules        => {
664
                maxissueqty       => 1,
677
                maxissueqty       => 1,
665
                maxonsiteissueqty => 1,
666
            }
678
            }
667
        }
679
        }
668
    );
680
    );
Lines 682-703 subtest 'empty string means unlimited' => sub { Link Here
682
            branchcode   => '*',
694
            branchcode   => '*',
683
            categorycode => '*',
695
            categorycode => '*',
684
            itemtype     => '*',
696
            itemtype     => '*',
697
            onsite_checkout => '*',
685
            rules        => {
698
            rules        => {
686
                maxissueqty       => '',
699
                maxissueqty       => '',
687
                maxonsiteissueqty => '',
688
            }
700
            }
689
        },
701
        },
690
    );
702
    );
691
    is(
703
    is(
692
        C4::Circulation::TooMany( $patron, $item ),
704
        C4::Circulation::TooMany( $patron, $item ),
693
        undef,
705
        undef,
694
        'maxissueqty="" should mean unlimited'
706
        'maxissueqty="" should mean unlimited for normal checkouts'
695
    );
707
    );
696
708
697
    is(
709
    is(
698
        C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ),
710
        C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ),
699
        undef,
711
        undef,
700
        'maxonsiteissueqty="" should mean unlimited'
712
        'maxissueqty="" should mean unlimited for onsite checkouts'
701
      );
713
      );
702
};
714
};
703
715
Lines 710-718 subtest 'itemtype group tests' => sub { Link Here
710
            branchcode   => '*',
722
            branchcode   => '*',
711
            categorycode => '*',
723
            categorycode => '*',
712
            itemtype     => '*',
724
            itemtype     => '*',
725
            onsite_checkout => '*',
713
            rules        => {
726
            rules        => {
714
                maxissueqty       => '',
727
                maxissueqty       => '',
715
                maxonsiteissueqty => '',
716
                issuelength       => 1,
728
                issuelength       => 1,
717
                firstremind       => 1,      # 1 day of grace
729
                firstremind       => 1,      # 1 day of grace
718
                finedays          => 2,      # 2 days of fine per day of overdue
730
                finedays          => 2,      # 2 days of fine per day of overdue
Lines 784-789 subtest 'itemtype group tests' => sub { Link Here
784
                branchcode   => $branch->{branchcode},
796
                branchcode   => $branch->{branchcode},
785
                categorycode => $category->{categorycode},
797
                categorycode => $category->{categorycode},
786
                itemtype     => undef,
798
                itemtype     => undef,
799
                onsite_checkout => undef,
787
                rule_name    => 'maxissueqty',
800
                rule_name    => 'maxissueqty',
788
                rule_value   => 1
801
                rule_value   => 1
789
            }
802
            }
Lines 806-811 subtest 'itemtype group tests' => sub { Link Here
806
                branchcode   => $branch->{branchcode},
819
                branchcode   => $branch->{branchcode},
807
                categorycode => $category->{categorycode},
820
                categorycode => $category->{categorycode},
808
                itemtype     => $parent_itype->{itemtype},
821
                itemtype     => $parent_itype->{itemtype},
822
                onsite_checkout => undef,
809
                rule_name    => 'maxissueqty',
823
                rule_name    => 'maxissueqty',
810
                rule_value   => 2
824
                rule_value   => 2
811
            }
825
            }
Lines 822-827 subtest 'itemtype group tests' => sub { Link Here
822
                branchcode   => $branch->{branchcode},
836
                branchcode   => $branch->{branchcode},
823
                categorycode => $category->{categorycode},
837
                categorycode => $category->{categorycode},
824
                itemtype     => $child_itype_1->{itemtype},
838
                itemtype     => $child_itype_1->{itemtype},
839
                onsite_checkout => undef,
825
                rule_name    => 'maxissueqty',
840
                rule_name    => 'maxissueqty',
826
                rule_value   => 1
841
                rule_value   => 1
827
            }
842
            }
Lines 853-858 subtest 'itemtype group tests' => sub { Link Here
853
                branchcode   => $branch->{branchcode},
868
                branchcode   => $branch->{branchcode},
854
                categorycode => $category->{categorycode},
869
                categorycode => $category->{categorycode},
855
                itemtype     => $child_itype_2->{itemtype},
870
                itemtype     => $child_itype_2->{itemtype},
871
                onsite_checkout => undef,
856
                rule_name    => 'maxissueqty',
872
                rule_name    => 'maxissueqty',
857
                rule_value   => 3
873
                rule_value   => 3
858
            }
874
            }
859
- 

Return to bug 26814