@@ -, +, @@ hold is canceled during transit 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 | 4 ++++ t/db_dependent/Circulation/Branch.t | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -2171,6 +2171,8 @@ sub AddReturn { if ( $transfer->tobranch eq $branch ) { $transfer->receive; $messages->{'TransferArrived'} = $transfer->frombranch; + # validTransfer=1 allows us returning the item back if the reserve is cancelled + $validTransfer = 1 if $transfer->reason eq 'Reserve'; } else { $messages->{'WrongTransfer'} = $transfer->tobranch; @@ -2181,6 +2183,8 @@ sub AddReturn { if ( $transfer->tobranch eq $branch ) { $transfer->receive; $messages->{'TransferArrived'} = $transfer->frombranch; + # validTransfer=1 allows us returning the item back if the reserve is cancelled + $validTransfer = 1 if $transfer->reason eq 'Reserve'; } else { $messages->{'WasTransfered'} = $transfer->tobranch; --- a/t/db_dependent/Circulation/Branch.t +++ a/t/db_dependent/Circulation/Branch.t @@ -25,7 +25,7 @@ use Koha::CirculationRules; use Koha::Patrons; -use Test::More tests => 15; +use Test::More tests => 16; use t::lib::Mocks; use t::lib::TestBuilder; @@ -307,7 +307,13 @@ is( $messages->{NeedsTransfer}, $samplebranch1->{branchcode}, "AddReturn respect ModItemTransfer($item_id2, $samplebranch2->{branchcode}, $samplebranch1->{branchcode}, "ReturnToHolding"); # Fulfill it ($doreturn, $messages, $iteminformation, $borrower) = AddReturn('barcode_2',$samplebranch1->{branchcode}); -is( $messages->{NeedsTransfer}, undef, "AddReturn does not generate a new transfer for return policy when resolving an existing transfer" ); +is( $messages->{NeedsTransfer}, undef, "AddReturn does not generate a new transfer for return policy when resolving an existing non-Reserve transfer" ); + +# Generate a hold caused transfer which doesn't have a hold i.e. is the hold is cancelled +ModItemTransfer($item_id2, $samplebranch2->{branchcode}, $samplebranch1->{branchcode}, "Reserve"); +# Fulfill it +($doreturn, $messages, $iteminformation, $borrower) = AddReturn('barcode_2',$samplebranch1->{branchcode}); +is( $messages->{NeedsTransfer}, $samplebranch2->{branchcode}, "AddReturn generates a new transfer for hold transfer if the hold was cancelled" ); # item3 should not trigger transfer - floating collection $query = --