From 306f7aa57f077f754caeeb315e1f1e4c29f6222b Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 8 Jun 2021 13:23:48 +0100 Subject: [PATCH] Bug 28527: Restore cancellation of transfers from Koha::Hold This aptch restores the cancellation of the transfers in transit when a hold is cancelled. --- Koha/Hold.pm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Koha/Hold.pm b/Koha/Hold.pm index bd5458f494..bd7f8f0959 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -513,6 +513,14 @@ sub cancel { my ( $self, $params ) = @_; $self->_result->result_source->schema->txn_do( sub { + if ( $self->is_in_transit ) { + my $transfer = $self->item->get_transfer; + # 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 } ); + } + } $self->cancellationdate( dt_from_string->strftime( '%Y-%m-%d %H:%M:%S' ) ); $self->priority(0); $self->cancellation_reason( $params->{cancellation_reason} ); -- 2.20.1