From e56f02b9c6a7cec8b47789e2ae8ee631f52a071c Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Sat, 11 Apr 2020 20:31:44 +0000 Subject: [PATCH] Bug 25115: Use get_effective_rule for getting rental discount --- C4/Circulation.pm | 42 ++++++++---------------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 747d660ea6..f228f7c703 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3301,40 +3301,14 @@ sub GetIssuingCharges { sub _get_discount_from_rule { my ($categorycode, $branchcode, $itemtype) = @_; - # Set search precedences - my @params = ( - { - branchcode => $branchcode, - itemtype => $itemtype, - categorycode => $categorycode, - }, - { - branchcode => undef, - categorycode => $categorycode, - itemtype => $itemtype, - }, - { - branchcode => $branchcode, - categorycode => $categorycode, - itemtype => undef, - }, - { - branchcode => undef, - categorycode => $categorycode, - itemtype => undef, - }, - ); - - foreach my $params (@params) { - my $rule = Koha::CirculationRules->search( - { - rule_name => 'rentaldiscount', - %$params, - } - )->next(); - - return $rule->rule_value if $rule; - } + my $rule = Koha::CirculationRules->get_effective_rule( { + branchcode => $branchcode, + itemtype => $itemtype, + categorycode => $categorycode, + rule_name => 'rentaldiscount', + } ); + + return $rule->rule_value if $rule; # none of the above return 0; -- 2.17.1