Swap order of circ and copy updates in AssetCommon->set_item_lost_or_lod
authorJason Stephenson <jstephenson@mvlc.org>
Sun, 8 Sep 2013 16:41:34 +0000 (12:41 -0400)
committerJason Stephenson <jstephenson@mvlc.org>
Sun, 8 Sep 2013 16:41:34 +0000 (12:41 -0400)
We update the copy's status and status_changed_time after updating the
stop_fines of the ciculation because a trigger on action.circulation
will update the copy's status which causes our status_changed_time to
be overwritten.

Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm

index ce2fbd7..d0b7167 100644 (file)
@@ -712,6 +712,25 @@ sub set_item_lost_or_lod {
         $owning_lib, $args{ous_void_od}, $e) || 0;
 
     # ---------------------------------------------------------------------
+    # mark the circ as lost and stop the fines
+    $circ->stop_fines($args{stop_fines});
+    $circ->stop_fines_time($args{stop_fines_time}) unless $circ->stop_fines_time;
+    $e->update_action_circulation($circ) or return $e->die_event;
+
+    # ---------------------------------------------------------------------
+    # void all overdue fines on this circ if configured
+    if( $void_overdue ) {
+        my $evt = OpenILS::Application::Circ::CircCommon->void_overdues($e, $circ);
+        return $evt if $evt;
+    }
+
+    # ---------------------------------------------------------------------
+    # Update trigger on action.circulation will change the status on
+    # the copy when the circulation is updated, so we need to update
+    # the copy after updating the circulation to prevent our
+    # status_changed_time from being overwritten when we try to
+    # backdate.
+    # ---------------------------------------------------------------------
     # move the copy into LOST status
     $copy->status($args{status});
     $copy->status_changed_time($args{stop_fines_time});
@@ -735,19 +754,6 @@ sub set_item_lost_or_lod {
         return $evt if $evt;
     }
 
-    # ---------------------------------------------------------------------
-    # mark the circ as lost and stop the fines
-    $circ->stop_fines($args{stop_fines});
-    $circ->stop_fines_time($args{stop_fines_time}) unless $circ->stop_fines_time;
-    $e->update_action_circulation($circ) or return $e->die_event;
-
-    # ---------------------------------------------------------------------
-    # void all overdue fines on this circ if configured
-    if( $void_overdue ) {
-        my $evt = OpenILS::Application::Circ::CircCommon->void_overdues($e, $circ);
-        return $evt if $evt;
-    }
-
     my $evt = OpenILS::Application::Circ::CircCommon->reopen_xact($e, $circ->id);
     return $evt if $evt;