Lines 227-233
our $RULE_KINDS = {
Link Here
|
227 |
bookings_trail_period => { |
227 |
bookings_trail_period => { |
228 |
scope => [ 'branchcode', 'itemtype' ], |
228 |
scope => [ 'branchcode', 'itemtype' ], |
229 |
}, |
229 |
}, |
230 |
|
230 |
has_priority => { |
|
|
231 |
scope => [ 'branchcode', 'categorycode' ], |
232 |
}, |
231 |
# Not included (deprecated?): |
233 |
# Not included (deprecated?): |
232 |
# * accountsent |
234 |
# * accountsent |
233 |
# * reservecharge |
235 |
# * reservecharge |
Lines 260-265
sub get_effective_rule {
Link Here
|
260 |
$params->{categorycode} //= undef; |
262 |
$params->{categorycode} //= undef; |
261 |
$params->{branchcode} //= undef; |
263 |
$params->{branchcode} //= undef; |
262 |
$params->{itemtype} //= undef; |
264 |
$params->{itemtype} //= undef; |
|
|
265 |
$params->{has_priority} //= undef; |
263 |
|
266 |
|
264 |
my $rule_name = $params->{rule_name}; |
267 |
my $rule_name = $params->{rule_name}; |
265 |
my $categorycode = $params->{categorycode}; |
268 |
my $categorycode = $params->{categorycode}; |
Lines 290-296
sub get_effective_rule {
Link Here
|
290 |
} |
293 |
} |
291 |
)->single; |
294 |
)->single; |
292 |
|
295 |
|
293 |
return $rule; |
296 |
$search_params->{has_priority} = 1; |
|
|
297 |
|
298 |
my $priority_rule = $self->search( |
299 |
$search_params, |
300 |
{ |
301 |
order_by => $order_by, |
302 |
rows => 1, |
303 |
} |
304 |
)->single; |
305 |
|
306 |
return defined $priority_rule ? $priority_rule : $rule; |
294 |
} |
307 |
} |
295 |
|
308 |
|
296 |
=head3 get_effective_rule_value |
309 |
=head3 get_effective_rule_value |
Lines 318-327
sub get_effective_rule_value {
Link Here
|
318 |
my $categorycode = $params->{categorycode}; |
331 |
my $categorycode = $params->{categorycode}; |
319 |
my $itemtype = $params->{itemtype}; |
332 |
my $itemtype = $params->{itemtype}; |
320 |
my $branchcode = $params->{branchcode}; |
333 |
my $branchcode = $params->{branchcode}; |
|
|
334 |
my $has_priority = $params->{has_priority}; |
321 |
|
335 |
|
322 |
my $memory_cache = Koha::Cache::Memory::Lite->get_instance; |
336 |
my $memory_cache = Koha::Cache::Memory::Lite->get_instance; |
323 |
my $cache_key = sprintf "CircRules:%s:%s:%s:%s", $rule_name // q{}, |
337 |
my $cache_key = sprintf "CircRules:%s:%s:%s:%s", $rule_name // q{}, |
324 |
$categorycode // q{}, $branchcode // q{}, $itemtype // q{}; |
338 |
$categorycode // q{}, $branchcode // q{}, $itemtype // q{} ,$has_priority // q{}; |
325 |
|
339 |
|
326 |
my $cached = $memory_cache->get_from_cache($cache_key); |
340 |
my $cached = $memory_cache->get_from_cache($cache_key); |
327 |
return $cached if $cached; |
341 |
return $cached if $cached; |
Lines 344-349
sub get_effective_rules {
Link Here
|
344 |
my $categorycode = $params->{categorycode}; |
358 |
my $categorycode = $params->{categorycode}; |
345 |
my $itemtype = $params->{itemtype}; |
359 |
my $itemtype = $params->{itemtype}; |
346 |
my $branchcode = $params->{branchcode}; |
360 |
my $branchcode = $params->{branchcode}; |
|
|
361 |
my $has_priority = $params->{has_priority}; |
347 |
|
362 |
|
348 |
my $r; |
363 |
my $r; |
349 |
foreach my $rule (@$rules) { |
364 |
foreach my $rule (@$rules) { |
Lines 353-358
sub get_effective_rules {
Link Here
|
353 |
categorycode => $categorycode, |
368 |
categorycode => $categorycode, |
354 |
itemtype => $itemtype, |
369 |
itemtype => $itemtype, |
355 |
branchcode => $branchcode, |
370 |
branchcode => $branchcode, |
|
|
371 |
has_priority => $has_priority, |
356 |
} |
372 |
} |
357 |
); |
373 |
); |
358 |
|
374 |
|
Lines 394-399
sub set_rule {
Link Here
|
394 |
my $itemtype = $params->{itemtype}; |
410 |
my $itemtype = $params->{itemtype}; |
395 |
my $rule_name = $params->{rule_name}; |
411 |
my $rule_name = $params->{rule_name}; |
396 |
my $rule_value = $params->{rule_value}; |
412 |
my $rule_value = $params->{rule_value}; |
|
|
413 |
my $has_priority = $params->{has_priority}; |
414 |
|
397 |
my $can_be_blank = defined $kind_info->{can_be_blank} ? $kind_info->{can_be_blank} : 1; |
415 |
my $can_be_blank = defined $kind_info->{can_be_blank} ? $kind_info->{can_be_blank} : 1; |
398 |
$rule_value = undef if defined $rule_value && $rule_value eq "" && !$can_be_blank; |
416 |
$rule_value = undef if defined $rule_value && $rule_value eq "" && !$can_be_blank; |
399 |
my $is_monetary = defined $kind_info->{is_monetary} ? $kind_info->{is_monetary} : 0; |
417 |
my $is_monetary = defined $kind_info->{is_monetary} ? $kind_info->{is_monetary} : 0; |
Lines 409-414
sub set_rule {
Link Here
|
409 |
branchcode => $branchcode, |
427 |
branchcode => $branchcode, |
410 |
categorycode => $categorycode, |
428 |
categorycode => $categorycode, |
411 |
itemtype => $itemtype, |
429 |
itemtype => $itemtype, |
|
|
430 |
has_priority => $has_priority |
412 |
} |
431 |
} |
413 |
)->next(); |
432 |
)->next(); |
414 |
|
433 |
|
Lines 429-434
sub set_rule {
Link Here
|
429 |
itemtype => $itemtype, |
448 |
itemtype => $itemtype, |
430 |
rule_name => $rule_name, |
449 |
rule_name => $rule_name, |
431 |
rule_value => $rule_value, |
450 |
rule_value => $rule_value, |
|
|
451 |
has_priority => $has_priority, |
432 |
} |
452 |
} |
433 |
); |
453 |
); |
434 |
$rule->store(); |
454 |
$rule->store(); |
Lines 458-463
sub set_rules {
Link Here
|
458 |
$set_params{branchcode} = $params->{branchcode} if exists $params->{branchcode}; |
478 |
$set_params{branchcode} = $params->{branchcode} if exists $params->{branchcode}; |
459 |
$set_params{categorycode} = $params->{categorycode} if exists $params->{categorycode}; |
479 |
$set_params{categorycode} = $params->{categorycode} if exists $params->{categorycode}; |
460 |
$set_params{itemtype} = $params->{itemtype} if exists $params->{itemtype}; |
480 |
$set_params{itemtype} = $params->{itemtype} if exists $params->{itemtype}; |
|
|
481 |
$set_params{has_priority} = $params->{has_priority} if exists $params->{has_priority}; |
461 |
my $rules = $params->{rules}; |
482 |
my $rules = $params->{rules}; |
462 |
|
483 |
|
463 |
my $rule_objects = []; |
484 |
my $rule_objects = []; |