From 8d9068dcc64957cd72cf641ffbd93dc176784e01 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Sun, 8 Sep 2013 09:18:03 -0400 Subject: [PATCH] Add "backdate" option to set item lost or longoverdue. 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 --- Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm | 9 ++++++--- Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm index 1cf8cc8bed..ce2fbd7278 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm @@ -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' ); } @@ -712,6 +714,7 @@ sub set_item_lost_or_lod { # --------------------------------------------------------------------- # move the copy into LOST status $copy->status($args{status}); + $copy->status_changed_time($args{stop_fines_time}); $copy->editor($e->requestor->id); $copy->edit_date('now'); $e->update_asset_copy($copy) or return $e->die_event; @@ -735,7 +738,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; # --------------------------------------------------------------------- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm index 94dbaf86b0..7d4acddf3b 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm @@ -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; -- 2.11.0