added verify hold capture (and event) and no-op checkin flags
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 10 Oct 2008 16:36:44 +0000 (16:36 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 10 Oct 2008 16:36:44 +0000 (16:36 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@10815 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/extras/ils_events.xml
Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm

index b948b41..dd991d6 100644 (file)
                should be specified within the event with a 'location' key
                </desc>
        </event>
-
-
        <event code='7018' textcode='COPY_MARKED_LOST'>
                <desc xml:lang="en-US">The requested item is already marked as lost</desc>
        </event>
+       <event code='7019' textcode='HOLD_CAPTURE_DELAYED'>
+               <desc xml:lang="en-US">Hold capture was delayed for this item</desc>
+       </event>
 
 
 
index f30ef92..1345def 100644 (file)
@@ -391,6 +391,8 @@ my @AUTOLOAD_FIELDS = qw/
     is_rental
     deposit_billing
     rental_billing
+    capture
+    noop
 /;
 
 
@@ -444,6 +446,8 @@ sub new {
     $self->desk_renewal(1) unless 
         $self->opac_renewal or $self->phone_renewal;
 
+    $self->capture('') unless $self->capture;
+
     return $self;
 }
 
@@ -1691,36 +1695,38 @@ sub do_checkin {
    # this copy can fulfill a hold or needs to be routed to a different location
    # ------------------------------------------------------------------------------
 
-    if( !$self->remote_hold and $self->attempt_checkin_hold_capture() ) {
-        return if $self->bail_out;
-
-   } else { # not needed for a hold
+    unless($self->noop) { # no-op checkins to not capture holds or put items into transit
 
-        my $circ_lib = (ref $self->copy->circ_lib) ? 
-                $self->copy->circ_lib->id : $self->copy->circ_lib;
-
-        if( $self->remote_hold ) {
-            $circ_lib = $self->remote_hold->pickup_lib;
-            $logger->warn("circulator: Copy ".$self->copy->barcode.
-                " is on a remote hold's shelf, sending to $circ_lib");
+        my $needed_for_hold = (!$self->remote_hold and $self->attempt_checkin_hold_capture());
+        return if $self->bail_out;
+    
+        unless($needed_for_hold) {
+            my $circ_lib = (ref $self->copy->circ_lib) ? 
+                    $self->copy->circ_lib->id : $self->copy->circ_lib;
+    
+            if( $self->remote_hold ) {
+                $circ_lib = $self->remote_hold->pickup_lib;
+                $logger->warn("circulator: Copy ".$self->copy->barcode.
+                    " is on a remote hold's shelf, sending to $circ_lib");
+            }
+    
+            $logger->debug("circulator: circlib=$circ_lib, workstation=".$self->editor->requestor->ws_ou);
+    
+            if( $circ_lib == $self->editor->requestor->ws_ou ) {
+    
+                $self->checkin_handle_precat();
+                return if $self->bail_out;
+    
+            } else {
+    
+                my $bc = $self->copy->barcode;
+                $logger->info("circulator: copy $bc at the wrong location, sending to $circ_lib");
+                $self->checkin_build_copy_transit($circ_lib);
+                return if $self->bail_out;
+                $self->push_events(OpenILS::Event->new('ROUTE_ITEM', org => $circ_lib));
+            }
         }
-
-        $logger->debug("circulator: circlib=$circ_lib, workstation=".$self->editor->requestor->ws_ou);
-
-      if( $circ_lib == $self->editor->requestor->ws_ou ) {
-
-            $self->checkin_handle_precat();
-            return if $self->bail_out;
-
-      } else {
-
-            my $bc = $self->copy->barcode;
-            $logger->info("circulator: copy $bc at the wrong location, sending to $circ_lib");
-            $self->checkin_build_copy_transit($circ_lib);
-            return if $self->bail_out;
-            $self->push_events(OpenILS::Event->new('ROUTE_ITEM', org => $circ_lib));
-      }
-   }
+    }
 
     $self->reshelve_copy;
     return if $self->bail_out;
@@ -1869,10 +1875,15 @@ sub checkin_build_copy_transit {
 }
 
 
+# returns true if the item was used (or may potentially be used 
+# in subsequent calls) to capture a hold.
 sub attempt_checkin_hold_capture {
     my $self = shift;
     my $copy = $self->copy;
 
+    # we've been explicitly told not to capture any holds
+    return 0 if $self->capture eq 'nocapture';
+
     # See if this copy can fulfill any holds
     my ($hold, undef, $retarget) = $holdcode->find_nearest_permitted_hold( 
         $self->editor, $copy, $self->editor->requestor );
@@ -1880,7 +1891,16 @@ sub attempt_checkin_hold_capture {
     if(!$hold) {
         $logger->debug("circulator: no potential permitted".
             "holds found for copy ".$copy->barcode);
-        return undef;
+        return 0;
+    }
+
+    if($self->capture ne 'capture') {
+        # see if this item is in a hold-capture-delay location
+        my $location = $self->editor->retrieve_asset_copy_location($self->copy->location);
+        if($U->is_true($location->hold_verify)) {
+            $self->bail_on_events(OpenILS::Event->new('HOLD_CAPTURE_DELAYED'));
+            return 1;
+        }
     }
 
     $self->retarget($retarget);
@@ -1905,12 +1925,12 @@ sub attempt_checkin_hold_capture {
     $self->hold($hold);
     $self->checkin_changed(1);
 
-    return 1 if $self->bail_out;
+    return 0 if $self->bail_out;
 
     if( $hold->pickup_lib == $self->editor->requestor->ws_ou ) {
 
         # This hold was captured in the correct location
-    $copy->status(OILS_COPY_STATUS_ON_HOLDS_SHELF);
+        $copy->status(OILS_COPY_STATUS_ON_HOLDS_SHELF);
         $self->push_events(OpenILS::Event->new('SUCCESS'));
 
         #$self->do_hold_notify($hold->id);
@@ -1921,10 +1941,9 @@ sub attempt_checkin_hold_capture {
         # Hold needs to be picked up elsewhere.  Build a hold
         # transit and route the item.
         $self->checkin_build_hold_transit();
-    $copy->status(OILS_COPY_STATUS_IN_TRANSIT);
-        return 1 if $self->bail_out;
-        $self->push_events(
-            OpenILS::Event->new('ROUTE_ITEM', org => $hold->pickup_lib));
+        $copy->status(OILS_COPY_STATUS_IN_TRANSIT);
+        return 0 if $self->bail_out;
+        $self->push_events(OpenILS::Event->new('ROUTE_ITEM', org => $hold->pickup_lib));
     }
 
     # make sure we save the copy status