Resolve LP893448: Prevent hold expiration in past.
authorJason Stephenson <jstephenson@mvlc.org>
Wed, 14 Nov 2012 16:49:49 +0000 (11:49 -0500)
committerBen Shum <bshum@biblio.org>
Tue, 18 Dec 2012 05:57:19 +0000 (00:57 -0500)
If a hold is placed with an expiration date in the past, the
expire_time of the hold will be reset using the hold expiration
interval settings.

Likewise, if a hold is changed to have an expiration date in the
past, the hold expiration date will be recalculated using the
hold expiration interval settings.

Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm

index 617f4de..3e32d62 100644 (file)
@@ -315,6 +315,9 @@ sub create_hold {
         }
     }
 
+        # Check for hold expiration in the past, and set it to empty string.
+        $hold->expire_time(undef) if ($hold->expire_time && $U->datecmp($hold->expire_time) == -1);
+
     # set the configured expire time
     unless($hold->expire_time) {
         $hold->expire_time(calculate_expire_time($recipient->home_ou));
@@ -1008,6 +1011,13 @@ sub update_hold_impl {
         $hold->clear_prev_check_time;
     }
 
+    # If the hold_expire_time is in the past && is not equal to the
+    # original expire_time, then reset the expire time to be in the
+    # future.
+    if ($hold->expire_time && $U->datecmp($hold->expire_time) == -1 && $U->datecmp($hold->expire_time, $orig_hold->expire_time) != 0) {
+        $hold->expire_time(calculate_expire_time($hold->request_lib));
+    }
+
     $e->update_action_hold_request($hold) or return $e->die_event;
     $e->commit;