From 92e1a9823eae97ddc11a1b0a4a09f763741b777b Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 25 Feb 2026 06:29:28 +0000 Subject: [PATCH] Bug 41917: (QA follow-up) Derive parent pool rule from child rule in TooMany Now that CirculationRules::get_effective_rule performs parent itemtype fallback internally, a child item with no specific maxissueqty rule will already receive the parent rule back from that call. Deriving $parent_maxissueqty_rule from $maxissueqty_rule in that case avoids a redundant second get_effective_rule call for the parent itemtype. When the child does have its own specific rule the parent pool limit is still fetched explicitly, preserving the existing behaviour for that path. Also moves the $maxissueqty_rule lookup before the parent rule determination so the result is available for the comparison. Signed-off-by: Martin Renvoize --- C4/Circulation.pm | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 9fa3c9e8745..a37a2c5a1ca 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -448,18 +448,6 @@ sub TooMany { # given branch, patron category, and item type, determine # applicable issuing rule - $parent_maxissueqty_rule = Koha::CirculationRules->get_effective_rule( - { - categorycode => $cat_borrower, - itemtype => $parent_type, - branchcode => $branch, - rule_name => 'maxissueqty', - } - ) if $parent_type; - - # If the parent rule is for default type we discount it - $parent_maxissueqty_rule = undef if $parent_maxissueqty_rule && !defined $parent_maxissueqty_rule->itemtype; - my $maxissueqty_rule = Koha::CirculationRules->get_effective_rule( { categorycode => $cat_borrower, @@ -469,6 +457,31 @@ sub TooMany { } ); + if ($parent_type) { + if ( $maxissueqty_rule + && defined $maxissueqty_rule->itemtype + && $maxissueqty_rule->itemtype eq $parent_type ) + { + # get_effective_rule already fell back to the parent itemtype rule + $parent_maxissueqty_rule = $maxissueqty_rule; + } else { + + # Child has its own specific rule; look up parent pool limit separately + $parent_maxissueqty_rule = Koha::CirculationRules->get_effective_rule( + { + categorycode => $cat_borrower, + itemtype => $parent_type, + branchcode => $branch, + rule_name => 'maxissueqty', + } + ); + + # Discard if only a global (non-itemtype-specific) rule was found + $parent_maxissueqty_rule = undef + if $parent_maxissueqty_rule && !defined $parent_maxissueqty_rule->itemtype; + } + } + my $maxonsiteissueqty_rule = Koha::CirculationRules->get_effective_rule( { categorycode => $cat_borrower, -- 2.53.0