From ac9379c07beea76dbcacbd902b1ed4a7f2a3ac11 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 8 Dec 2021 17:37:39 -0500 Subject: [PATCH] LP1952931 ASN Receiving UI Signed-off-by: Bill Erickson --- .../src/app/staff/acq/asn/receive.component.html | 123 +++++++++++++++++++-- .../eg2/src/app/staff/acq/asn/receive.component.ts | 113 ++++++++++++++++++- .../eg2/src/app/staff/acq/asn/routing.module.ts | 4 + Open-ILS/src/eg2/src/app/staff/nav.component.html | 5 + 4 files changed, 232 insertions(+), 13 deletions(-) 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 828dc61ce4..68d400581f 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 @@ -18,14 +18,123 @@ + -
-
-
{{container.container_code()}}
-
{{container.provider().name()}}
-
{{container.recv_date() | date:'short'}}
-
{{container.lading_number()}}
-
{{container.note()}}
+ + +
+
+
+ +
+
+
{{container.container_code()}}
+
+
+ +
+ +
+ +
+
+
{{entries.length}}
+
+
+
+
+ +
+
+
{{container.lading_number()}}
+
+
+ +
+
+
{{container.recv_date() | date:'short'}}
+
+
+ +
+
+
{{affectedItemsCount()}}
+
+
+
+
+ +
+
+
{{container.note()}}
+
+ + + + + + {{row.title}} + + + + + {{row.lineitem.id()}} + + + + + {{row.lineitem.purchase_order().name()}} + + + + + + + + + + + + + + + + + + + + + + + + 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 cb534990bb..0f5ad15af2 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 @@ -1,8 +1,14 @@ -import {Component, OnInit} from '@angular/core'; +import {Component, OnInit, ViewChild} from '@angular/core'; import {Router, ActivatedRoute, ParamMap} from '@angular/router'; +import {Location} from '@angular/common'; +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 {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'; @Component({ templateUrl: 'receive.component.html' @@ -11,28 +17,123 @@ export class AsnReceiveComponent implements OnInit { barcode = ''; - // Technically possible for one barcode to match across providers. + // Technically possible for one container code to match across providers. + container: IdlObject; + entries: IdlObject[] = []; containers: IdlObject[] = []; + @ViewChild('grid') private grid: GridComponent; + gridDataSource: GridDataSource = new GridDataSource(); + constructor( private route: ActivatedRoute, + private router: Router, + private ngLocation: Location, private pcrud: PcrudService, private li: LineitemService ) {} ngOnInit() { - } + this.barcode = this.route.snapshot.paramMap.get('containerCode') || ''; + if (this.barcode) { + this.findContainer(); + } - findContainer() { + this.gridDataSource.getRows = (pager: Pager, sort: any[]) => { + return from(this.entries.map(e => this.gridifyEntry(e))); + }; + } - console.log('BARCODE', this.barcode); + gridifyEntry(entry: IdlObject): any { + const li = entry.lineitem(); + const sum = li.order_summary(); + return { + entry: entry, + lineitem: li, + title: this.li.getFirstAttributeValue(li, 'title'), + author: this.li.getFirstAttributeValue(li, 'author'), + isbn: this.li.getFirstAttributeValue(li, 'isbn'), + issn: this.li.getFirstAttributeValue(li, 'issn'), + upc: this.li.getFirstAttributeValue(li, 'upc'), + recievable_count: sum.item_count() - ( + sum.recv_count() + sum.cancel_count() + ) + }; + } + findContainer() { + this.container = null; this.containers = []; + this.entries = []; this.pcrud.search('acqsn', {container_code: this.barcode}, {flesh: 1, flesh_fields: {acqsn: ['entries', 'provider']}} - ).subscribe(sn => this.containers.push(sn)); + ).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(); + } + ); + } + + loadContainer() { + if (!this.container) { return; } + + const entries = this.container.entries(); + + if (entries.length === 0) { return; } + + this.li.getFleshedLineitems(entries.map(e => e.lineitem()), {}) + .subscribe( + li_struct => { + // Flesh the lineitems directly in the shipment entry + const entry = entries.filter(e => e.lineitem() === li_struct.id)[0]; + entry.lineitem(li_struct.lineitem); + }, + _ => {}, + () => { + this.entries = entries; + this.grid.reload(); + } + ); + } + + openLi(row: any) { + let url = this.ngLocation.prepareExternalUrl( + this.router.serializeUrl( + this.router.createUrlTree( + ['/staff/acq/po/', row.lineitem.purchase_order().id()] + ) + ) + ); + + // this.router.createUrlTree() documents claim it supports + // {fragment: row.lineitem.id()}, but it's not getting added to + // the URL. Adding manually. + url += '#' + row.lineitem.id(); + + window.open(url); + } + + affectedItemsCount(): number { + if (this.entries.length === 0) { return 0; } + return this.entries + .map(e => e.item_count()) + .reduce((pv, cv) => pv + (cv || 0)); + } + + receiveAllItems() { + alert('TODO'); } } diff --git a/Open-ILS/src/eg2/src/app/staff/acq/asn/routing.module.ts b/Open-ILS/src/eg2/src/app/staff/acq/asn/routing.module.ts index ca60120f6b..b4d0f67414 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/asn/routing.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/asn/routing.module.ts @@ -12,6 +12,10 @@ import {AsnReceiveComponent} from './receive.component'; const routes: Routes = [{ path: 'receive', component: AsnReceiveComponent +}, { + path: 'receive/:containerCode', + component: AsnReceiveComponent + }]; @NgModule({ diff --git a/Open-ILS/src/eg2/src/app/staff/nav.component.html b/Open-ILS/src/eg2/src/app/staff/nav.component.html index ab959cae36..d707d3f0d2 100644 --- a/Open-ILS/src/eg2/src/app/staff/nav.component.html +++ b/Open-ILS/src/eg2/src/app/staff/nav.component.html @@ -303,6 +303,11 @@ Claim-Ready Items + + Receive Shipment + + Invoices -- 2.11.0