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};
}
}