From: Thomas Berezansky Date: Thu, 8 Mar 2012 14:25:22 +0000 (-0500) Subject: Use circ lib for finding nearest hold on renew X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Ftsbere%2Fnearest_permitted_opac_renewal;p=working%2FEvergreen.git Use circ lib for finding nearest hold on renew This solves problems with the following situation: Re-use circ library for opac renewals Block renew if item is needed for holds Item is age protected Patron with item has home library outside of the protect range Patron's home library has 10+ holds the item matches The end result is 10 holds are looked at, skipped due to age protection, and the system decides "nope, not needed for a hold". This does not help if the patron shows up in person at their home library, nor does it help when not re-using the original circ library for OPAC renewals. Signed-off-by: Thomas Berezansky --- 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 731131dec3..85cec04466 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm @@ -3623,7 +3623,7 @@ sub run_renew_permit { if ($U->ou_ancestor_setting_value($self->circ_lib, 'circ.block_renews_for_holds')) { my ($hold, undef, $retarget) = $holdcode->find_nearest_permitted_hold( - $self->editor, $self->copy, $self->editor->requestor, 1 + $self->editor, $self->copy, $self->editor->requestor, 1, $self->circ_lib ); $self->push_events(new OpenILS::Event("COPY_NEEDED_FOR_HOLD")) if $hold; } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm index 5c840c5d10..3ead7e68fd 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm @@ -2863,11 +2863,14 @@ sub find_nearest_permitted_hold { my $copy = shift; # copy to target my $user = shift; # staff my $check_only = shift; # do no updates, just see if the copy could fulfill a hold + my $force_ou = shift; # if set, use this OU instead of the work OU my $evt = OpenILS::Event->new('ACTION_HOLD_REQUEST_NOT_FOUND'); my $bc = $copy->barcode; + $force_ou = $user->ws_ou unless $force_ou; + # find any existing holds that already target this copy my $old_holds = $editor->search_action_hold_request( { current_copy => $copy->id, @@ -2876,17 +2879,17 @@ sub find_nearest_permitted_hold { } ); - my $hold_stall_interval = $U->ou_ancestor_setting_value($user->ws_ou, OILS_SETTING_HOLD_SOFT_STALL); + my $hold_stall_interval = $U->ou_ancestor_setting_value($force_ou, OILS_SETTING_HOLD_SOFT_STALL); - $logger->info("circulator: searching for best hold at org ".$user->ws_ou. + $logger->info("circulator: searching for best hold at org ".$force_ou. " and copy $bc with a hold stalling interval of ". ($hold_stall_interval || "(none)")); - my $fifo = $U->ou_ancestor_setting_value($user->ws_ou, 'circ.holds_fifo'); + my $fifo = $U->ou_ancestor_setting_value($force_ou, 'circ.holds_fifo'); # search for what should be the best holds for this copy to fulfill my $best_holds = $U->storagereq( "open-ils.storage.action.hold_request.nearest_hold.atomic", - $user->ws_ou, $copy->id, 10, $hold_stall_interval, $fifo ); + $force_ou, $copy->id, 10, $hold_stall_interval, $fifo ); unless(@$best_holds) {