From d662410544ae3f20e827dce320bca285e484bcc9 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 22 Mar 2021 14:57:06 +0000 Subject: [PATCH] Bug 12362: Cancel transfer with hold cancelation This patch adds a transfer cancellation when a hold is cancelled. --- Koha/Hold.pm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Koha/Hold.pm b/Koha/Hold.pm index 892fb20cd5..a7be5287da 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -497,8 +497,15 @@ Cancel a hold: sub cancel { my ( $self, $params ) = @_; + $self->_result->result_source->schema->txn_do( sub { + if ( $self->is_in_transit ) { + my $transfer = $self->item->get_transfer; + if ( $transfer->in_transit ) { + $transfer->cancel({ reason => 'CancelReserve', force => 1 }); + } + } $self->cancellationdate( dt_from_string->strftime( '%Y-%m-%d %H:%M:%S' ) ); $self->priority(0); $self->cancellation_reason( $params->{cancellation_reason} ); -- 2.20.1