LP 1198465: Set restored overdue timestamp to time of last overdue
authorDan Wells <dbw2@calvin.edu>
Thu, 28 May 2015 17:54:26 +0000 (13:54 -0400)
committerBen Shum <bshum@biblio.org>
Tue, 28 Jul 2015 20:24:53 +0000 (16:24 -0400)
When we have our settings configured to generate new overdues on lost
item return, we start generation after the most recent overdue fine.
Because of this, we need the restored fine to be dated in the past,
which in turn allows the fine generator to apply catch-up fines as
expected.

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircCommon.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm

index 4dac75e..541a5a8 100644 (file)
@@ -198,7 +198,7 @@ sub reopen_xact {
 
 
 sub create_bill {
-    my($class, $e, $amount, $btype, $type, $xactid, $note) = @_;
+    my($class, $e, $amount, $btype, $type, $xactid, $note, $billing_ts) = @_;
 
     $logger->info("The system is charging $amount [$type] on xact $xactid");
     $note ||= 'SYSTEM GENERATED';
@@ -208,6 +208,7 @@ sub create_bill {
     my $bill = Fieldmapper::money::billing->new;
     $bill->xact($xactid);
     $bill->amount($amount);
+    $bill->billing_ts($billing_ts);
     $bill->billing_type($type); 
     $bill->btype($btype); 
     $bill->note($note);
index 44719ef..9b20a97 100644 (file)
@@ -3813,12 +3813,15 @@ sub checkin_handle_lost_or_lo_now_found_restore_od {
     # restore those overdue charges voided when item was set to lost
     # ------------------------------------------------------------------
 
-    my $ods = $self->editor->search_money_billing(
+    my $ods = $self->editor->search_money_billing([
         {
             xact => $self->circ->id,
             btype => 1
+        },
+        {
+            order_by => {mb => 'billing_ts desc'}
         }
-    );
+    ]);
 
     $logger->debug("returning ".scalar(@$ods)." overdue charges pre-$tag");
     # Because actual users get up to all kinds of unexpectedness, we
@@ -3852,7 +3855,8 @@ sub checkin_handle_lost_or_lo_now_found_restore_od {
             $ods->[0]->btype(),
             $ods->[0]->billing_type(),
             $self->circ->id(),
-            "System: $tag RETURNED - OVERDUES REINSTATED"
+            "System: $tag RETURNED - OVERDUES REINSTATED",
+            $ods->[0]->billing_ts() # date this restoration the same as the last overdue (for possible subsequent fine generation)
         );
     }
 }