From d4bdba47ef995d91fe32a4378b899f77c2e1f396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joonas=20Kylm=C3=A4l=C3=A4?= Date: Mon, 7 Jun 2021 20:02:20 +0300 Subject: [PATCH] Bug 28520: Don't allow simply cancelling a transfer If we just cancel a transfer it will be in a state where we don't know where it originated from / was last seen. Let's treat cancelled transfers also as they would be in transit. --- C4/Circulation.pm | 1 - Koha/Hold.pm | 2 +- Koha/Item/Transfer.pm | 3 +-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index f0e39b7583..aaf32ef967 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3446,7 +3446,6 @@ sub GetTransfers { FROM branchtransfers WHERE itemnumber = ? AND datearrived IS NULL - AND datecancelled IS NULL '; my $sth = $dbh->prepare($query); $sth->execute($itemnumber); diff --git a/Koha/Hold.pm b/Koha/Hold.pm index 2bdae269ec..a2d7216fdb 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -519,7 +519,7 @@ sub cancel { # NOTE: Transfers are well bound with Holds.. as such we have to check that there is actually a # transfer enqueued and in transit here prior to trying to cancel it. if ( $transfer && $transfer->in_transit ) { - $transfer->cancel({ reason => 'CancelReserve', force => 1 }); + $transfer->cancel({ reason => 'CancelReserve', force => 1, replace => 1 }); } } $self->cancellationdate( dt_from_string->strftime( '%Y-%m-%d %H:%M:%S' ) ); diff --git a/Koha/Item/Transfer.pm b/Koha/Item/Transfer.pm index 21d8a2938c..c10df41ad3 100644 --- a/Koha/Item/Transfer.pm +++ b/Koha/Item/Transfer.pm @@ -110,8 +110,7 @@ sub in_transit { my ($self) = @_; return ( defined( $self->datesent ) - && !defined( $self->datearrived ) - && !defined( $self->datecancelled ) ); + && !defined( $self->datearrived ) ); } =head3 receive -- 2.25.1