Bug 18925: Replace logic in GetBranchBorrowerCircRule with get_effective_rule

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2018-09-15 13:19:04 -07:00 committed by Nick Clemens
parent d1303ca834
commit 6845cd6a67
1 changed files with 9 additions and 36 deletions

View File

@ -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;