LP#1562061 Make Lost/Long-overdue billings exclusive
authorDan Wells <dbw2@calvin.edu>
Thu, 13 Sep 2018 19:20:36 +0000 (15:20 -0400)
committerDan Wells <dbw2@calvin.edu>
Thu, 13 Sep 2018 19:46:48 +0000 (15:46 -0400)
It would be nice if, for purposes of status, we could mark long-
overdue items as lost, but without causing any duplicate billings.

This code interprets any long-overdue/lost billing as "final" for
automation purposes, and then only generates bills (and potentially
reopens xacts) in cases where no "final" billing has yet taken
place (based on stopfines).

(indenting left in place for readability, handled in follow-up)

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm

index e52d94f..e3de9e4 100644 (file)
@@ -807,7 +807,6 @@ sub set_item_lost {
         $e, $copy_id,
         perm => 'SET_CIRC_LOST',
         status => OILS_COPY_STATUS_LOST,
-        alt_status => 16, #Long Overdue,
         ous_proc_fee => OILS_SETTING_LOST_PROCESSING_FEE,
         ous_void_od => OILS_SETTING_VOID_OVERDUE_ON_LOST,
         bill_type => 3,
@@ -826,8 +825,7 @@ sub set_item_long_overdue {
     return $class->set_item_lost_or_lod(
         $e, $copy_id,
         perm => 'SET_CIRC_LONG_OVERDUE',
-        status => 16, # Long Overdue
-        alt_status => OILS_COPY_STATUS_LOST,
+        status => OILS_COPY_STATUS_LONG_OVERDUE,
         ous_proc_fee => 'circ.longoverdue_materials_processing_fee',
         ous_void_od => 'circ.void_overdue_on_longoverdue',
         bill_type => 10,
@@ -861,7 +859,7 @@ sub set_item_lost_or_lod {
     $e->allowed($args{perm}, $circ->circ_lib) or return $e->die_event;
 
     return $e->die_event(OpenILS::Event->new($args{event}))
-           if ($copy->status == $args{status} || $copy->status == $args{alt_status});
+           if ($copy->status == $args{status});
 
     # ---------------------------------------------------------------------
     # fetch the related org settings
@@ -877,6 +875,11 @@ sub set_item_lost_or_lod {
     $copy->edit_date('now');
     $e->update_asset_copy($copy) or return $e->die_event;
 
+    # ---------------------------------------------------------------------
+    # we only figure fines once for lost/long-overdue events on the same
+    # circulation
+    my $stop_fines = $circ->stop_fines || '';
+    if ($stop_fines !~ /^(LOST|LONGOVERDUE)$/) {
     my $price = $U->get_copy_price($e, $copy, $copy->call_number);
 
     if( $price > 0 ) {
@@ -908,6 +911,7 @@ sub set_item_lost_or_lod {
 
     my $evt = OpenILS::Application::Circ::CircCommon->reopen_xact($e, $circ->id);
     return $evt if $evt;
+    }
 
     my $ses = OpenSRF::AppSession->create('open-ils.trigger');
     $ses->request(