From: Jonathan Druart Date: Sat, 15 Sep 2018 20:19:04 +0000 (-0700) Subject: Bug 18925: Replace logic in GetBranchBorrowerCircRule with get_effective_rule X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=6845cd6a67fcc57c22aa695970236e3caab336fd;p=koha.git 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 --- 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;