Add "backdate" option to set item lost or longoverdue. user/dyrcona/backdate_lost_or_lod
authorJason Stephenson <jstephenson@mvlc.org>
Tue, 3 Sep 2013 17:51:06 +0000 (13:51 -0400)
committerJason Stephenson <jstephenson@mvlc.org>
Tue, 3 Sep 2013 17:51:06 +0000 (13:51 -0400)
This optional parameter allows the caller to set the lost date in the past
or the future, if their crystal ball is not cloudy.  While the staff client
may not ever use this option, it comes in handy in some utility scripts.
It is also a really handy feature when writing one's own migration scripts.

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

index 1cf8cc8..ecae769 100644 (file)
@@ -642,7 +642,7 @@ sub copy_perm_org {
 
 
 sub set_item_lost {
-    my ($class, $e, $copy_id) = @_;
+    my ($class, $e, $copy_id, $backdate) = @_;
 
     return $class->set_item_lost_or_lod(
         $e, $copy_id,
@@ -656,12 +656,13 @@ sub set_item_lost {
         bill_fee_note => 'Lost Materials Processing Fee',
         event => 'COPY_MARKED_LOST',
         stop_fines => OILS_STOP_FINES_LOST,
+        stop_fines_time => $backdate || 'now',
         at_hook => 'lost'
     );
 }
 
 sub set_item_long_overdue {
-    my ($class, $e, $copy_id) = @_;
+    my ($class, $e, $copy_id, $backdate) = @_;
 
     return $class->set_item_lost_or_lod(
         $e, $copy_id,
@@ -675,6 +676,7 @@ sub set_item_long_overdue {
         bill_fee_note => 'Long Overdue Materials Processing Fee',
         event => 'COPY_MARKED_LONG_OVERDUE',
         stop_fines => 'LONGOVERDUE',
+        stop_fines_time => $backdate || 'now',
         at_hook => 'longoverdue'
     );
 }
@@ -735,7 +737,7 @@ sub set_item_lost_or_lod {
     # ---------------------------------------------------------------------
     # mark the circ as lost and stop the fines
     $circ->stop_fines($args{stop_fines});
-    $circ->stop_fines_time('now') unless $circ->stop_fines_time;
+    $circ->stop_fines_time($args{stop_fines_time}) unless $circ->stop_fines_time;
     $e->update_action_circulation($circ) or return $e->die_event;
 
     # ---------------------------------------------------------------------
index 94dbaf8..7d4acdd 100644 (file)
@@ -336,7 +336,7 @@ __PACKAGE__->register_method(
     signature   => q/
         Sets the copy and related open circulation to lost
         @param auth
-        @param args : barcode
+        @param args : barcode, backdate
     /
 );
 
@@ -354,7 +354,7 @@ sub new_set_circ_lost {
     my $copy = $e->search_asset_copy({barcode=>$$args{barcode}, deleted=>'f'})->[0]
         or return $e->die_event;
 
-    my $evt = OpenILS::Application::Cat::AssetCommon->set_item_lost($e, $copy->id);
+    my $evt = OpenILS::Application::Cat::AssetCommon->set_item_lost($e, $copy->id, $$args{backdate});
     return $evt if $evt;
 
     $e->commit;