LP#1801191: ensure recall does not extend due date
authorJeff Davis <jdavis@sitka.bclibraries.ca>
Thu, 1 Nov 2018 23:29:36 +0000 (16:29 -0700)
committerDan Wells <dbw2@calvin.edu>
Fri, 22 Feb 2019 20:00:47 +0000 (15:00 -0500)
Signed-off-by: Jeff Davis <jdavis@sitka.bclibraries.ca>
Signed-off-by: Remington Steed <rjs7@calvin.edu>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm
Open-ILS/src/perlmods/lib/OpenILS/Utils/HoldTargeter.pm

index 872b78d..4af8dae 100644 (file)
@@ -1675,6 +1675,8 @@ sub process_recall {
         my $circ = $circs->[0];
         $log->info("Recalling circ ID : " . $circ->id);
 
+        my $old_due_date = DateTime::Format::ISO8601->parse_datetime(cleanse_ISO8601($circ->due_date))->iso8601();
+
         # Give the user a new due date of either a full recall threshold,
         # or the return interval, whichever is further in the future
         my $threshold_date = DateTime::Format::ISO8601->parse_datetime(clean_ISO8601($circ->xact_start))->add(seconds => interval_to_seconds($recall_threshold))->iso8601();
@@ -1682,6 +1684,12 @@ sub process_recall {
             $return_date = $threshold_date;
         }
 
+        # But if the new due date is later than the old one,
+        # keep the old one.
+        if (DateTime->compare(DateTime::Format::ISO8601->parse_datetime($return_date), DateTime::Format::ISO8601->parse_datetime($old_due_date)) == 1) {
+            $return_date = $old_due_date;
+        }
+
         my $update_fields = {
             due_date => $return_date,
             renewal_remaining => 0,
index a42638c..957fb25 100644 (file)
@@ -1181,6 +1181,8 @@ sub process_recalls {
 
     $self->log_hold("recalling circ ".$circ->id);
 
+    my $old_due_date = DateTime::Format::ISO8601->parse_datetime(cleanse_ISO8601($circ->due_date))->iso8601();
+
     # Give the user a new due date of either a full recall threshold,
     # or the return interval, whichever is further in the future.
     my $threshold_date = DateTime::Format::ISO8601
@@ -1197,6 +1199,14 @@ sub process_recalls {
         $return_date = $threshold_date;
     }
 
+    # But if the new due date is later than the old one,
+    # keep the old one.
+    if (DateTime->compare(
+        DateTime::Format::ISO8601->parse_datetime($return_date),
+        DateTime::Format::ISO8601->parse_datetime($old_due_date)) == 1) { 
+        $return_date = $old_due_date;
+    }
+
     my %update_fields = (
         due_date => $return_date,
         renewal_remaining => 0,