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

(-)a/Koha/CirculationRules.pm (-29 / +40 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-170 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
    unseen_renewals_allowed => {
154
    unseen_renewals_allowed => {
155
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
155
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
156
    },
156
    },
157
    rentaldiscount => {
157
    rentaldiscount => {
158
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
158
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
159
    },
159
    },
160
    reservesallowed => {
160
    reservesallowed => {
161
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
161
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
162
    },
162
    },
163
    suspension_chargeperiod => {
163
    suspension_chargeperiod => {
164
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
164
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
165
    },
165
    },
166
    note => { # This is not really a rule. Maybe we will want to separate this later.
166
    note => { # This is not really a rule. Maybe we will want to separate this later.
167
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
167
        scope => [ 'branchcode', 'categorycode', 'itemtype', 'onsite_checkout' ],
168
    },
168
    },
169
    decreaseloanholds => {
169
    decreaseloanholds => {
170
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
170
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
Lines 194-210 sub get_effective_rule { Link Here
194
    my $categorycode = $params->{categorycode};
194
    my $categorycode = $params->{categorycode};
195
    my $itemtype     = $params->{itemtype};
195
    my $itemtype     = $params->{itemtype};
196
    my $branchcode   = $params->{branchcode};
196
    my $branchcode   = $params->{branchcode};
197
    my $onsite_checkout = $params->{onsite_checkout};
197
198
198
    Koha::Exceptions::MissingParameter->throw(
199
    Koha::Exceptions::MissingParameter->throw(
199
        "Required parameter 'rule_name' missing")
200
        "Required parameter 'rule_name' missing")
200
      unless $rule_name;
201
      unless $rule_name;
201
202
202
    for my $v ( $branchcode, $categorycode, $itemtype ) {
203
    for my $v ( $branchcode, $onsite_checkout, $categorycode, $itemtype ) {
203
        $v = undef if $v and $v eq '*';
204
        $v = undef if $v and $v eq '*';
204
    }
205
    }
205
206
206
    my $order_by = $params->{order_by}
207
    my $order_by = $params->{order_by}
207
      // { -desc => [ 'branchcode', 'categorycode', 'itemtype' ] };
208
      // { -desc => [ 'branchcode', 'onsite_checkout', 'categorycode', 'itemtype', ] };
208
209
209
    my $search_params;
210
    my $search_params;
210
    $search_params->{rule_name} = $rule_name;
211
    $search_params->{rule_name} = $rule_name;
Lines 212-217 sub get_effective_rule { Link Here
212
    $search_params->{categorycode} = defined $categorycode ? [ $categorycode, undef ] : undef;
213
    $search_params->{categorycode} = defined $categorycode ? [ $categorycode, undef ] : undef;
213
    $search_params->{itemtype}     = defined $itemtype     ? [ $itemtype, undef ] : undef;
214
    $search_params->{itemtype}     = defined $itemtype     ? [ $itemtype, undef ] : undef;
214
    $search_params->{branchcode}   = defined $branchcode   ? [ $branchcode,   undef ] : undef;
215
    $search_params->{branchcode}   = defined $branchcode   ? [ $branchcode,   undef ] : undef;
216
    $search_params->{onsite_checkout} = defined $onsite_checkout ? [ $onsite_checkout, undef ] : undef;
215
217
216
    my $rule = $self->search(
218
    my $rule = $self->search(
217
        $search_params,
219
        $search_params,
Lines 234-239 sub get_effective_rules { Link Here
234
    my $rules        = $params->{rules};
236
    my $rules        = $params->{rules};
235
    my $categorycode = $params->{categorycode};
237
    my $categorycode = $params->{categorycode};
236
    my $itemtype     = $params->{itemtype};
238
    my $itemtype     = $params->{itemtype};
239
    my $onsite_checkout = $params->{onsite_checkout};
237
    my $branchcode   = $params->{branchcode};
240
    my $branchcode   = $params->{branchcode};
238
241
239
    my $r;
242
    my $r;
Lines 244-249 sub get_effective_rules { Link Here
244
                categorycode => $categorycode,
247
                categorycode => $categorycode,
245
                itemtype     => $itemtype,
248
                itemtype     => $itemtype,
246
                branchcode   => $branchcode,
249
                branchcode   => $branchcode,
250
                onsite_checkout => $onsite_checkout,
247
            }
251
            }
248
        );
252
        );
249
253
Lines 272-278 sub set_rule { Link Here
272
        unless defined $kind_info;
276
        unless defined $kind_info;
273
277
274
    # Enforce scope; a rule should be set for its defined scope, no more, no less.
278
    # Enforce scope; a rule should be set for its defined scope, no more, no less.
275
    foreach my $scope_level ( qw( branchcode categorycode itemtype ) ) {
279
    foreach my $scope_level ( qw( branchcode onsite_checkout categorycode itemtype ) ) {
276
        if ( grep /$scope_level/, @{ $kind_info->{scope} } ) {
280
        if ( grep /$scope_level/, @{ $kind_info->{scope} } ) {
277
            croak "set_rule needs '$scope_level' to set '$params->{rule_name}'!"
281
            croak "set_rule needs '$scope_level' to set '$params->{rule_name}'!"
278
                unless exists $params->{$scope_level};
282
                unless exists $params->{$scope_level};
Lines 285-296 sub set_rule { Link Here
285
    my $branchcode   = $params->{branchcode};
289
    my $branchcode   = $params->{branchcode};
286
    my $categorycode = $params->{categorycode};
290
    my $categorycode = $params->{categorycode};
287
    my $itemtype     = $params->{itemtype};
291
    my $itemtype     = $params->{itemtype};
292
    my $onsite_checkout = $params->{onsite_checkout};
288
    my $rule_name    = $params->{rule_name};
293
    my $rule_name    = $params->{rule_name};
289
    my $rule_value   = $params->{rule_value};
294
    my $rule_value   = $params->{rule_value};
290
    my $can_be_blank = defined $kind_info->{can_be_blank} ? $kind_info->{can_be_blank} : 1;
295
    my $can_be_blank = defined $kind_info->{can_be_blank} ? $kind_info->{can_be_blank} : 1;
291
    $rule_value = undef if defined $rule_value && $rule_value eq "" && !$can_be_blank;
296
    $rule_value = undef if defined $rule_value && $rule_value eq "" && !$can_be_blank;
292
297
293
    for my $v ( $branchcode, $categorycode, $itemtype ) {
298
    for my $v ( $branchcode, $onsite_checkout, $categorycode, $itemtype ) {
294
        $v = undef if $v and $v eq '*';
299
        $v = undef if $v and $v eq '*';
295
    }
300
    }
296
    my $rule = $self->search(
301
    my $rule = $self->search(
Lines 299-304 sub set_rule { Link Here
299
            branchcode   => $branchcode,
304
            branchcode   => $branchcode,
300
            categorycode => $categorycode,
305
            categorycode => $categorycode,
301
            itemtype     => $itemtype,
306
            itemtype     => $itemtype,
307
            onsite_checkout => $onsite_checkout,
302
        }
308
        }
303
    )->next();
309
    )->next();
304
310
Lines 318-323 sub set_rule { Link Here
318
                    branchcode   => $branchcode,
324
                    branchcode   => $branchcode,
319
                    categorycode => $categorycode,
325
                    categorycode => $categorycode,
320
                    itemtype     => $itemtype,
326
                    itemtype     => $itemtype,
327
                    onsite_checkout => $onsite_checkout,
321
                    rule_name    => $rule_name,
328
                    rule_name    => $rule_name,
322
                    rule_value   => $rule_value,
329
                    rule_value   => $rule_value,
323
                }
330
                }
Lines 340-345 sub set_rules { Link Here
340
    $set_params{branchcode} = $params->{branchcode} if exists $params->{branchcode};
347
    $set_params{branchcode} = $params->{branchcode} if exists $params->{branchcode};
341
    $set_params{categorycode} = $params->{categorycode} if exists $params->{categorycode};
348
    $set_params{categorycode} = $params->{categorycode} if exists $params->{categorycode};
342
    $set_params{itemtype} = $params->{itemtype} if exists $params->{itemtype};
349
    $set_params{itemtype} = $params->{itemtype} if exists $params->{itemtype};
350
    $set_params{onsite_checkout} = $params->{onsite_checkout} if exists $params->{onsite_checkout};
351
343
    my $rules        = $params->{rules};
352
    my $rules        = $params->{rules};
344
353
345
    my $rule_objects = [];
354
    my $rule_objects = [];
Lines 558-569 sub get_effective_daysmode { Link Here
558
    my $categorycode     = $params->{categorycode};
567
    my $categorycode     = $params->{categorycode};
559
    my $itemtype         = $params->{itemtype};
568
    my $itemtype         = $params->{itemtype};
560
    my $branchcode       = $params->{branchcode};
569
    my $branchcode       = $params->{branchcode};
570
    my $onsite_checkout  = $params->{onsite_checkout};
561
571
562
    my $daysmode_rule = $class->get_effective_rule(
572
    my $daysmode_rule = $class->get_effective_rule(
563
        {
573
        {
564
            categorycode => $categorycode,
574
            categorycode => $categorycode,
565
            itemtype     => $itemtype,
575
            itemtype     => $itemtype,
566
            branchcode   => $branchcode,
576
            branchcode   => $branchcode,
577
            onsite_checkout => $onsite_checkout,
567
            rule_name    => 'daysmode',
578
            rule_name    => 'daysmode',
568
        }
579
        }
569
    );
580
    );
(-)a/t/db_dependent/Koha/CirculationRules.t (-8 / +30 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    => 'lostreturn',
331
                rule_name    => 'lostreturn',
315
                rule_value   => 'charge'
332
                rule_value   => 'charge'
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    => 'lostreturn',
345
                rule_name    => 'lostreturn',
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    => 'lostreturn',
359
                rule_name    => 'lostreturn',
341
                rule_value   => 'refund'
360
                rule_value   => 'refund'
342
            }
361
            }
Lines 350-355 subtest 'get_lostreturn_policy() tests' => sub { Link Here
350
                branchcode   => $branchcode3,
369
                branchcode   => $branchcode3,
351
                categorycode => undef,
370
                categorycode => undef,
352
                itemtype     => undef,
371
                itemtype     => undef,
372
                onsite_checkout => undef,
353
                rule_name    => 'lostreturn',
373
                rule_name    => 'lostreturn',
354
                rule_value   => 'restore'
374
                rule_value   => 'restore'
355
            }
375
            }
Lines 365-370 subtest 'get_lostreturn_policy() tests' => sub { Link Here
365
                branchcode   => $branchcode4,
385
                branchcode   => $branchcode4,
366
                categorycode => undef,
386
                categorycode => undef,
367
                itemtype     => undef,
387
                itemtype     => undef,
388
                onsite_checkout => undef,
368
                rule_name    => 'lostreturn',
389
                rule_name    => 'lostreturn',
369
                rule_value   => 'refund'
390
                rule_value   => 'refund'
370
            }
391
            }
Lines 377-382 subtest 'get_lostreturn_policy() tests' => sub { Link Here
377
                branchcode   => $branch_without_rule,
398
                branchcode   => $branch_without_rule,
378
                categorycode => undef,
399
                categorycode => undef,
379
                itemtype     => undef,
400
                itemtype     => undef,
401
                onsite_checkout => undef,
380
                rule_name    => 'lostreturn',
402
                rule_name    => 'lostreturn',
381
                rule_value   => 'refund'
403
                rule_value   => 'refund'
382
            }
404
            }
Lines 426-431 subtest 'get_lostreturn_policy() tests' => sub { Link Here
426
                branchcode   => undef,
448
                branchcode   => undef,
427
                categorycode => undef,
449
                categorycode => undef,
428
                itemtype     => undef,
450
                itemtype     => undef,
451
                onsite_checkout => undef,
429
                rule_name    => 'lostreturn'
452
                rule_name    => 'lostreturn'
430
            }
453
            }
431
          )
454
          )
Lines 470-476 sub prepare_tests_for_rule_scope_combinations { Link Here
470
    # We must maintain the order in order to keep the test valid. This should be
493
    # We must maintain the order in order to keep the test valid. This should be
471
    # equal to Koha/CirculationRules.pm "order_by" of C<get_effective_rule> sub.
494
    # equal to Koha/CirculationRules.pm "order_by" of C<get_effective_rule> sub.
472
    # Let's explicitly define the order and fail test if we are missing a scope:
495
    # Let's explicitly define the order and fail test if we are missing a scope:
473
    my $order = [ 'branchcode', 'categorycode', 'itemtype' ];
496
    my $order = [ 'branchcode', 'onsite_checkout', 'categorycode', 'itemtype' ];
474
    is( join(", ", sort keys %$scope),
497
    is( join(", ", sort keys %$scope),
475
       join(", ", sort @$order), 'Missing a scope!' ) if keys %$scope ne scalar @$order;
498
       join(", ", sort @$order), 'Missing a scope!' ) if keys %$scope ne scalar @$order;
476
499
477
- 

Return to bug 26814