From 50be8f7029ca69cdf2c0196bf0d60d9193b45298 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 4 Feb 2026 17:59:24 +0000 Subject: [PATCH] Bug 28530: (QA follow-up) Fix branch transfer limits not checking alternate libraries Fixed a pre-existing bug where branch transfer limits would prevent ANY transfer if the optimal library was blocked, instead of trying the next best candidate. Original behavior: - Sort candidates by best ratio - Check if transfer to best candidate is allowed - If not allowed: exit loop immediately (bug!) and return undef - Result: No transfer created even if other valid candidates exist Fixed behavior: - Sort candidates by best ratio - Check if transfer to best candidate is allowed - If allowed: use that library and exit loop - If not allowed: continue to next candidate - Result: Uses the best ALLOWED candidate This fix ensures that when branch transfer limits block the optimal destination, the system will try the next-best option instead of giving up entirely. Signed-off-by: Martin Renvoize --- Koha/Library/FloatLimits.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Koha/Library/FloatLimits.pm b/Koha/Library/FloatLimits.pm index d22892fc51d..840c8e8cd3b 100644 --- a/Koha/Library/FloatLimits.pm +++ b/Koha/Library/FloatLimits.pm @@ -234,8 +234,12 @@ sub lowest_ratio_library { $item->$BranchTransferLimitsType ); - $transfer_branch = Koha::Libraries->find( $candidate->{branchcode} ) if $allowed; - last; + if ($allowed) { + $transfer_branch = Koha::Libraries->find( $candidate->{branchcode} ); + last; # Found an allowed transfer, exit loop + } + + # If not allowed, continue to next candidate } else { $transfer_branch = Koha::Libraries->find( $candidate->{branchcode} ); last; -- 2.52.0