From 45c8f21871e883118671e05863c2a9b91ac312ea Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 20 Apr 2021 10:28:40 +0100 Subject: [PATCH] Bug 12362: (QA follow-up) Fix ModItemTransfer cancellation handling ModItemTransfer is still used, sparingly. It force cancels transfers regardles of whether they are already marked as in_transit. We do not, however, want to enqueue a return transfer in this case as ModItemTransfer is itself an enqueue function. This patch updates the internal logic of ModItemTransfer to enqueue the passed transfer prior to cancelling the pre-existing one.. in this way the result is one cancelled transfer and one new transfer and not three transfers. Test plan 1/ Run t/db_dependant/Items.t and verify it fails prior to applying this patch 2/ Apply patch and run the test again, verifying it now passes. --- Koha/Item.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index 049b026bc3..ab498da607 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -456,9 +456,6 @@ sub request_transfer { Koha::Exceptions::Item::Transfer::InQueue->throw( transfer => $request ) if ( $request && !$params->{enqueue} && !$params->{replace} ); - $request->cancel( { reason => $params->{reason}, force => 1 } ) - if ( defined($request) && $params->{replace} ); - my $transfer = Koha::Item::Transfer->new( { itemnumber => $self->itemnumber, @@ -470,6 +467,9 @@ sub request_transfer { } )->store(); + $request->cancel( { reason => $params->{reason}, force => 1 } ) + if ( defined($request) && $params->{replace} ); + return $transfer; } -- 2.20.1