__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/
$org ||= $e->requestor->ws_ou;
+ $logger->info("In fetch_captured_holds VSL");
+
my $current_copy = { '!=' => undef };
$current_copy = { '=' => $match_copy } if $match_copy;
}
};
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
$$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) {
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;
$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.