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

(-)a/Koha/CirculationRules.pm (-28 / +39 lines)
Lines 51-57 our $RULE_KINDS = { Link Here
51
    },
51
    },
52
52
53
    patron_maxissueqty => {
53
    patron_maxissueqty => {
54
        scope => [ 'branchcode', 'categorycode' ],
54
        scope => [ 'branchcode', 'categorycode', 'onsite_checkout' ],
55
    },
55
    },
56
    patron_maxonsiteissueqty => {
56
    patron_maxonsiteissueqty => {
57
        scope => [ 'branchcode', 'categorycode' ],
57
        scope => [ 'branchcode', 'categorycode' ],
Lines 77-107 our $RULE_KINDS = { Link Here
77
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
77
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
78
    },
78
    },
79
    auto_renew => {
79
    auto_renew => {
80
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
80
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
81
    },
81
    },
82
    cap_fine_to_replacement_price => {
82
    cap_fine_to_replacement_price => {
83
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
83
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
84
    },
84
    },
85
    chargeperiod => {
85
    chargeperiod => {
86
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
86
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
87
    },
87
    },
88
    chargeperiod_charge_at => {
88
    chargeperiod_charge_at => {
89
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
89
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
90
    },
90
    },
91
    fine => {
91
    fine => {
92
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
92
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
93
    },
93
    },
94
    finedays => {
94
    finedays => {
95
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
95
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
96
    },
96
    },
97
    firstremind => {
97
    firstremind => {
98
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
98
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
99
    },
99
    },
100
    hardduedate => {
100
    hardduedate => {
101
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
101
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
102
    },
102
    },
103
    hardduedatecompare => {
103
    hardduedatecompare => {
104
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
104
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
105
    },
105
    },
106
    holds_per_day => {
106
    holds_per_day => {
107
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
107
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
Lines 110-140 our $RULE_KINDS = { Link Here
110
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
110
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
111
    },
111
    },
112
    issuelength => {
112
    issuelength => {
113
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
113
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
114
    },
114
    },
115
    daysmode => {
115
    daysmode => {
116
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
116
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
117
    },
117
    },
118
    lengthunit => {
118
    lengthunit => {
119
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
119
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
120
    },
120
    },
121
    maxissueqty => {
121
    maxissueqty => {
122
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
122
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
123
    },
123
    },
124
    maxonsiteissueqty => {
124
    maxonsiteissueqty => {
125
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
125
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
126
    },
126
    },
127
    maxsuspensiondays => {
127
    maxsuspensiondays => {
128
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
128
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
129
    },
129
    },
130
    no_auto_renewal_after => {
130
    no_auto_renewal_after => {
131
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
131
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
132
    },
132
    },
133
    no_auto_renewal_after_hard_limit => {
133
    no_auto_renewal_after_hard_limit => {
134
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
134
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
135
    },
135
    },
136
    norenewalbefore => {
136
    norenewalbefore => {
137
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
137
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
138
    },
138
    },
139
    onshelfholds => {
139
    onshelfholds => {
140
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
140
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
Lines 143-167 our $RULE_KINDS = { Link Here
143
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
143
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
144
    },
144
    },
145
    overduefinescap => {
145
    overduefinescap => {
146
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
146
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
147
    },
147
    },
148
    renewalperiod => {
148
    renewalperiod => {
149
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
149
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
150
    },
150
    },
151
    renewalsallowed => {
151
    renewalsallowed => {
152
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
152
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
153
    },
153
    },
154
    rentaldiscount => {
154
    rentaldiscount => {
155
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
155
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
156
    },
156
    },
157
    reservesallowed => {
157
    reservesallowed => {
158
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
158
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
159
    },
159
    },
160
    suspension_chargeperiod => {
160
    suspension_chargeperiod => {
161
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
161
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
162
    },
162
    },
163
    note => { # This is not really a rule. Maybe we will want to separate this later.
163
    note => { # This is not really a rule. Maybe we will want to separate this later.
164
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
164
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
165
    },
165
    },
166
    # Not included (deprecated?):
166
    # Not included (deprecated?):
167
    #   * accountsent
167
    #   * accountsent
Lines 188-204 sub get_effective_rule { Link Here
188
    my $categorycode = $params->{categorycode};
188
    my $categorycode = $params->{categorycode};
189
    my $itemtype     = $params->{itemtype};
189
    my $itemtype     = $params->{itemtype};
190
    my $branchcode   = $params->{branchcode};
190
    my $branchcode   = $params->{branchcode};
191
    my $onsite_checkout = $params->{onsite_checkout};
191
192
192
    Koha::Exceptions::MissingParameter->throw(
193
    Koha::Exceptions::MissingParameter->throw(
193
        "Required parameter 'rule_name' missing")
194
        "Required parameter 'rule_name' missing")
194
      unless $rule_name;
195
      unless $rule_name;
195
196
196
    for my $v ( $branchcode, $categorycode, $itemtype ) {
197
    for my $v ( $branchcode, $onsite_checkout, $categorycode, $itemtype ) {
197
        $v = undef if $v and $v eq '*';
198
        $v = undef if $v and $v eq '*';
198
    }
199
    }
199
200
200
    my $order_by = $params->{order_by}
201
    my $order_by = $params->{order_by}
201
      // { -desc => [ 'branchcode', 'categorycode', 'itemtype' ] };
202
      // { -desc => [ 'branchcode', 'onsite_checkout', 'categorycode', 'itemtype', ] };
202
203
203
    my $search_params;
204
    my $search_params;
204
    $search_params->{rule_name} = $rule_name;
205
    $search_params->{rule_name} = $rule_name;
Lines 206-211 sub get_effective_rule { Link Here
206
    $search_params->{categorycode} = defined $categorycode ? [ $categorycode, undef ] : undef;
207
    $search_params->{categorycode} = defined $categorycode ? [ $categorycode, undef ] : undef;
207
    $search_params->{itemtype}     = defined $itemtype     ? [ $itemtype, undef ] : undef;
208
    $search_params->{itemtype}     = defined $itemtype     ? [ $itemtype, undef ] : undef;
208
    $search_params->{branchcode}   = defined $branchcode   ? [ $branchcode,   undef ] : undef;
209
    $search_params->{branchcode}   = defined $branchcode   ? [ $branchcode,   undef ] : undef;
210
    $search_params->{onsite_checkout} = defined $onsite_checkout ? [ $onsite_checkout, undef ] : undef;
209
211
210
    my $rule = $self->search(
212
    my $rule = $self->search(
211
        $search_params,
213
        $search_params,
Lines 228-233 sub get_effective_rules { Link Here
228
    my $rules        = $params->{rules};
230
    my $rules        = $params->{rules};
229
    my $categorycode = $params->{categorycode};
231
    my $categorycode = $params->{categorycode};
230
    my $itemtype     = $params->{itemtype};
232
    my $itemtype     = $params->{itemtype};
233
    my $onsite_checkout = $params->{onsite_checkout};
231
    my $branchcode   = $params->{branchcode};
234
    my $branchcode   = $params->{branchcode};
232
235
233
    my $r;
236
    my $r;
Lines 238-243 sub get_effective_rules { Link Here
238
                categorycode => $categorycode,
241
                categorycode => $categorycode,
239
                itemtype     => $itemtype,
242
                itemtype     => $itemtype,
240
                branchcode   => $branchcode,
243
                branchcode   => $branchcode,
244
                onsite_checkout => $onsite_checkout,
241
            }
245
            }
242
        );
246
        );
243
247
Lines 266-272 sub set_rule { Link Here
266
        unless defined $kind_info;
270
        unless defined $kind_info;
267
271
268
    # Enforce scope; a rule should be set for its defined scope, no more, no less.
272
    # Enforce scope; a rule should be set for its defined scope, no more, no less.
269
    foreach my $scope_level ( qw( branchcode categorycode itemtype ) ) {
273
    foreach my $scope_level ( qw( branchcode onsite_checkout categorycode itemtype ) ) {
270
        if ( grep /$scope_level/, @{ $kind_info->{scope} } ) {
274
        if ( grep /$scope_level/, @{ $kind_info->{scope} } ) {
271
            croak "set_rule needs '$scope_level' to set '$params->{rule_name}'!"
275
            croak "set_rule needs '$scope_level' to set '$params->{rule_name}'!"
272
                unless exists $params->{$scope_level};
276
                unless exists $params->{$scope_level};
Lines 279-290 sub set_rule { Link Here
279
    my $branchcode   = $params->{branchcode};
283
    my $branchcode   = $params->{branchcode};
280
    my $categorycode = $params->{categorycode};
284
    my $categorycode = $params->{categorycode};
281
    my $itemtype     = $params->{itemtype};
285
    my $itemtype     = $params->{itemtype};
286
    my $onsite_checkout = $params->{onsite_checkout};
282
    my $rule_name    = $params->{rule_name};
287
    my $rule_name    = $params->{rule_name};
283
    my $rule_value   = $params->{rule_value};
288
    my $rule_value   = $params->{rule_value};
284
    my $can_be_blank = defined $kind_info->{can_be_blank} ? $kind_info->{can_be_blank} : 1;
289
    my $can_be_blank = defined $kind_info->{can_be_blank} ? $kind_info->{can_be_blank} : 1;
285
    $rule_value = undef if defined $rule_value && $rule_value eq "" && !$can_be_blank;
290
    $rule_value = undef if defined $rule_value && $rule_value eq "" && !$can_be_blank;
286
291
287
    for my $v ( $branchcode, $categorycode, $itemtype ) {
292
    for my $v ( $branchcode, $onsite_checkout, $categorycode, $itemtype ) {
288
        $v = undef if $v and $v eq '*';
293
        $v = undef if $v and $v eq '*';
289
    }
294
    }
290
    my $rule = $self->search(
295
    my $rule = $self->search(
Lines 293-298 sub set_rule { Link Here
293
            branchcode   => $branchcode,
298
            branchcode   => $branchcode,
294
            categorycode => $categorycode,
299
            categorycode => $categorycode,
295
            itemtype     => $itemtype,
300
            itemtype     => $itemtype,
301
            onsite_checkout => $onsite_checkout,
296
        }
302
        }
297
    )->next();
303
    )->next();
298
304
Lines 312-317 sub set_rule { Link Here
312
                    branchcode   => $branchcode,
318
                    branchcode   => $branchcode,
313
                    categorycode => $categorycode,
319
                    categorycode => $categorycode,
314
                    itemtype     => $itemtype,
320
                    itemtype     => $itemtype,
321
                    onsite_checkout => $onsite_checkout,
315
                    rule_name    => $rule_name,
322
                    rule_name    => $rule_name,
316
                    rule_value   => $rule_value,
323
                    rule_value   => $rule_value,
317
                }
324
                }
Lines 334-339 sub set_rules { Link Here
334
    $set_params{branchcode} = $params->{branchcode} if exists $params->{branchcode};
341
    $set_params{branchcode} = $params->{branchcode} if exists $params->{branchcode};
335
    $set_params{categorycode} = $params->{categorycode} if exists $params->{categorycode};
342
    $set_params{categorycode} = $params->{categorycode} if exists $params->{categorycode};
336
    $set_params{itemtype} = $params->{itemtype} if exists $params->{itemtype};
343
    $set_params{itemtype} = $params->{itemtype} if exists $params->{itemtype};
344
    $set_params{onsite_checkout} = $params->{onsite_checkout} if exists $params->{onsite_checkout};
345
337
    my $rules        = $params->{rules};
346
    my $rules        = $params->{rules};
338
347
339
    my $rule_objects = [];
348
    my $rule_objects = [];
Lines 538-549 sub get_effective_daysmode { Link Here
538
    my $categorycode     = $params->{categorycode};
547
    my $categorycode     = $params->{categorycode};
539
    my $itemtype         = $params->{itemtype};
548
    my $itemtype         = $params->{itemtype};
540
    my $branchcode       = $params->{branchcode};
549
    my $branchcode       = $params->{branchcode};
550
    my $onsite_checkout  = $params->{onsite_checkout};
541
551
542
    my $daysmode_rule = $class->get_effective_rule(
552
    my $daysmode_rule = $class->get_effective_rule(
543
        {
553
        {
544
            categorycode => $categorycode,
554
            categorycode => $categorycode,
545
            itemtype     => $itemtype,
555
            itemtype     => $itemtype,
546
            branchcode   => $branchcode,
556
            branchcode   => $branchcode,
557
            onsite_checkout => $onsite_checkout,
547
            rule_name    => 'daysmode',
558
            rule_name    => 'daysmode',
548
        }
559
        }
549
    );
560
    );
(-)a/t/db_dependent/Koha/CirculationRules.t (-8 / +29 lines)
Lines 22-27 use Modern::Perl; Link Here
22
use Test::More tests => 4;
22
use Test::More tests => 4;
23
use Test::Exception;
23
use Test::Exception;
24
24
25
use Koha::Checkouts;
25
use Koha::CirculationRules;
26
use Koha::CirculationRules;
26
use Koha::Database;
27
use Koha::Database;
27
28
Lines 41-46 subtest 'set_rule + get_effective_rule' => sub { Link Here
41
    my $itemtype     = $builder->build_object( { class => 'Koha::ItemTypes' } )->itemtype;
42
    my $itemtype     = $builder->build_object( { class => 'Koha::ItemTypes' } )->itemtype;
42
    my $branchcode   = $builder->build_object( { class => 'Koha::Libraries' } )->branchcode;
43
    my $branchcode   = $builder->build_object( { class => 'Koha::Libraries' } )->branchcode;
43
    my $branchcode_2 = $builder->build_object( { class => 'Koha::Libraries' } )->branchcode;
44
    my $branchcode_2 = $builder->build_object( { class => 'Koha::Libraries' } )->branchcode;
45
    my $onsite_checkout = 1;
44
    my $rule_name    = 'maxissueqty';
46
    my $rule_name    = 'maxissueqty';
45
    my $default_rule_value = 1;
47
    my $default_rule_value = 1;
46
48
Lines 56-61 subtest 'set_rule + get_effective_rule' => sub { Link Here
56
            branchcode   => $branchcode,
58
            branchcode   => $branchcode,
57
            categorycode => $categorycode,
59
            categorycode => $categorycode,
58
            itemtype     => $itemtype,
60
            itemtype     => $itemtype,
61
            onsite_checkout => undef,
59
            rule_name    => $rule_name,
62
            rule_name    => $rule_name,
60
        }
63
        }
61
    );
64
    );
Lines 66-71 subtest 'set_rule + get_effective_rule' => sub { Link Here
66
            branchcode   => '*',
69
            branchcode   => '*',
67
            categorycode => '*',
70
            categorycode => '*',
68
            itemtype     => '*',
71
            itemtype     => '*',
72
            onsite_checkout => '*',
69
            rule_name    => $rule_name,
73
            rule_name    => $rule_name,
70
            rule_value   => $default_rule_value,
74
            rule_value   => $default_rule_value,
71
        }
75
        }
Lines 76-81 subtest 'set_rule + get_effective_rule' => sub { Link Here
76
            branchcode   => undef,
80
            branchcode   => undef,
77
            categorycode => undef,
81
            categorycode => undef,
78
            itemtype     => undef,
82
            itemtype     => undef,
83
            onsite_checkout => undef,
79
            rule_name    => $rule_name,
84
            rule_name    => $rule_name,
80
        }
85
        }
81
    );
86
    );
Lines 85-90 subtest 'set_rule + get_effective_rule' => sub { Link Here
85
            branchcode   => '*',
90
            branchcode   => '*',
86
            categorycode => '*',
91
            categorycode => '*',
87
            itemtype     => '*',
92
            itemtype     => '*',
93
            onsite_checkout => '*',
88
            rule_name    => $rule_name,
94
            rule_name    => $rule_name,
89
        }
95
        }
90
    );
96
    );
Lines 96-101 subtest 'set_rule + get_effective_rule' => sub { Link Here
96
            branchcode   => $branchcode_2,
102
            branchcode   => $branchcode_2,
97
            categorycode => '*',
103
            categorycode => '*',
98
            itemtype     => '*',
104
            itemtype     => '*',
105
            onsite_checkout => '*',
99
            rule_name    => $rule_name,
106
            rule_name    => $rule_name,
100
        }
107
        }
101
    );
108
    );
Lines 133-138 subtest 'set_rule + get_effective_rule' => sub { Link Here
133
                branchcode   => $branchcode,
140
                branchcode   => $branchcode,
134
                categorycode => $categorycode,
141
                categorycode => $categorycode,
135
                itemtype     => $itemtype,
142
                itemtype     => $itemtype,
143
                onsite_checkout => $onsite_checkout,
136
            },
144
            },
137
            'maxissueqty'
145
            'maxissueqty'
138
        );
146
        );
Lines 151-156 subtest 'set_rule + get_effective_rule' => sub { Link Here
151
                    branchcode   => $branchcode,
159
                    branchcode   => $branchcode,
152
                    categorycode => $categorycode,
160
                    categorycode => $categorycode,
153
                    itemtype     => $itemtype,
161
                    itemtype     => $itemtype,
162
                    onsite_checkout => $onsite_checkout,
154
                    rule_name    => $rule_name,
163
                    rule_name    => $rule_name,
155
                }
164
                }
156
            );
165
            );
Lines 167-175 subtest 'set_rule + get_effective_rule' => sub { Link Here
167
    };
176
    };
168
177
169
    my $our_branch_rules = Koha::CirculationRules->search({branchcode => $branchcode});
178
    my $our_branch_rules = Koha::CirculationRules->search({branchcode => $branchcode});
170
    is( $our_branch_rules->count, 4, "We added 8 rules");
179
    is( $our_branch_rules->count, 8, "We added 16 rules");
171
    $our_branch_rules->delete;
180
    $our_branch_rules->delete;
172
    is( $our_branch_rules->count, 0, "We deleted 8 rules");
181
    is( $our_branch_rules->count, 0, "We deleted 16 rules");
173
182
174
    $schema->storage->txn_rollback;
183
    $schema->storage->txn_rollback;
175
};
184
};
Lines 223-229 subtest 'get_effective_daysmode' => sub { Link Here
223
            {
232
            {
224
                categorycode => undef,
233
                categorycode => undef,
225
                itemtype     => $item_1->effective_itemtype,
234
                itemtype     => $item_1->effective_itemtype,
226
                branchcode   => undef
235
                branchcode   => undef,
236
                onsite_checkout => undef,
227
            }
237
            }
228
        ),
238
        ),
229
        'Datedue',
239
        'Datedue',
Lines 235-240 subtest 'get_effective_daysmode' => sub { Link Here
235
            branchcode   => '*',
245
            branchcode   => '*',
236
            categorycode => '*',
246
            categorycode => '*',
237
            itemtype     => '*',
247
            itemtype     => '*',
248
            onsite_checkout => '*',
238
            rule_name    => 'daysmode',
249
            rule_name    => 'daysmode',
239
            rule_value   => 'Calendar',
250
            rule_value   => 'Calendar',
240
        }
251
        }
Lines 244-249 subtest 'get_effective_daysmode' => sub { Link Here
244
            branchcode   => '*',
255
            branchcode   => '*',
245
            categorycode => '*',
256
            categorycode => '*',
246
            itemtype     => $item_1->effective_itemtype,
257
            itemtype     => $item_1->effective_itemtype,
258
            onsite_checkout => '*',
247
            rule_name    => 'daysmode',
259
            rule_name    => 'daysmode',
248
            rule_value   => 'Days',
260
            rule_value   => 'Days',
249
        }
261
        }
Lines 254-260 subtest 'get_effective_daysmode' => sub { Link Here
254
            {
266
            {
255
                categorycode => undef,
267
                categorycode => undef,
256
                itemtype     => $item_1->effective_itemtype,
268
                itemtype     => $item_1->effective_itemtype,
257
                branchcode   => undef
269
                branchcode   => undef,
270
                onsite_checkout => undef,
258
            }
271
            }
259
        ),
272
        ),
260
        'Days',
273
        'Days',
Lines 265-271 subtest 'get_effective_daysmode' => sub { Link Here
265
            {
278
            {
266
                categorycode => undef,
279
                categorycode => undef,
267
                itemtype     => $item_2->effective_itemtype,
280
                itemtype     => $item_2->effective_itemtype,
268
                branchcode   => undef
281
                branchcode   => undef,
282
                onsite_checkout => undef,
269
            }
283
            }
270
        ),
284
        ),
271
        'Calendar',
285
        'Calendar',
Lines 277-282 subtest 'get_effective_daysmode' => sub { Link Here
277
            branchcode   => '*',
291
            branchcode   => '*',
278
            categorycode => '*',
292
            categorycode => '*',
279
            itemtype     => $item_2->effective_itemtype,
293
            itemtype     => $item_2->effective_itemtype,
294
            onsite_checkout => '*',
280
            rule_name    => 'daysmode',
295
            rule_name    => 'daysmode',
281
            rule_value   => '',
296
            rule_value   => '',
282
        }
297
        }
Lines 287-293 subtest 'get_effective_daysmode' => sub { Link Here
287
            {
302
            {
288
                categorycode => undef,
303
                categorycode => undef,
289
                itemtype     => $item_2->effective_itemtype,
304
                itemtype     => $item_2->effective_itemtype,
290
                branchcode   => undef
305
                branchcode   => undef,
306
                onsite_checkout => undef,
291
            }
307
            }
292
        ),
308
        ),
293
        'Datedue',
309
        'Datedue',
Lines 311-316 subtest 'get_lostreturn_policy() tests' => sub { Link Here
311
                branchcode   => undef,
327
                branchcode   => undef,
312
                categorycode => undef,
328
                categorycode => undef,
313
                itemtype     => undef,
329
                itemtype     => undef,
330
                onsite_checkout => undef,
314
                rule_name    => 'refund',
331
                rule_name    => 'refund',
315
                rule_value   => 1
332
                rule_value   => 1
316
            }
333
            }
Lines 324-329 subtest 'get_lostreturn_policy() tests' => sub { Link Here
324
                branchcode   => $branchcode,
341
                branchcode   => $branchcode,
325
                categorycode => undef,
342
                categorycode => undef,
326
                itemtype     => undef,
343
                itemtype     => undef,
344
                onsite_checkout => undef,
327
                rule_name    => 'refund',
345
                rule_name    => 'refund',
328
                rule_value   => 0
346
                rule_value   => 0
329
            }
347
            }
Lines 337-342 subtest 'get_lostreturn_policy() tests' => sub { Link Here
337
                branchcode   => $branchcode2,
355
                branchcode   => $branchcode2,
338
                categorycode => undef,
356
                categorycode => undef,
339
                itemtype     => undef,
357
                itemtype     => undef,
358
                onsite_checkout => undef,
340
                rule_name    => 'refund',
359
                rule_name    => 'refund',
341
                rule_value   => 1
360
                rule_value   => 1
342
            }
361
            }
Lines 351-356 subtest 'get_lostreturn_policy() tests' => sub { Link Here
351
                branchcode   => $branchcode3,
370
                branchcode   => $branchcode3,
352
                categorycode => undef,
371
                categorycode => undef,
353
                itemtype     => undef,
372
                itemtype     => undef,
373
                onsite_checkout => undef,
354
                rule_name    => 'refund',
374
                rule_name    => 'refund',
355
            }
375
            }
356
        }
376
        }
Lines 362-367 subtest 'get_lostreturn_policy() tests' => sub { Link Here
362
                branchcode   => $branch_without_rule,
382
                branchcode   => $branch_without_rule,
363
                categorycode => undef,
383
                categorycode => undef,
364
                itemtype     => undef,
384
                itemtype     => undef,
385
                onsite_checkout => undef,
365
                rule_name    => 'refund'
386
                rule_name    => 'refund'
366
            }
387
            }
367
          )
388
          )
Lines 410-415 subtest 'get_lostreturn_policy() tests' => sub { Link Here
410
                branchcode   => undef,
431
                branchcode   => undef,
411
                categorycode => undef,
432
                categorycode => undef,
412
                itemtype     => undef,
433
                itemtype     => undef,
434
                onsite_checkout => undef,
413
                rule_name    => 'refund'
435
                rule_name    => 'refund'
414
            }
436
            }
415
          )
437
          )
Lines 454-460 sub prepare_tests_for_rule_scope_combinations { Link Here
454
    # We must maintain the order in order to keep the test valid. This should be
476
    # We must maintain the order in order to keep the test valid. This should be
455
    # equal to Koha/CirculationRules.pm "order_by" of C<get_effective_rule> sub.
477
    # equal to Koha/CirculationRules.pm "order_by" of C<get_effective_rule> sub.
456
    # Let's explicitly define the order and fail test if we are missing a scope:
478
    # Let's explicitly define the order and fail test if we are missing a scope:
457
    my $order = [ 'branchcode', 'categorycode', 'itemtype' ];
479
    my $order = [ 'branchcode', 'onsite_checkout', 'categorycode', 'itemtype' ];
458
    is( join(", ", sort keys %$scope),
480
    is( join(", ", sort keys %$scope),
459
       join(", ", sort @$order), 'Missing a scope!' ) if keys %$scope ne scalar @$order;
481
       join(", ", sort @$order), 'Missing a scope!' ) if keys %$scope ne scalar @$order;
460
482
461
- 

Return to bug 26814