From 9c90558644e7154a0a68505f719c698f1826954d Mon Sep 17 00:00:00 2001 From: Jeff Davis Date: Thu, 1 Nov 2018 16:29:36 -0700 Subject: [PATCH] LP#1801191: ensure recall does not extend due date Signed-off-by: Jeff Davis Signed-off-by: Remington Steed Signed-off-by: Dan Wells --- .../OpenILS/Application/Storage/Publisher/action.pm | 8 ++++++++ .../src/perlmods/lib/OpenILS/Utils/HoldTargeter.pm | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm index 872b78d795..4af8dae616 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm @@ -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, diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/HoldTargeter.pm b/Open-ILS/src/perlmods/lib/OpenILS/Utils/HoldTargeter.pm index a42638c806..957fb25a8b 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Utils/HoldTargeter.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Utils/HoldTargeter.pm @@ -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, -- 2.43.2