LP#1422379 Fix backdate voiding for new billing timestamps
authorDan Wells <dbw2@calvin.edu>
Mon, 16 Feb 2015 16:09:45 +0000 (11:09 -0500)
committerDan Wells <dbw2@calvin.edu>
Tue, 28 Jul 2015 21:21:53 +0000 (17:21 -0400)
With the new timestamp style, the extra step of jumping ahead one fine
interval when selecting fines to void is unnecessary.

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

index 30988de..394b73b 100644 (file)
@@ -38,28 +38,15 @@ sub void_or_zero_overdues {
 
     if( $opts->{backdate} ) {
         my $backdate = $opts->{backdate};
-        # ------------------------------------------------------------------
-        # Fines for overdue materials are assessed up to, but not including,
-        # one fine interval after the fines are applicable.  Here, we add
-        # one fine interval to the backdate to ensure that we are not 
-        # voiding fines that were applicable before the backdate.
-        # ------------------------------------------------------------------
-
-        # if there is a raw time component (e.g. from postgres), 
-        # turn it into an interval that interval_to_seconds can parse
-        my $duration = $circ->fine_interval;
-        $duration =~ s/(\d{2}):(\d{2}):(\d{2})/$1 h $2 m $3 s/o;
-        my $interval = OpenSRF::Utils->interval_to_seconds($duration);
-
-        my $date = DateTime::Format::ISO8601->parse_datetime(cleanse_ISO8601($backdate));
+        my $backdate_clean = cleanse_ISO8601($backdate);
+        my $backdate_dt = DateTime::Format::ISO8601->parse_datetime($backdate_clean);
         my $due_date = DateTime::Format::ISO8601->parse_datetime(cleanse_ISO8601($circ->due_date))->epoch;
         my $grace_period = extend_grace_period( $class, $circ->circ_lib, $circ->due_date, OpenSRF::Utils->interval_to_seconds($circ->grace_period), $e);
-        if($date->epoch <= $due_date + $grace_period) {
+        if($backdate_dt->epoch <= $due_date + $grace_period) {
             $logger->info("backdate $backdate is within grace period, voiding all");
         } else {
-            $backdate = $U->epoch2ISO8601($date->epoch + $interval);
             $logger->info("applying backdate $backdate in overdue voiding");
-            $$bill_search{billing_ts} = {'>=' => $backdate};
+            $$bill_search{billing_ts} = {'>=' => $backdate_clean};
         }
     }