From 1a0a7b3f448f23730dbd82ceb87a2cf34d58d760 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. --- Koha/Item.pm | 2 +- Koha/Item/Transfer.pm | 5 +++-- 2 files changed, 4 insertions(+), 3 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..6a9269893c 100644 --- a/Koha/Item/Transfer.pm +++ b/Koha/Item/Transfer.pm @@ -172,10 +172,11 @@ sub cancel { { datecancelled => dt_from_string, cancellation_reason => $params->{reason} } ) ->store; - # Set up return transfer if transfer was force cancelled whilst in transit + # 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.20.1