From e73ac7870b2f3eb7df696474a4b8cf4c6e8bdea2 Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Fri, 19 Aug 2011 09:46:40 -0400 Subject: [PATCH] Fix "Retarget Local Holds" for non-holdable copies 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 Signed-off-by: Mike Rylander --- .../lib/OpenILS/Application/Circ/Circulate.pm | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm index f5a7479cfb..270f7aa654 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm @@ -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)); -- 2.11.0