From c132946cc075f0d622440054c439f69ff38544b5 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 10 Feb 2020 18:19:07 +0000 Subject: [PATCH] Bug 24620: Close existing transfers when setting item to waiting This patch adds a clause in ModReserveAffect to check if there are existing transfers and close them when setting a hold to waiting To test: 1 - Set AutomaticItemReturn to Do 2 - Checkin an item from Library B at Library A 3 - Confirm item is in transfer (check the details page) 4 - Place a item level hold for pickup at library A 5 - Checkin the item at Library A 6 - Confirm the hold 7 - View the details page 8 - Note the item is in transit and waiting 9 - Apply patch 10 - Delete hold and repeat 11 - Confirm that transfer is closed when hold marked waiting Signed-off-by: Sally Signed-off-by: Stina Hallin Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize --- C4/Reserves.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index b4cc6c470d..9a170b58d4 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -1145,6 +1145,18 @@ sub ModReserveAffect { _koha_notify_reserve( $hold->reserve_id ) if ( !$transferToDo && !$already_on_shelf ); + if( !$transferToDo ){ + _koha_notify_reserve( $hold->reserve_id ) unless $already_on_shelf; + my $transfers = Koha::Item::Transfers->search({ + itemnumber => $itemnumber, + datearrived => undef + }); + while( my $transfer = $transfers->next ){ + $transfer->datearrived( DateTime->now( time_zone => C4::Context->tz() ) )->store; + }; + } + + _FixPriority( { biblionumber => $biblionumber } ); my $item = Koha::Items->find($itemnumber); if ( $item->location && $item->location eq 'CART' -- 2.39.5