From 7e8b27000070fd63d8a90f26d302188c05be6c4c Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 10 Feb 2022 18:34:38 -0500 Subject: [PATCH] LP#1942220: exclude invalid LIs when creating PO from SL LIs that are not in a valid state to be added to a PO (e.g., if they already were) are now excluded when creating a PO from an SL. This fixes a problem where if a SL had some LIs that were added to an order, including those LIs when creating a new PO would cause the PO creation to silently fail. Signed-off-by: Galen Charlton --- .../eg2/src/app/staff/acq/po/create.component.html | 8 ++++-- .../eg2/src/app/staff/acq/po/create.component.ts | 29 +++++++++++++++++++--- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/acq/po/create.component.html b/Open-ILS/src/eg2/src/app/staff/acq/po/create.component.html index db6edbf975..1912c21e27 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/po/create.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/po/create.component.html @@ -1,9 +1,13 @@ -
-
+
+
Creating for {{lineitems.length}} line items. + + (There were {{origLiCount}} selected, but not all were in a valid state + to be added to a purchase order.) +
diff --git a/Open-ILS/src/eg2/src/app/staff/acq/po/create.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/po/create.component.ts index 145ac3cee7..d8b1ae3dcc 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/po/create.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/po/create.component.ts @@ -16,6 +16,12 @@ import {PoService} from './po.service'; import {LineitemService} from '../lineitem/lineitem.service'; import {CancelDialogComponent} from '../lineitem/cancel-dialog.component'; +const VALID_PRE_PO_LI_STATES = [ + 'new', + 'selector-ready', + 'order-ready', + 'approved' +]; @Component({ templateUrl: 'create.component.html', @@ -25,6 +31,7 @@ export class PoCreateComponent implements OnInit { initDone = false; lineitems: number[] = []; + origLiCount = 0; poName: string; orderAgency: number; provider: ComboboxEntry; @@ -50,13 +57,29 @@ export class PoCreateComponent implements OnInit { this.route.queryParamMap.subscribe((params: ParamMap) => { this.lineitems = params.getAll('li').map(id => Number(id)); + this.origLiCount = this.lineitems.length; }); - this.load().then(_ => this.initDone = true); + this.load(); } - load(): Promise { - return Promise.resolve(); + load() { + if (this.origLiCount > 0) { + const fleshed_lis: IdlObject[] = []; + this.liService.getFleshedLineitems(this.lineitems, { fromCache: false }).subscribe( + liStruct => { + fleshed_lis.push(liStruct.lineitem); + }, + err => { }, + () => { + this.lineitems = fleshed_lis.filter(li => VALID_PRE_PO_LI_STATES.includes(li.state())) + .map(li => li.id()); + this.initDone = true; + } + ); + } else { + this.initDone = true; + } } orgChange(org: IdlObject) { -- 2.11.0