From 75ab422aada32135053e74d4b55fd7c5f7404c35 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 Signed-off-by: Michal Denar Signed-off-by: Jonathan Druart Signed-off-by: Fridolin Somers --- C4/Circulation.pm | 39 ++++++++------------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 17cab0c74b..b55509cb37 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1845,39 +1845,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.39.5