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 |
); |