From 22cf9bb24ef8a81660998617c1126891c14a2c84 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Fri, 18 Mar 2016 16:38:33 -0400 Subject: [PATCH] LP 1306666: Abort Transit Only Change Copy Status if In Transit When aborting a transit, the copy status is presently changed, either to the status stored in action.transit_copy or to Reshelving if the transit was for a hold. This causes problems with "hanging" transits where something was not handled properly before. We've had cases where a transit sticks around on a copy that is later checked out, and while that copy is checked out, the transit is aborted, thus setting the copy status to Reshelving when it should be Checked Out. The code change in this branch only changes the copy's status if it is In Transit. A copy in any other status has its status left untouched. Signed-off-by: Jason Stephenson Signed-off-by: Mike Rylander --- .../lib/OpenILS/Application/Circ/Transit.pm | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Transit.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Transit.pm index bd687c421d..d5185862a7 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Transit.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Transit.pm @@ -239,20 +239,24 @@ sub __abort_transit { return $e->die_event unless $e->allowed('ABORT_REMOTE_TRANSIT', $e->requestor->ws_ou); } - # recover the copy status - $copy->status( $transit->copy_status ); - $copy->editor( $e->requestor->id ); - $copy->edit_date('now'); - my $holdtransit = $e->retrieve_action_hold_transit_copy($transit->id); - if( $holdtransit ) { - $logger->info("setting copy to reshelving on hold transit abort"); - $copy->status( OILS_COPY_STATUS_RESHELVING ); + return $e->die_event unless $e->delete_action_transit_copy($transit); + + # Only change the copy status if the copy status is "In Transit." + if ($copy->status == OILS_COPY_STATUS_IN_TRANSIT) { + # recover the copy status + $copy->status( $transit->copy_status ); + $copy->editor( $e->requestor->id ); + $copy->edit_date('now'); + + if ( $holdtransit ) { + $logger->info("setting copy to reshelving on hold transit abort"); + $copy->status( OILS_COPY_STATUS_RESHELVING ); + } + return $e->die_event unless $e->update_asset_copy($copy); } - return $e->die_event unless $e->delete_action_transit_copy($transit); - return $e->die_event unless $e->update_asset_copy($copy); $e->commit unless $no_commit; -- 2.43.2