Bug 32129: (QA follow-up) Avoid duplicate calculation

This patch stores the output from ->check_recall() (a Koha::Recall
object or undef) and reuses afterwards, on a ternaty operator.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 62f176d079)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
This commit is contained in:
Tomas Cohen Arazi 2023-05-12 15:47:02 -03:00 committed by Matt Blenkinsop
parent a104de7094
commit 9adac1f4d4
1 changed files with 9 additions and 8 deletions

View File

@ -1969,14 +1969,15 @@ sub can_be_waiting_recall {
}
# Check the circulation rule for each relevant itemtype for this item
my $rule = Koha::CirculationRules->get_effective_rules({
branchcode => $branchcode,
categorycode => $self->check_recalls ? $self->check_recalls->patron->categorycode : undef,
itemtype => $self->effective_itemtype,
rules => [
'recalls_allowed',
],
});
my $most_relevant_recall = $self->check_recalls;
my $rule = Koha::CirculationRules->get_effective_rules(
{
branchcode => $branchcode,
categorycode => $most_relevant_recall ? $most_relevant_recall->patron->categorycode : undef,
itemtype => $self->effective_itemtype,
rules => [ 'recalls_allowed', ],
}
);
# check recalls allowed has been set and is not zero
return 0 if ( !defined($rule->{recalls_allowed}) || $rule->{recalls_allowed} == 0 );