From 8ee533dadb6ddffce051861280f3ecc145c4c26f Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 15 Dec 2021 16:27:18 +0000 Subject: [PATCH] Bug 29703: Use get_effective_rules in GetBranchItemRule To test: 1 - prove -v t/db_dependent/Circulation/Branch.t --- C4/Circulation.pm | 39 ++++++++------------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index c2edf81f94..bc8894f849 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1846,39 +1846,16 @@ sub GetBranchItemRule { my ( $branchcode, $itemtype ) = @_; # Search for rules! - my $holdallowed_rule = Koha::CirculationRules->get_effective_rule( - { - branchcode => $branchcode, - itemtype => $itemtype, - rule_name => 'holdallowed', - } - ); - my $hold_fulfillment_policy_rule = Koha::CirculationRules->get_effective_rule( - { - branchcode => $branchcode, - itemtype => $itemtype, - rule_name => 'hold_fulfillment_policy', - } - ); - my $returnbranch_rule = Koha::CirculationRules->get_effective_rule( - { - branchcode => $branchcode, - itemtype => $itemtype, - rule_name => 'returnbranch', - } - ); + my $rules = Koha::CirculationRules->get_effective_rules({ + branchcode => $branchcode, + itemtype => $itemtype, + rules => ['holdallowed', 'hold_fulfillment_policy', 'returnbranch'] + }); # built-in default circulation rule - my $rules; - $rules->{holdallowed} = defined $holdallowed_rule - ? $holdallowed_rule->rule_value - : 'from_any_library'; - $rules->{hold_fulfillment_policy} = defined $hold_fulfillment_policy_rule - ? $hold_fulfillment_policy_rule->rule_value - : 'any'; - $rules->{returnbranch} = defined $returnbranch_rule - ? $returnbranch_rule->rule_value - : 'homebranch'; + $rules->{holdallowed} //= 'from_any_library'; + $rules->{hold_fulfillment_policy} //= 'any'; + $rules->{returnbranch} //= 'homebranch'; return $rules; } -- 2.20.1