From: Bill Erickson Date: Wed, 29 Oct 2014 21:10:05 +0000 (-0400) Subject: KMain-808 CHS report missing holds where pickup location has been changed. Modified... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ee7c45c1afa1f6ece6db2331367aec1f8c9d0e31;p=working%2FEvergreen.git KMain-808 CHS report missing holds where pickup location has been changed. Modified Holds.pm and circ.properties so that the CHS report run daily by staff includes holds with a changed pickup location. In addition to the cancelled/expired holds it also shows a hold that has been moved so that staffknow to pull it and send it on to the changed pickup location. Signed-off-by: Victoria Lewis Cross-port: 6095afa --- 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 3808a3244d..1dee83dae3 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm @@ -2104,6 +2104,7 @@ __PACKAGE__->register_method( __PACKAGE__->register_method( method => 'fetch_captured_holds', api_name => 'open-ils.circ.captured_holds.id_list.expired_on_shelf.retrieve', + stream => 1, authoritative => 1, signature => q/ @@ -2148,6 +2149,8 @@ sub fetch_captured_holds { $org ||= $e->requestor->ws_ou; + $logger->info("In fetch_captured_holds VSL"); + my $current_copy = { '!=' => undef }; $current_copy = { '=' => $match_copy } if $match_copy; @@ -2172,12 +2175,25 @@ sub fetch_captured_holds { } }; if($self->api_name =~ /expired/) { + + $logger->info("in if(api_name =~/expired/"); $query->{'where'}->{'+alhr'}->{'-or'} = { shelf_expire_time => { '<' => 'today'}, cancel_time => { '!=' => undef }, - }; + + }; } my $hold_ids = $e->json_query( $query ); + + if ($self->api_name =~ /wrong_shelf/) { + # fetch holds whose current_shelf_lib is $org, but whose pickup + # lib is some other org unit. Ignore already-retrieved holds. + my $wrong_shelf = + pickup_lib_changed_on_shelf_holds( + $e, $org, [map {$_->{id}} @$hold_ids]); + # match the layout of other items in $hold_ids + push (@$hold_ids, {id => $_}) for @$wrong_shelf; + } if ($self->api_name =~ /wrong_shelf/) { # fetch holds whose current_shelf_lib is $org, but whose pickup @@ -2236,7 +2252,7 @@ sub print_expired_holds_stream { $$params{org_id} = (defined $$params{org_id}) ? $$params{org_id}: $e->requestor->ws_ou; my @hold_ids = $self->method_lookup( - "open-ils.circ.captured_holds.id_list.expired_on_shelf.retrieve" + "open-ils.circ.captured_holds.id_list.expired_on_shelf_or_wrong_shelf.retrieve" )->run($auth, $params->{"org_id"}); if (!@hold_ids) { @@ -3666,7 +3682,7 @@ sub clear_shelf_process { my $copy_status = $U->ou_ancestor_setting_value($org_id, 'circ.holds.clear_shelf.copy_status'); my @hold_ids = $self->method_lookup( - "open-ils.circ.captured_holds.id_list.expired_on_shelf.retrieve" + "open-ils.circ.captured_holds.id_list.expired_on_shelf.retrieve" )->run($auth, $org_id, $match_copy); $e->xact_begin; @@ -3763,6 +3779,45 @@ sub clear_shelf_process { $client->respond_complete; } } + # returns IDs for holds that are on the holds shelf but + # have had their pickup_libs change while on the shelf. + + + sub pickup_lib_changed_on_shelf_holds { + my $e = shift; + my $org_id = shift; + my $ignore_holds = shift; + $ignore_holds = [$ignore_holds] if !ref($ignore_holds); + + my $query = { + select => { alhr => ['id'] }, + from => { + alhr => { + acp => { + field => 'id', + fkey => 'current_copy' + }, + } + }, + where => { + '+acp' => { status => OILS_COPY_STATUS_ON_HOLDS_SHELF }, + '+alhr' => { + capture_time => { "!=" => undef }, + fulfillment_time => undef, + current_shelf_lib => $org_id, + pickup_lib => {'!=' => {'+alhr' => 'current_shelf_lib'}} + } + } + }; + + $query->{where}->{'+alhr'}->{id} = + {'not in' => $ignore_holds} if @$ignore_holds; + + my $hold_ids = $e->json_query($query); + return [ map { $_->{id} } @$hold_ids ]; +} + + # returns IDs for holds that are on the holds shelf but # have had their pickup_libs change while on the shelf.