From: Bill Erickson Date: Wed, 2 Feb 2022 22:32:41 +0000 (-0500) Subject: LP1952931 Receiving... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=07af6b8a1e78c0074de7dee0e9a805f61c27bf46;p=working%2FEvergreen.git LP1952931 Receiving... Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/staff/acq/asn/receive.component.html b/Open-ILS/src/eg2/src/app/staff/acq/asn/receive.component.html index a7dc22bedb..03b9053a20 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/asn/receive.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/asn/receive.component.html @@ -14,6 +14,11 @@ +
+ + +
@@ -136,7 +141,7 @@ across different vendors to match a container code.
{{li.lids.length}}
diff --git a/Open-ILS/src/eg2/src/app/staff/acq/asn/receive.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/asn/receive.component.ts index 2562066c48..4108a050ef 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/asn/receive.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/asn/receive.component.ts @@ -28,6 +28,7 @@ export class AsnReceiveComponent implements OnInit { barcode = ''; receiving = false; dryRun = true; + receiveOnScan = false; // Technically possible for one container code to match across providers. container: IdlObject; @@ -88,19 +89,22 @@ export class AsnReceiveComponent implements OnInit { {container_code: this.barcode}, {flesh: 1, flesh_fields: {acqsn: ['entries', 'provider']}} ).subscribe( - sn => this.containers.push(sn), - _ => {}, - () => { - - // TODO handle multiple containers w/ same code - if (this.containers.length === 1) { - this.container = this.containers[0]; - this.loadContainer(); - } - - const node = document.getElementById('barcode-search-input'); - (node as HTMLInputElement).select(); - } + sn => this.containers.push(sn), + _ => {}, + () => { + + // TODO handle multiple containers w/ same code + if (this.containers.length === 1) { + this.container = this.containers[0]; + this.loadContainer(); + if (this.receiveOnScan) { + this.receiveAllItems(); + } + } + + const node = document.getElementById('barcode-search-input'); + (node as HTMLInputElement).select(); + } ); } @@ -121,7 +125,11 @@ export class AsnReceiveComponent implements OnInit { _ => {}, () => { this.entries = entries; - this.grid.reload(); + + if (this.grid) { + // Hidden of receiveOnScan + this.grid.reload(); + } } ); } @@ -171,12 +179,11 @@ export class AsnReceiveComponent implements OnInit { .subscribe( resp => { this.progress.update({value: resp.progress}); - console.debug("ASN Receive returned", resp); + console.debug('ASN Receive returned', resp); this.receiveResponse = resp; }, err => {}, () => { - // this.receiving = false; } ); } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm index 7a2b7922f0..b6c87bce0b 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm @@ -4380,27 +4380,43 @@ sub asn_receive_items { push(@{$resp->{lineitems}}, $li_resp); - my $lid_ids = $e->search_acq_lineitem_detail( - [{ lineitem => $entry->lineitem, - recv_time => undef, - cancel_reason => undef # TODO delayed? - }, { - limit => $entry->item_count, - order_by => {acqlid => 'id'} - }], - {idlist => 1} - ); + # Include canceled items. + my $lids = $e->search_acq_lineitem_detail([{ + lineitem => $entry->lineitem, + recv_time => undef + }, { + flesh => 1, + flesh_fields => {acqlid => ['cancel_reason']} + }]); + + # Start by receiving un-canceled items. + # Then try "delayed" items if it comes to that. + # Apply sorting for consistency with dry-run. + + my @active_lids = sort {$a->id cmp $b->id} + grep {!$_->cancel_reason} @$lids; - if (scalar(@$lid_ids) < $entry->item_count) { + my @canceled_lids = sort {$a->id cmp $b->id} + grep { $_->cancel_reason && $U->is_true($_->cancel_reason->keep_debits) + } @$lids; + + my @potential_lids = (@active_lids, @canceled_lids); + + if (scalar(@potential_lids) < $entry->item_count) { $logger->warn(sprintf( - "ASN $asn_id entry %d found %d receivable items, but wanted %d", - $entry->id, scalar(@$lid_ids), $entry->item_count)); + "ASN $asn_id entry %d found %d receivable items for lineitem %d, but wanted %d", + $entry->id, scalar(@potential_lids), $entry->lineitem, $entry->item_count + )); } - for my $li_id (@$lid_ids) { - return $e->die_event unless receive_lineitem_detail($mgr, $li_id); + my $recv_count = 0; + + for my $lid (@potential_lids) { - my $lid = $e->retrieve_acq_lineitem_detail($li_id); + return $e->die_event unless receive_lineitem_detail($mgr, $lid->id); + + # Get an updated copy to pick up the recv_time + $lid = $e->retrieve_acq_lineitem_detail($lid->id); my $note = $lid->note ? $lid->note . "\n" : ''; $note .= "Received via shipment notification #$asn_id"; @@ -4408,9 +4424,11 @@ sub asn_receive_items { $e->update_acq_lineitem_detail($lid) or return $e->die_event; - push(@{$li_resp->{lids}}, $li_id); + push(@{$li_resp->{lids}}, $lid->id); $resp->{progress}++; $client->respond($resp); + + last if ++$recv_count >= $entry->item_count; } }