Booking workflow fix for reservation op-capture
authorsenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 14 Apr 2010 18:54:15 +0000 (18:54 +0000)
committersenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 14 Apr 2010 18:54:15 +0000 (18:54 +0000)
Only capture items for reservation upon checkin if the reservation in question
is starting within the interval defined by the elbow room value.  Elbow room
value can be controller per booking resource type, or if none is set, an
org unit setting defines the elbow room interval.  This allows new
circulations to happen more easily between the time a reservation is made and
the time a reservation actually starts.

git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_6@16238 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Booking.pm

index 91f5ddb..65e5e43 100644 (file)
@@ -778,22 +778,37 @@ sub could_capture {
     return $e->die_event unless $e->checkauth;
     return $e->die_event unless $e->allowed("CAPTURE_RESERVATION");
 
+    my $dt_parser = new DateTime::Format::ISO8601;
+    my $now = now DateTime; # sic
     my $res = get_uncaptured_bresv_for_brsrc($e, {"barcode" => $barcode});
+
     if ($res and keys %$res) {
         my $id;
         while ((undef, $id) = each %$res) {
-            $client->respond(
-                $e->retrieve_booking_reservation([
-                    $id, {
-                        "flesh" => 1, "flesh_fields" => {
-                            "bresv" => [qw(
-                                usr target_resource_type
-                                target_resource current_resource
-                            )]
-                        }
+            my $bresv = $e->retrieve_booking_reservation([
+                $id, {
+                    "flesh" => 1, "flesh_fields" => {
+                        "bresv" => [qw(
+                            usr target_resource_type
+                            target_resource current_resource
+                        )]
                     }
-                ])
+                }
+            ]);
+            my $elbow_room = interval_to_seconds(
+                $bresv->target_resource_type->elbow_room ||
+                $U->ou_ancestor_setting_value(
+                    $bresv->pickup_lib,
+                    "circ.booking_reservation.default_elbow_room"
+                ) ||
+                "0 seconds"
             );
+            my $start_time = $dt_parser->parse_datetime(
+                clense_ISO8601($bresv->start_time)
+            );
+
+            $client->respond($bresv) if
+                $now >= $start_time->subtract("seconds" => $elbow_room);
         }
     }
     $e->disconnect;