LP1891369 Renewal exentions ignores overdues
authorBill Erickson <berickxx@gmail.com>
Fri, 25 Jun 2021 19:45:39 +0000 (15:45 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 01:04:27 +0000 (21:04 -0400)
Exit renewal extension logic early when the renewed circulation was
overdue.  I.e., there's no time to offer on the subsequent circulation.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Michele Morgan <mmorgan@noblenet.org>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>

Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm

index 88d2d73..ca293dc 100644 (file)
@@ -2387,11 +2387,13 @@ sub extend_renewal_due_date {
     my $start_time = DateTime::Format::ISO8601->new
         ->parse_datetime(clean_ISO8601($prev_circ->xact_start))->epoch;
 
-    my $end_time = DateTime::Format::ISO8601->new
+    my $due_time = DateTime::Format::ISO8601->new
         ->parse_datetime(clean_ISO8601($prev_circ->due_date))->epoch;
 
     my $now_time = DateTime->now->epoch;
 
+    return if $due_time < $now_time; # Renewed circ was overdue.
+
     if (my $interval = $matchpoint->renew_extend_min_interval) {
 
         my $min_duration = OpenILS::Utils::DateTime->interval_to_seconds($interval);
@@ -2400,7 +2402,7 @@ sub extend_renewal_due_date {
         return if $checkout_duration < $min_duration;
     }
 
-    my $remaining_duration = $end_time - $now_time;
+    my $remaining_duration = $due_time - $now_time;
 
     my $due_date = DateTime::Format::ISO8601->new
         ->parse_datetime(clean_ISO8601($circ->due_date));