From 6845cd6a67fcc57c22aa695970236e3caab336fd 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 Signed-off-by: Tomas Cohen Arazi Signed-off-by: Josef Moravec Signed-off-by: Nick Clemens --- C4/Circulation.pm | 45 +++++++++------------------------------------ 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index f4bdbf422f..58b8efb0f0 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1617,30 +1617,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, @@ -1649,19 +1625,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.39.5