From cda860678561decd12dea6f981aefcbb991cab7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joonas=20Kylm=C3=A4l=C3=A4?= Date: Mon, 7 Jun 2021 21:49:21 +0300 Subject: [PATCH] Bug 28520: Create cancelled hold's transfer back after previous transfer finishes This fixes regression caused by "Bug 12362: Cancel transfer with hold cancelation" where cancelled hold's transfer didn't show up in intranet and opac because it create a new transfer that was not yet put in in-transit state. The original idea of bug 12362 was to be able to trigger transfer back home if a hold was cancelled. We can do it more simply by setting the $validTransfer variable true in the item check-in code when we are dealing with Reserve transfers. To test: 1) Apply patch 1) Have biblio with item in branch A 2) Create a new hold with a pickup library to branch B 3) Check-in the item at branch A and confirm the hold and transfer 4) Cancel the hold 5) Check-in the hold at branch B and notice it prompt to return it to branch A --- C4/Circulation.pm | 2 ++ Koha/Hold.pm | 8 -------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 10db0d226a..de1d77595f 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2171,6 +2171,7 @@ sub AddReturn { if ( $transfer->tobranch eq $branch ) { $transfer->receive; $messages->{'TransferArrived'} = $transfer->frombranch; + $validTransfer = 1 if $transfer->reason eq 'Reserve'; } else { $messages->{'WrongTransfer'} = $transfer->tobranch; @@ -2181,6 +2182,7 @@ sub AddReturn { if ( $transfer->tobranch eq $branch ) { $transfer->receive; $messages->{'TransferArrived'} = $transfer->frombranch; + $validTransfer = 1 if $transfer->reason eq 'Reserve'; } else { $messages->{'WasTransfered'} = $transfer->tobranch; diff --git a/Koha/Hold.pm b/Koha/Hold.pm index 2bdae269ec..cefc3ed666 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -514,14 +514,6 @@ sub cancel { $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.25.1