Fix error on deleted hold in transit
authorThomas Berezansky <tsbere@mvlc.org>
Wed, 24 Jul 2013 14:02:08 +0000 (10:02 -0400)
committerJason Stephenson <jstephenson@mvlc.org>
Wed, 31 Jul 2013 19:05:32 +0000 (15:05 -0400)
May be caused by purging holds combined with "Checkout fills related hold"

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm

index ff50ed3..e01bbc9 100644 (file)
@@ -3271,14 +3271,21 @@ sub process_received_transit {
     if($hold_transit) { 
         my $hold = $self->editor->retrieve_action_hold_request($hold_transit->hold);
 
     if($hold_transit) { 
         my $hold = $self->editor->retrieve_action_hold_request($hold_transit->hold);
 
-        # hold has arrived at destination, set shelf time
-        $self->put_hold_on_shelf($hold);
-        $self->bail_on_events($self->editor->event)
-            unless $self->editor->update_action_hold_request($hold);
-        return if $self->bail_out;
+        if ($hold) {
+            # hold has arrived at destination, set shelf time
+            $self->put_hold_on_shelf($hold);
+            $self->bail_on_events($self->editor->event)
+                unless $self->editor->update_action_hold_request($hold);
+            return if $self->bail_out;
 
 
-        $self->notify_hold($hold_transit->hold);
-        $ishold = 1;
+            $self->notify_hold($hold_transit->hold);
+            $ishold = 1;
+        } else {
+            $hold_transit = undef;
+            $self->cancelled_hold_transit(1);
+            $self->reshelve_copy(1);
+            $self->fake_hold_dest(0);
+        }
     }
 
     $self->push_events( 
     }
 
     $self->push_events(