From 98e083cfcd4e4a44302a1a91ef9e6bda24710180 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 6 May 2021 16:31:39 +0100 Subject: [PATCH] Bug 28294: Pass 'replace' through to Koha::Item::Transfer->cancel The `replace` option found in Koha::Item->request_transfer should be passed through to Koha::Item::Transfer->cancel and prevent any reverse transfers from being queued in such cases. This allows us to replace updateWrongTransfer entirely with Koha::Item->request_transfer with the 'replace' parameter enabled. Signed-off-by: Victor Grousset/tuxayo --- Koha/Item.pm | 2 +- Koha/Item/Transfer.pm | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index 2bad020287..730a73bc8d 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -467,7 +467,7 @@ sub request_transfer { } )->store(); - $request->cancel( { reason => $params->{reason}, force => 1 } ) + $request->cancel( { reason => $params->{reason}, force => 1, replace => 1 } ) if ( defined($request) && $params->{replace} ); return $transfer; diff --git a/Koha/Item/Transfer.pm b/Koha/Item/Transfer.pm index d5602a9ba7..59387d4415 100644 --- a/Koha/Item/Transfer.pm +++ b/Koha/Item/Transfer.pm @@ -173,9 +173,10 @@ sub cancel { ->store; # Set up return transfer if transfer was force cancelled whilst in transit + # and we were not notified that the transfer is being replaced. # NOTE: We don't catch here, as we're happy to fail if there are already # other transfers in the queue. - if ($in_transit) { + if ($in_transit && !$params->{replace}) { try { $self->item->request_transfer( { to => $self->from_library, reason => 'TransferCancellation' } ); -- 2.31.1