From a8f376ac0e6f20734b1a4bbd45ab196530d098db Mon Sep 17 00:00:00 2001 From: Jake Deery Date: Fri, 6 Mar 2026 14:43:34 +0000 Subject: [PATCH] Bug 14962: (QA follow-up) Returning book now transfers to effective home library This patch fixes a design oversight that saw books to into transfer for their homebranch, not effective_homebranch, meaning books would be returned to the wrong place when on display. Sponsored-by: ByWater Solutions --- C4/Circulation.pm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 6a634cf1bfb..07e47f57321 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -349,7 +349,7 @@ sub transferbook { my $itemnumber = $item->itemnumber; # get branches of book... - my $hbr = $item->homebranch; + my $hbr = $item->effective_homebranch; # if using Branch Transfer Limits if ( C4::Context->preference("UseBranchTransferLimits") == 1 ) { @@ -2340,7 +2340,11 @@ sub AddReturn { # if library isn't in same the float group, transfer item to homebranch $hbr = 'homebranch'; - $returnbranch = $validate_float ? $branch : $item->$hbr; + $returnbranch = $validate_float ? $branch : $item->effective_homebranch; + } elsif ( $hbr eq 'homebranch' ) { + $returnbranch = $item->effective_homebranch; + } elsif ( $hbr eq 'holdingbranch' ) { + $returnbranch = $item->effective_holdingbranch; } else { $returnbranch = $item->$hbr; } @@ -2354,7 +2358,7 @@ sub AddReturn { my $limit = Koha::Library::FloatLimits->find( { itemtype => $effective_itemtype, branchcode => $branch } ); if ($limit) { my $transfer_library = - Koha::Library::FloatLimits->lowest_ratio_library( $item, $branch, $item->holdingbranch ); + Koha::Library::FloatLimits->lowest_ratio_library( $item, $branch, $item->effective_holdingbranch ); if ( $transfer_library && $transfer_library->branchcode ne $branch ) { $returnbranch = $transfer_library->branchcode; $transfer_trigger = 'LibraryFloatLimit'; @@ -2469,7 +2473,7 @@ sub AddReturn { # the holdingbranch is updated if the document is returned to another location. # this is always done regardless of whether the item was on loan or not - if ( $item->holdingbranch ne $branch ) { + if ( $item->effective_holdingbranch ne $branch ) { $item->holdingbranch($branch)->store( { log_action => 0, skip_record_index => 1, skip_holds_queue => 1 } ); } -- 2.50.1 (Apple Git-155)