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

(-)a/C4/Circulation.pm (-34 / +15 lines)
Lines 418-423 sub TooMany { Link Here
418
            categorycode => $cat_borrower,
418
            categorycode => $cat_borrower,
419
            itemtype     => $parent_type,
419
            itemtype     => $parent_type,
420
            branchcode   => $branch,
420
            branchcode   => $branch,
421
            onsite_checkout => $onsite_checkout,
421
            rule_name    => 'maxissueqty',
422
            rule_name    => 'maxissueqty',
422
        }
423
        }
423
    ) if $parent_type;
424
    ) if $parent_type;
Lines 429-448 sub TooMany { Link Here
429
            categorycode => $cat_borrower,
430
            categorycode => $cat_borrower,
430
            itemtype     => $type,
431
            itemtype     => $type,
431
            branchcode   => $branch,
432
            branchcode   => $branch,
433
            onsite_checkout => $onsite_checkout,
432
            rule_name    => 'maxissueqty',
434
            rule_name    => 'maxissueqty',
433
        }
435
        }
434
    );
436
    );
435
437
436
    my $maxonsiteissueqty_rule = Koha::CirculationRules->get_effective_rule(
437
        {
438
            categorycode => $cat_borrower,
439
            itemtype     => $type,
440
            branchcode   => $branch,
441
            rule_name    => 'maxonsiteissueqty',
442
        }
443
    );
444
445
446
    my $patron = Koha::Patrons->find($borrower->{borrowernumber});
438
    my $patron = Koha::Patrons->find($borrower->{borrowernumber});
447
    # if a rule is found and has a loan limit set, count
439
    # if a rule is found and has a loan limit set, count
448
    # how many loans the patron already has that meet that
440
    # how many loans the patron already has that meet that
Lines 478-483 sub TooMany { Link Here
478
                        branchcode => $maxissueqty_rule->branchcode,
470
                        branchcode => $maxissueqty_rule->branchcode,
479
                        categorycode => [ $maxissueqty_rule->categorycode, $cat_borrower ],
471
                        categorycode => [ $maxissueqty_rule->categorycode, $cat_borrower ],
480
                        itemtype  => { '!=' => undef },
472
                        itemtype  => { '!=' => undef },
473
                        onsite_checkout => $onsite_checkout,
481
                        rule_name => 'maxissueqty'
474
                        rule_name => 'maxissueqty'
482
                    }
475
                    }
483
                )->get_column('itemtype');
476
                )->get_column('itemtype');
Lines 513-519 sub TooMany { Link Here
513
            onsite_checkout_count        => $onsite_checkout_count,
506
            onsite_checkout_count        => $onsite_checkout_count,
514
            onsite_checkout              => $onsite_checkout,
507
            onsite_checkout              => $onsite_checkout,
515
            max_checkouts_allowed        => $maxissueqty_rule ? $maxissueqty_rule->rule_value : undef,
508
            max_checkouts_allowed        => $maxissueqty_rule ? $maxissueqty_rule->rule_value : undef,
516
            max_onsite_checkouts_allowed => $maxonsiteissueqty_rule ? $maxonsiteissueqty_rule->rule_value : undef,
517
            switch_onsite_checkout       => $switch_onsite_checkout,
509
            switch_onsite_checkout       => $switch_onsite_checkout,
518
        };
510
        };
519
        # If parent rules exists
511
        # If parent rules exists
Lines 536-542 sub TooMany { Link Here
536
    }
528
    }
537
529
538
    # Now count total loans against the limit for the branch
530
    # Now count total loans against the limit for the branch
539
    my $branch_borrower_circ_rule = GetBranchBorrowerCircRule($branch, $cat_borrower);
531
    my $branch_borrower_circ_rule = GetBranchBorrowerCircRule($branch, $cat_borrower, $onsite_checkout );
540
    if (defined($branch_borrower_circ_rule->{patron_maxissueqty}) and $branch_borrower_circ_rule->{patron_maxissueqty} ne '') {
532
    if (defined($branch_borrower_circ_rule->{patron_maxissueqty}) and $branch_borrower_circ_rule->{patron_maxissueqty} ne '') {
541
        my $checkouts;
533
        my $checkouts;
542
        if ( C4::Context->preference('CircControl') eq 'PickupLibrary' ) {
534
        if ( C4::Context->preference('CircControl') eq 'PickupLibrary' ) {
Lines 553-559 sub TooMany { Link Here
553
        my $checkout_count = $checkouts->count;
545
        my $checkout_count = $checkouts->count;
554
        my $onsite_checkout_count = $checkouts->search({ onsite_checkout => 1 })->count;
546
        my $onsite_checkout_count = $checkouts->search({ onsite_checkout => 1 })->count;
555
        my $max_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxissueqty};
547
        my $max_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxissueqty};
556
        my $max_onsite_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxonsiteissueqty} || undef;
557
548
558
        my $qty_over = _check_max_qty(
549
        my $qty_over = _check_max_qty(
559
            {
550
            {
Lines 561-567 sub TooMany { Link Here
561
                onsite_checkout_count        => $onsite_checkout_count,
552
                onsite_checkout_count        => $onsite_checkout_count,
562
                onsite_checkout              => $onsite_checkout,
553
                onsite_checkout              => $onsite_checkout,
563
                max_checkouts_allowed        => $max_checkouts_allowed,
554
                max_checkouts_allowed        => $max_checkouts_allowed,
564
                max_onsite_checkouts_allowed => $max_onsite_checkouts_allowed,
565
                switch_onsite_checkout       => $switch_onsite_checkout
555
                switch_onsite_checkout       => $switch_onsite_checkout
566
            }
556
            }
567
        );
557
        );
Lines 582-597 sub _check_max_qty { Link Here
582
    my $onsite_checkout_count        = $params->{onsite_checkout_count};
572
    my $onsite_checkout_count        = $params->{onsite_checkout_count};
583
    my $onsite_checkout              = $params->{onsite_checkout};
573
    my $onsite_checkout              = $params->{onsite_checkout};
584
    my $max_checkouts_allowed        = $params->{max_checkouts_allowed};
574
    my $max_checkouts_allowed        = $params->{max_checkouts_allowed};
585
    my $max_onsite_checkouts_allowed = $params->{max_onsite_checkouts_allowed};
586
    my $switch_onsite_checkout       = $params->{switch_onsite_checkout};
575
    my $switch_onsite_checkout       = $params->{switch_onsite_checkout};
587
576
588
    if ( $onsite_checkout and defined $max_onsite_checkouts_allowed ) {
577
    if ( $onsite_checkout and defined $max_checkouts_allowed ) {
589
        if ( $max_onsite_checkouts_allowed eq '' ) { return; }
578
        if ( $max_checkouts_allowed eq '' ) { return; }
590
        if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed ) {
579
        if ( $onsite_checkout_count >= $max_checkouts_allowed ) {
591
            return {
580
            return {
592
                reason      => 'TOO_MANY_ONSITE_CHECKOUTS',
581
                reason      => 'TOO_MANY_ONSITE_CHECKOUTS',
593
                count       => $onsite_checkout_count,
582
                count       => $onsite_checkout_count,
594
                max_allowed => $max_onsite_checkouts_allowed,
583
                max_allowed => $max_checkouts_allowed,
595
            };
584
            };
596
        }
585
        }
597
    }
586
    }
Lines 1731-1761 sub GetHardDueDate { Link Here
1731
1720
1732
=head2 GetBranchBorrowerCircRule
1721
=head2 GetBranchBorrowerCircRule
1733
1722
1734
  my $branch_cat_rule = GetBranchBorrowerCircRule($branchcode, $categorycode);
1723
  my $branch_cat_rule = GetBranchBorrowerCircRule($branchcode, $categorycode, $onsite_checkout);
1735
1724
1736
Retrieves circulation rule attributes that apply to the given
1725
Retrieves circulation rule attributes that apply to the given
1737
branch and patron category, regardless of item type.  
1726
branch, patron category and checkout type, regardless of item type.
1738
The return value is a hashref containing the following key:
1727
The return value is a hashref containing the following key:
1739
1728
1740
patron_maxissueqty - maximum number of loans that a
1729
patron_maxissueqty - maximum number of loans that a
1741
patron of the given category can have at the given
1730
patron of the given category can have at the given
1742
branch.  If the value is undef, no limit.
1731
branch.  If the value is undef, no limit.
1743
1732
1744
patron_maxonsiteissueqty - maximum of on-site checkouts that a
1733
The order in which rules are searched is defined in
1745
patron of the given category can have at the given
1734
C<Koha::CirculationRules->get_effective_rule()>
1746
branch.  If the value is undef, no limit.
1747
1748
This will check for different branch/category combinations in the following order:
1749
branch and category
1750
branch only
1751
category only
1752
default branch and category
1753
1735
1754
If no rule has been found in the database, it will default to
1736
If no rule has been found in the database, it will default to
1755
the buillt in rule:
1737
the buillt in rule:
1756
1738
1757
patron_maxissueqty - undef
1739
patron_maxissueqty - undef
1758
patron_maxonsiteissueqty - undef
1759
1740
1760
C<$branchcode> and C<$categorycode> should contain the
1741
C<$branchcode> and C<$categorycode> should contain the
1761
literal branch code and patron category code, respectively - no
1742
literal branch code and patron category code, respectively - no
Lines 1764-1784 wildcards. Link Here
1764
=cut
1745
=cut
1765
1746
1766
sub GetBranchBorrowerCircRule {
1747
sub GetBranchBorrowerCircRule {
1767
    my ( $branchcode, $categorycode ) = @_;
1748
    my ( $branchcode, $categorycode, $onsite_checkout ) = @_;
1768
1749
1769
    # Initialize default values
1750
    # Initialize default values
1770
    my $rules = {
1751
    my $rules = {
1771
        patron_maxissueqty       => undef,
1752
        patron_maxissueqty       => undef,
1772
        patron_maxonsiteissueqty => undef,
1773
    };
1753
    };
1774
1754
1775
    # Search for rules!
1755
    # Search for rules!
1776
    foreach my $rule_name (qw( patron_maxissueqty patron_maxonsiteissueqty )) {
1756
    foreach my $rule_name (qw( patron_maxissueqty )) {
1777
        my $rule = Koha::CirculationRules->get_effective_rule(
1757
        my $rule = Koha::CirculationRules->get_effective_rule(
1778
            {
1758
            {
1779
                categorycode => $categorycode,
1759
                categorycode => $categorycode,
1780
                itemtype     => undef,
1760
                itemtype     => undef,
1781
                branchcode   => $branchcode,
1761
                branchcode   => $branchcode,
1762
                onsite_checkout => $onsite_checkout,
1782
                rule_name    => $rule_name,
1763
                rule_name    => $rule_name,
1783
            }
1764
            }
1784
        );
1765
        );
(-)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 (-16 / +31 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 510-518 subtest 'General vs specific rules limit quantity correctly' => sub { Link Here
510
        {
522
        {
511
            branchcode   => $branch->{branchcode},
523
            branchcode   => $branch->{branchcode},
512
            categorycode => '*',
524
            categorycode => '*',
525
            onsite_checkout => undef,
513
            rules        => {
526
            rules        => {
514
                patron_maxissueqty       => 1,
527
                patron_maxissueqty       => 1,
515
                patron_maxonsiteissueqty => 1,
516
            }
528
            }
517
        }
529
        }
518
    );
530
    );
Lines 523-531 subtest 'General vs specific rules limit quantity correctly' => sub { Link Here
523
            branchcode   => '*',
535
            branchcode   => '*',
524
            categorycode => '*',
536
            categorycode => '*',
525
            itemtype     => $itemtype->{itemtype},
537
            itemtype     => $itemtype->{itemtype},
538
            onsite_checkout => '*',
526
            rules        => {
539
            rules        => {
527
                maxissueqty       => 1,
540
                maxissueqty       => 1,
528
                maxonsiteissueqty => 1,
529
            }
541
            }
530
        }
542
        }
531
    );
543
    );
Lines 576-584 subtest 'General vs specific rules limit quantity correctly' => sub { Link Here
576
            branchcode   => $branch->{branchcode},
588
            branchcode   => $branch->{branchcode},
577
            categorycode => $category->{categorycode},
589
            categorycode => $category->{categorycode},
578
            itemtype     => $itemtype->{itemtype},
590
            itemtype     => $itemtype->{itemtype},
591
            onsite_checkout => undef,
579
            rules        => {
592
            rules        => {
580
                maxissueqty       => 1,
593
                maxissueqty       => 1,
581
                maxonsiteissueqty => 1,
582
            }
594
            }
583
        }
595
        }
584
    );
596
    );
Lines 672-680 subtest 'General vs specific rules limit quantity correctly' => sub { Link Here
672
            branchcode   => $branch2->{branchcode},
684
            branchcode   => $branch2->{branchcode},
673
            categorycode => $category->{categorycode},
685
            categorycode => $category->{categorycode},
674
            itemtype     => $itemtype->{itemtype},
686
            itemtype     => $itemtype->{itemtype},
687
            onsite_checkout => undef,
675
            rules        => {
688
            rules        => {
676
                maxissueqty       => 1,
689
                maxissueqty       => 1,
677
                maxonsiteissueqty => 1,
678
            }
690
            }
679
        }
691
        }
680
    );
692
    );
Lines 694-715 subtest 'empty string means unlimited' => sub { Link Here
694
            branchcode   => '*',
706
            branchcode   => '*',
695
            categorycode => '*',
707
            categorycode => '*',
696
            itemtype     => '*',
708
            itemtype     => '*',
709
            onsite_checkout => '*',
697
            rules        => {
710
            rules        => {
698
                maxissueqty       => '',
711
                maxissueqty       => '',
699
                maxonsiteissueqty => '',
700
            }
712
            }
701
        },
713
        },
702
    );
714
    );
703
    is(
715
    is(
704
        C4::Circulation::TooMany( $patron, $item ),
716
        C4::Circulation::TooMany( $patron, $item ),
705
        undef,
717
        undef,
706
        'maxissueqty="" should mean unlimited'
718
        'maxissueqty="" should mean unlimited for normal checkouts'
707
    );
719
    );
708
720
709
    is(
721
    is(
710
        C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ),
722
        C4::Circulation::TooMany( $patron, $item, { onsite_checkout => 1 } ),
711
        undef,
723
        undef,
712
        'maxonsiteissueqty="" should mean unlimited'
724
        'maxissueqty="" should mean unlimited for onsite checkouts'
713
      );
725
      );
714
};
726
};
715
727
Lines 722-730 subtest 'itemtype group tests' => sub { Link Here
722
            branchcode   => '*',
734
            branchcode   => '*',
723
            categorycode => '*',
735
            categorycode => '*',
724
            itemtype     => '*',
736
            itemtype     => '*',
737
            onsite_checkout => '*',
725
            rules        => {
738
            rules        => {
726
                maxissueqty       => '',
739
                maxissueqty       => '',
727
                maxonsiteissueqty => '',
728
                issuelength       => 1,
740
                issuelength       => 1,
729
                firstremind       => 1,      # 1 day of grace
741
                firstremind       => 1,      # 1 day of grace
730
                finedays          => 2,      # 2 days of fine per day of overdue
742
                finedays          => 2,      # 2 days of fine per day of overdue
Lines 796-801 subtest 'itemtype group tests' => sub { Link Here
796
                branchcode   => $branch->{branchcode},
808
                branchcode   => $branch->{branchcode},
797
                categorycode => $category->{categorycode},
809
                categorycode => $category->{categorycode},
798
                itemtype     => undef,
810
                itemtype     => undef,
811
                onsite_checkout => undef,
799
                rule_name    => 'maxissueqty',
812
                rule_name    => 'maxissueqty',
800
                rule_value   => 1
813
                rule_value   => 1
801
            }
814
            }
Lines 818-823 subtest 'itemtype group tests' => sub { Link Here
818
                branchcode   => $branch->{branchcode},
831
                branchcode   => $branch->{branchcode},
819
                categorycode => $category->{categorycode},
832
                categorycode => $category->{categorycode},
820
                itemtype     => $parent_itype->{itemtype},
833
                itemtype     => $parent_itype->{itemtype},
834
                onsite_checkout => undef,
821
                rule_name    => 'maxissueqty',
835
                rule_name    => 'maxissueqty',
822
                rule_value   => 2
836
                rule_value   => 2
823
            }
837
            }
Lines 834-839 subtest 'itemtype group tests' => sub { Link Here
834
                branchcode   => $branch->{branchcode},
848
                branchcode   => $branch->{branchcode},
835
                categorycode => $category->{categorycode},
849
                categorycode => $category->{categorycode},
836
                itemtype     => $child_itype_1->{itemtype},
850
                itemtype     => $child_itype_1->{itemtype},
851
                onsite_checkout => undef,
837
                rule_name    => 'maxissueqty',
852
                rule_name    => 'maxissueqty',
838
                rule_value   => 1
853
                rule_value   => 1
839
            }
854
            }
Lines 865-870 subtest 'itemtype group tests' => sub { Link Here
865
                branchcode   => $branch->{branchcode},
880
                branchcode   => $branch->{branchcode},
866
                categorycode => $category->{categorycode},
881
                categorycode => $category->{categorycode},
867
                itemtype     => $child_itype_2->{itemtype},
882
                itemtype     => $child_itype_2->{itemtype},
883
                onsite_checkout => undef,
868
                rule_name    => 'maxissueqty',
884
                rule_name    => 'maxissueqty',
869
                rule_value   => 3
885
                rule_value   => 3
870
            }
886
            }
871
- 

Return to bug 26814