From: Bill Erickson Date: Wed, 2 Feb 2022 18:04:34 +0000 (-0500) Subject: LP1952931 Receiving... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=42a4a8bc3ea065a7e06e8e1564bebc6065a4697e;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 68d400581f..ec72062935 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 @@ -111,9 +111,27 @@ across different vendors to match a container code. - +
+
+
Receiving Items (Dry Run)
+
+
    +
  • + +
  • +
+
+
+
+ + + + + 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 0f5ad15af2..aea6f16bb0 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 @@ -5,10 +5,13 @@ import {Observable, Observer, of, from} from 'rxjs'; import {tap} from 'rxjs/operators'; import {IdlObject} from '@eg/core/idl.service'; import {PcrudService} from '@eg/core/pcrud.service'; +import {NetService} from '@eg/core/net.service'; +import {AuthService} from '@eg/core/auth.service'; import {LineitemService} from '../lineitem/lineitem.service'; import {Pager} from '@eg/share/util/pager'; import {GridDataSource, GridColumn, GridCellTextGenerator} from '@eg/share/grid/grid'; import {GridComponent} from '@eg/share/grid/grid.component'; +import {ProgressInlineComponent} from '@eg/share/dialog/progress-inline.component'; @Component({ templateUrl: 'receive.component.html' @@ -16,6 +19,8 @@ import {GridComponent} from '@eg/share/grid/grid.component'; export class AsnReceiveComponent implements OnInit { barcode = ''; + receiving = false; + dryRun = true; // Technically possible for one container code to match across providers. container: IdlObject; @@ -23,6 +28,8 @@ export class AsnReceiveComponent implements OnInit { containers: IdlObject[] = []; @ViewChild('grid') private grid: GridComponent; + @ViewChild('progress') private progress: ProgressInlineComponent; + gridDataSource: GridDataSource = new GridDataSource(); constructor( @@ -30,6 +37,8 @@ export class AsnReceiveComponent implements OnInit { private router: Router, private ngLocation: Location, private pcrud: PcrudService, + private net: NetService, + private auth: AuthService, private li: LineitemService ) {} @@ -132,8 +141,27 @@ export class AsnReceiveComponent implements OnInit { .reduce((pv, cv) => pv + (cv || 0)); } - receiveAllItems() { - alert('TODO'); + receiveAllItems(dryRun?: boolean) { + this.receiving = true; + this.dryRun = dryRun; + + setTimeout(() => // Allow time to render + this.progress.update({value: 0, max: this.entries.length})); + + let method = 'open-ils.acq.shipment_notification.receive_items'; + if (dryRun) { method += '.dry_run'; } + + this.net.request('open-ils.acq', + method, this.auth.token(), this.container.id()) + .subscribe( + resp => { + console.debug("ASN Receive returned", 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 62cd372577..f03eb5f6b3 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm @@ -4321,5 +4321,81 @@ sub li_existing_copies { } +__PACKAGE__->register_method( + method => 'asn_receive_items', + api_name => 'open-ils.acq.shipment_notification.receive_items', + max_bundle_count => 1, + signature => { + desc => q/ + Mark items from a shipment notification as received. + /, + params => [ + {desc => 'Authentication token', type => 'string'}, + {desc => 'Shipment Notification ID', type => 'number'} + ], + return => {desc => q/Stream of status updates, event on error/} + } +); + +__PACKAGE__->register_method( + method => 'asn_receive_items', + api_name => 'open-ils.acq.shipment_notification.receive_items.dry_run', + max_bundle_count => 1, + signature => q/dry_run variant of open-ils.acq.shipment_notification.receive_items/ +); + +sub asn_receive_items { + my ($self, $client, $auth, $asn_id) = @_; + + my $e = new_editor(xact => 1, authtoken => $auth); + return $e->die_event unless $e->checkauth; + + my $mgr = + OpenILS::Application::Acq::BatchManager->new(editor => $e, conn => $client); + + my $asn = $e->retrieve_acq_shipment_notification([$asn_id, + {flesh => 1, flesh_fields => {acqsn => ['provider', 'entries']}} + ]) || return $e->die_event; + + return $e->die_event unless + $e->allowed('MANAGE_SHIPMENT_NOTIFICATION', $asn->provider->owner); + + for my $entry (@{$asn->entries}) { + + 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} + ); + + if (scalar(@$lid_ids) < $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)); + } + + for my $li_id (@$lid_ids) { + return $e->die_event unless receive_lineitem_detail($mgr, $li_id); + $mgr->respond; + } + } + + if ($self->api_name =~ /dry_run/) { + $e->rollback; + } else { + $e->commit; + } + + $mgr->respond_complete; + + undef; +} + + 1;