Fix "Retarget Local Holds" for non-holdable copies
authorThomas Berezansky <tsbere@mvlc.org>
Fri, 19 Aug 2011 13:46:40 +0000 (09:46 -0400)
committerMike Rylander <mrylander@gmail.com>
Tue, 23 Aug 2011 18:13:13 +0000 (14:13 -0400)
Specificially:

Wrap holdable check in is_true
Add check for current copy status holdable
Add check for current copy location holdable

The latter stores the fetched location for later use.
The one later use I found updated to check if the location is a reference.

The update copy code already checks if location is a reference and deals
with it properly.

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm

index f5a7479..270f7aa 100644 (file)
@@ -2307,12 +2307,17 @@ sub checkin_retarget {
     return if $self->capture eq 'nocapture'; # Not capturing holds anyway? Move on.
     return if $self->is_precat; # No holds for precats
     return unless $self->circ_lib == $self->copy->circ_lib; # Item isn't "home"? Don't check.
-    return unless $self->copy->holdable; # Not holdable, shouldn't capture holds.
+    return unless $U->is_true($self->copy->holdable); # Not holdable, shouldn't capture holds.
+    my $status = $U->copy_status($self->copy->status);
+    return unless $U->is_true($status->holdable); # Current status not holdable means no hold will ever target the item
     # Specifically target items that are likely new (by status ID)
-    unless ($self->retarget_mode =~ m/\.all/) {
-        my $status = $U->copy_status($self->copy->status)->id;
-        return unless $status == OILS_COPY_STATUS_IN_PROCESS;
+    return unless $status->id == OILS_COPY_STATUS_IN_PROCESS || $self->retarget_mode =~ m/\.all/;
+    my $location = $self->copy->location;
+    if(!ref($location)) {
+        $location = $self->editor->retrieve_asset_copy_location($self->copy->location);
+        $self->copy->location($location);
     }
+    return unless $U->is_true($location->holdable); # Don't bother on non-holdable locations
 
     # Fetch holds for the bib
     my ($result) = $holdcode->method_lookup('open-ils.circ.holds.retrieve_all_from_title')->run(
@@ -2812,7 +2817,11 @@ sub attempt_checkin_hold_capture {
 
     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);
+        my $location = $self->copy->location;
+        if(!ref($location)) {
+            $location = $self->editor->retrieve_asset_copy_location($self->copy->location);
+            $self->copy->location($location);
+        }
         if($U->is_true($location->hold_verify)) {
             $self->bail_on_events(
                 OpenILS::Event->new('HOLD_CAPTURE_DELAYED', copy_location => $location));