Lines 216-221
our $RULE_KINDS = {
Link Here
|
216 |
holds_pickup_period => { |
216 |
holds_pickup_period => { |
217 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
217 |
scope => [ 'branchcode', 'categorycode', 'itemtype' ], |
218 |
}, |
218 |
}, |
|
|
219 |
has_priority => { |
220 |
scope => [ 'branchcode', 'categorycode' ], |
221 |
}, |
219 |
# Not included (deprecated?): |
222 |
# Not included (deprecated?): |
220 |
# * accountsent |
223 |
# * accountsent |
221 |
# * reservecharge |
224 |
# * reservecharge |
Lines 248-253
sub get_effective_rule {
Link Here
|
248 |
$params->{categorycode} //= undef; |
251 |
$params->{categorycode} //= undef; |
249 |
$params->{branchcode} //= undef; |
252 |
$params->{branchcode} //= undef; |
250 |
$params->{itemtype} //= undef; |
253 |
$params->{itemtype} //= undef; |
|
|
254 |
$params->{has_priority} //= undef; |
251 |
|
255 |
|
252 |
my $rule_name = $params->{rule_name}; |
256 |
my $rule_name = $params->{rule_name}; |
253 |
my $categorycode = $params->{categorycode}; |
257 |
my $categorycode = $params->{categorycode}; |
Lines 280-286
sub get_effective_rule {
Link Here
|
280 |
} |
284 |
} |
281 |
)->single; |
285 |
)->single; |
282 |
|
286 |
|
283 |
return $rule; |
287 |
$search_params->{has_priority} = 1; |
|
|
288 |
|
289 |
my $priority_rule = $self->search( |
290 |
$search_params, |
291 |
{ |
292 |
order_by => $order_by, |
293 |
rows => 1, |
294 |
} |
295 |
)->single; |
296 |
|
297 |
return defined $priority_rule ? $priority_rule : $rule; |
284 |
} |
298 |
} |
285 |
|
299 |
|
286 |
=head3 get_effective_rule_value |
300 |
=head3 get_effective_rule_value |
Lines 308-317
sub get_effective_rule_value {
Link Here
|
308 |
my $categorycode = $params->{categorycode}; |
322 |
my $categorycode = $params->{categorycode}; |
309 |
my $itemtype = $params->{itemtype}; |
323 |
my $itemtype = $params->{itemtype}; |
310 |
my $branchcode = $params->{branchcode}; |
324 |
my $branchcode = $params->{branchcode}; |
|
|
325 |
my $has_priority = $params->{has_priority}; |
311 |
|
326 |
|
312 |
my $memory_cache = Koha::Cache::Memory::Lite->get_instance; |
327 |
my $memory_cache = Koha::Cache::Memory::Lite->get_instance; |
313 |
my $cache_key = sprintf "CircRules:%s:%s:%s:%s", $rule_name // q{}, |
328 |
my $cache_key = sprintf "CircRules:%s:%s:%s:%s", $rule_name // q{}, |
314 |
$categorycode // q{}, $branchcode // q{}, $itemtype // q{}; |
329 |
$categorycode // q{}, $branchcode // q{}, $itemtype // q{} ,$has_priority // q{}; |
315 |
|
330 |
|
316 |
my $cached = $memory_cache->get_from_cache($cache_key); |
331 |
my $cached = $memory_cache->get_from_cache($cache_key); |
317 |
return $cached if $cached; |
332 |
return $cached if $cached; |
Lines 334-339
sub get_effective_rules {
Link Here
|
334 |
my $categorycode = $params->{categorycode}; |
349 |
my $categorycode = $params->{categorycode}; |
335 |
my $itemtype = $params->{itemtype}; |
350 |
my $itemtype = $params->{itemtype}; |
336 |
my $branchcode = $params->{branchcode}; |
351 |
my $branchcode = $params->{branchcode}; |
|
|
352 |
my $has_priority = $params->{has_priority}; |
337 |
|
353 |
|
338 |
my $r; |
354 |
my $r; |
339 |
foreach my $rule (@$rules) { |
355 |
foreach my $rule (@$rules) { |
Lines 343-348
sub get_effective_rules {
Link Here
|
343 |
categorycode => $categorycode, |
359 |
categorycode => $categorycode, |
344 |
itemtype => $itemtype, |
360 |
itemtype => $itemtype, |
345 |
branchcode => $branchcode, |
361 |
branchcode => $branchcode, |
|
|
362 |
has_priority => $has_priority, |
346 |
} |
363 |
} |
347 |
); |
364 |
); |
348 |
|
365 |
|
Lines 386-391
sub set_rule {
Link Here
|
386 |
my $itemtype = $params->{itemtype}; |
403 |
my $itemtype = $params->{itemtype}; |
387 |
my $rule_name = $params->{rule_name}; |
404 |
my $rule_name = $params->{rule_name}; |
388 |
my $rule_value = $params->{rule_value}; |
405 |
my $rule_value = $params->{rule_value}; |
|
|
406 |
my $has_priority = $params->{has_priority}; |
407 |
|
389 |
my $can_be_blank = defined $kind_info->{can_be_blank} ? $kind_info->{can_be_blank} : 1; |
408 |
my $can_be_blank = defined $kind_info->{can_be_blank} ? $kind_info->{can_be_blank} : 1; |
390 |
$rule_value = undef if defined $rule_value && $rule_value eq "" && !$can_be_blank; |
409 |
$rule_value = undef if defined $rule_value && $rule_value eq "" && !$can_be_blank; |
391 |
my $is_monetary = defined $kind_info->{is_monetary} ? $kind_info->{is_monetary} : 0; |
410 |
my $is_monetary = defined $kind_info->{is_monetary} ? $kind_info->{is_monetary} : 0; |
Lines 401-406
sub set_rule {
Link Here
|
401 |
branchcode => $branchcode, |
420 |
branchcode => $branchcode, |
402 |
categorycode => $categorycode, |
421 |
categorycode => $categorycode, |
403 |
itemtype => $itemtype, |
422 |
itemtype => $itemtype, |
|
|
423 |
has_priority => $has_priority |
404 |
} |
424 |
} |
405 |
)->next(); |
425 |
)->next(); |
406 |
|
426 |
|
Lines 422-427
sub set_rule {
Link Here
|
422 |
itemtype => $itemtype, |
442 |
itemtype => $itemtype, |
423 |
rule_name => $rule_name, |
443 |
rule_name => $rule_name, |
424 |
rule_value => $rule_value, |
444 |
rule_value => $rule_value, |
|
|
445 |
has_priority => $has_priority, |
425 |
} |
446 |
} |
426 |
); |
447 |
); |
427 |
$rule->store(); |
448 |
$rule->store(); |
Lines 447-453
sub set_rules {
Link Here
|
447 |
$set_params{branchcode} = $params->{branchcode} if exists $params->{branchcode}; |
468 |
$set_params{branchcode} = $params->{branchcode} if exists $params->{branchcode}; |
448 |
$set_params{categorycode} = $params->{categorycode} if exists $params->{categorycode}; |
469 |
$set_params{categorycode} = $params->{categorycode} if exists $params->{categorycode}; |
449 |
$set_params{itemtype} = $params->{itemtype} if exists $params->{itemtype}; |
470 |
$set_params{itemtype} = $params->{itemtype} if exists $params->{itemtype}; |
450 |
my $rules = $params->{rules}; |
471 |
$set_params{has_priority} = $params->{has_priority} if exists $params->{has_priority}; |
|
|
472 |
my $rules = $params->{rules}; |
473 |
|
451 |
|
474 |
|
452 |
my $rule_objects = []; |
475 |
my $rule_objects = []; |
453 |
while ( my ( $rule_name, $rule_value ) = each %$rules ) { |
476 |
while ( my ( $rule_name, $rule_value ) = each %$rules ) { |