From a55134491976069d25b3fde66b6a9dedb4f1d661 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 25 Apr 2025 16:21:43 +0000 Subject: [PATCH] Bug 39750: Ignore limits when updating WrongTransfer This patch ignores limits when updating a wrong transfer to ensure we can return a book home when checked in at the wrong branch To test: 1 - Enable UseBranchTransferLimits based on 'Collection code' 2 - Disable transfers for FIC from: CPL -> FFL CPL -> IPT FFL -> CPL FFL -> IPT IPT -> CPL IPT -> FFL 3 - Set library to IPT 4 - Checkin an FFL item 5 - It generates a transfer home 6 - Set library to CPL 7 - Check the item in 8 - 500 error, and in logs: ==> /var/log/koha/kohadev/plack-error.log <== Exception 'Koha::Exceptions::Item::Transfer::Limit' thrown 'Transfer not allowed' 9 - Apply patch, restart all 10 - Check item in again 11 - Success! Transfer updated --- circ/returns.pl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/circ/returns.pl b/circ/returns.pl index c9c89593a82..601e20d9f24 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -549,8 +549,15 @@ if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'} ) { # Update the transfer to reflect the new item holdingbranch my $item = Koha::Items->find( $messages->{'WrongTransferItem'} ); my $old_transfer = $item->get_transfer; + + # We need to ignore limits here. While we can't transfer from this branch, it is, wrongly, here right now + # and that fact must be recorded my $new_transfer = $item->request_transfer( - { to => $old_transfer->to_library, reason => $old_transfer->reason, replace => 'WrongTransfer' } ); + { + to => $old_transfer->to_library, reason => $old_transfer->reason, replace => 'WrongTransfer', + ignore_limits => 1 + } + ); $template->param( NewTransfer => $new_transfer->id ); my $reserve = $messages->{'ResFound'}; -- 2.39.5