From e9e509b726600c4e50b807e365a9bfee6efdd364 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Sat, 15 Sep 2018 13:19:04 -0700 Subject: [PATCH] Bug 18925: Replace logic in GetBranchBorrowerCircRule with get_effective_rule --- C4/Circulation.pm | 45 +++++++++------------------------------------ 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 558a02cf35..11f413415a 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1604,30 +1604,6 @@ wildcards. sub GetBranchBorrowerCircRule { my ( $branchcode, $categorycode ) = @_; - # Set search prededences - my @params = ( - { - branchcode => $branchcode, - categorycode => $categorycode, - itemtype => undef, - }, - { - branchcode => $branchcode, - categorycode => undef, - itemtype => undef, - }, - { - branchcode => undef, - categorycode => $categorycode, - itemtype => undef, - }, - { - branchcode => undef, - categorycode => undef, - itemtype => undef, - }, - ); - # Initialize default values my $rules = { patron_maxissueqty => undef, @@ -1636,19 +1612,16 @@ sub GetBranchBorrowerCircRule { # Search for rules! foreach my $rule_name (qw( patron_maxissueqty patron_maxonsiteissueqty )) { - foreach my $params (@params) { - my $rule = Koha::CirculationRules->search( - { - rule_name => $rule_name, - %$params, - } - )->next(); - - if ( $rule ) { - $rules->{$rule_name} = $rule->rule_value; - last; + my $rule = Koha::CirculationRules->get_effective_rule( + { + categorycode => $categorycode, + itemtype => undef, + branchcode => $branchcode, + rule_name => $rule_name, } - } + ); + + $rules->{$rule_name} = $rule->rule_value if defined $rule; } return $rules; -- 2.11.0