Browse Source

Bug 18887: Insert undef instead of '*'

Koha::CirculationRules->get_effective_rule will become the method to
call to retrieve a specific rule, we should start using it when
possible.

Moreover undef could replace '*' to mean 'any', that way we will be able
to add FK on circulation_rules

TODO: Add more tests

Signed-off-by: Lisette Scheer <lisetteslatah@gmail.com>

Signed-off-by: Jesse Maseto <jesse@bywatersolution.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
18.11.x
Jonathan Druart 6 years ago
committed by Nick Clemens
parent
commit
f185785b8c
  1. 11
      C4/Reserves.pm
  2. 9
      Koha/CirculationRules.pm
  3. 4
      admin/smart-rules.pl

11
C4/Reserves.pm

@ -413,19 +413,10 @@ sub CanItemBeReserved {
}
# Now we need to check hold limits by patron category
my $rule = Koha::CirculationRules->find(
my $rule = Koha::CirculationRules->get_effective_rule(
{
categorycode => $borrower->{categorycode},
branchcode => $branchcode,
itemtype => undef,
rule_name => 'max_holds',
}
);
$rule ||= Koha::CirculationRules->find(
{
categorycode => $borrower->{categorycode},
branchcode => undef,,
itemtype => undef,
rule_name => 'max_holds',
}
);

9
Koha/CirculationRules.pm

@ -53,9 +53,9 @@ sub get_effective_rule {
my $search_params;
$search_params->{rule_name} = $rule_name;
$search_params->{categorycode} = defined $categorycode ? { 'in' => [ $categorycode, '*' ] } : undef;
$search_params->{itemtype} = defined $itemtype ? { 'in' => [ $itemtype, '*' ] } : undef;
$search_params->{branchcode} = defined $branchcode ? { 'in' => [ $branchcode, '*' ] } : undef;
$search_params->{categorycode} = defined $categorycode ? [ $categorycode, undef ] : undef;
$search_params->{itemtype} = defined $itemtype ? [ $itemtype, undef ] : undef;
$search_params->{branchcode} = defined $branchcode ? [ $branchcode, undef ] : undef;
my $rule = $self->search(
$search_params,
@ -94,6 +94,9 @@ sub set_rule {
my $rule_name = $params->{rule_name};
my $rule_value = $params->{rule_value};
for my $v ( $branchcode, $categorycode, $itemtype ) {
$v = undef if $v and $v eq '*';
}
my $rule = $self->search(
{
rule_name => $rule_name,

4
admin/smart-rules.pl

@ -271,7 +271,7 @@ elsif ($op eq "set-branch-defaults") {
Koha::CirculationRules->set_rule(
{
branchcode => $branch,
categorycode => '*',
categorycode => undef,
itemtype => undef,
rule_name => 'max_holds',
rule_value => $max_holds,
@ -348,7 +348,7 @@ elsif ($op eq "add-branch-cat") {
Koha::CirculationRules->set_rule(
{
branchcode => '*',
branchcode => undef,
categorycode => $categorycode,
itemtype => undef,
rule_name => 'max_holds',

Loading…
Cancel
Save