added support for setting shelf_expire_time to hold requests and clearing shelf expir...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 3 Nov 2009 23:16:37 +0000 (23:16 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 3 Nov 2009 23:16:37 +0000 (23:16 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@14756 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index d85af22..39f34cd 100644 (file)
@@ -2081,7 +2081,7 @@ sub attempt_checkin_hold_capture {
 
     $hold->current_copy($copy->id);
     $hold->capture_time('now');
-    $hold->shelf_time('now'
+    $self->put_hold_on_shelf($hold
         if $hold->pickup_lib == $self->editor->requestor->ws_ou;
 
     # prevent DB errors caused by fetching 
@@ -2242,7 +2242,7 @@ sub process_received_transit {
         my $hold = $self->editor->retrieve_action_hold_request($hold_transit->hold);
 
         # hold has arrived at destination, set shelf time
-        $hold->shelf_time('now');
+        $self->put_hold_on_shelf($hold);
         $self->bail_on_events($self->editor->event)
             unless $self->editor->update_action_hold_request($hold);
         return if $self->bail_out;
@@ -2261,6 +2261,28 @@ sub process_received_transit {
 }
 
 
+# ------------------------------------------------------------------
+# Sets the shelf_time and shelf_expire_time for a newly shelved hold
+# ------------------------------------------------------------------
+sub put_hold_on_shelf {
+    my($self, $hold) = @_;
+
+    $hold->shelf_time('now');
+
+    my $shelf_expire = $U->ou_ancestor_setting_value(
+        $self->circ_lib, 'circ.holds.default_shelf_expire_interval', $self->editor);
+
+    if($shelf_expire) {
+        my $seconds = OpenSRF::Utils->interval_to_seconds($shelf_expire);
+        my $expire_time = DateTime->now->add(seconds => $seconds);
+        $hold->shelf_expire_time($expire_time->strftime('%FT%T%z'));
+    }
+
+    return undef;
+}
+
+
+
 sub generate_fines {
    my $self = shift;
    my $evt;
index 498befd..3ddb8e5 100644 (file)
@@ -1232,6 +1232,7 @@ sub _reset_hold {
        $hold->clear_capture_time;
        $hold->clear_current_copy;
        $hold->clear_shelf_time;
+       $hold->clear_shelf_expire_time;
 
        $e->update_action_hold_request($hold) or return $e->event;
        $e->commit;