From 4edc3aa04947de77a883ed907726b85af52b7452 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 11 Jan 2022 16:44:55 -0500 Subject: [PATCH] LP#1942220: (follow-up) fix handling of fund balance warning This is now just a warning that requires an extra confirmation step to activate a PO, not a blocker to activation. Signed-off-by: Galen Charlton --- .../src/app/staff/acq/po/summary.component.html | 32 +++++++++++++++------- .../eg2/src/app/staff/acq/po/summary.component.ts | 27 +++++++++++++++++- 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/acq/po/summary.component.html b/Open-ILS/src/eg2/src/app/staff/acq/po/summary.component.html index 4d4b350fc6..f7407c12ec 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/po/summary.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/po/summary.component.html @@ -7,6 +7,12 @@ dialogTitle="Finalize Blanket Order?" dialogBody="This will disencumber all blanket charges and mark the PO as received."> + + +
@@ -41,24 +47,30 @@ + + + (Warning: + + + + Fund exceeds warning percent: + {{evt.payload.fund.code()}} ({{evt.payload.fund.year()}}). + + + + ) + +
+ *ngIf="evt.textcode == 'ACQ_FUND_EXCEEDS_STOP_PERCENT'; else noPrice"> Fund exceeds stop percent: {{evt.payload.fund.code()}} ({{evt.payload.fund.year()}}). - - - - Fund exceeds warning percent: - {{evt.payload.fund.code()}} ({{evt.payload.fund.year()}}). - - - diff --git a/Open-ILS/src/eg2/src/app/staff/acq/po/summary.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/po/summary.component.ts index 66d19d0694..ec02900bd0 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/po/summary.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/po/summary.component.ts @@ -17,6 +17,10 @@ import {LineitemService} from '../lineitem/lineitem.service'; import {CancelDialogComponent} from '../lineitem/cancel-dialog.component'; import {LinkInvoiceDialogComponent} from '../lineitem/link-invoice-dialog.component'; +const PO_ACTIVATION_WARNINGS = [ + 'ACQ_FUND_EXCEEDS_WARN_PERCENT' +]; + @Component({ templateUrl: 'summary.component.html', selector: 'eg-acq-po-summary' @@ -43,6 +47,7 @@ export class PoSummaryComponent implements OnInit, OnDestroy { showLegacyLinks = false; activationBlocks: EgEvent[] = []; + activationWarnings: EgEvent[] = []; activationEvent: EgEvent; nameEditEnterToggled = false; stateChangeSub: Subscription; @@ -51,6 +56,7 @@ export class PoSummaryComponent implements OnInit, OnDestroy { @ViewChild('linkInvoiceDialog') linkInvoiceDialog: LinkInvoiceDialogComponent; @ViewChild('progressDialog') progressDialog: ProgressDialogComponent; @ViewChild('confirmFinalize') confirmFinalize: ConfirmDialogComponent; + @ViewChild('confirmActivate') confirmActivate: ConfirmDialogComponent; constructor( private router: Router, @@ -183,6 +189,7 @@ export class PoSummaryComponent implements OnInit, OnDestroy { setCanActivate() { this.canActivate = null; this.activationBlocks = []; + this.activationWarnings = []; if (!(this.po().state().match(/new|pending/))) { this.canActivate = false; @@ -200,7 +207,13 @@ export class PoSummaryComponent implements OnInit, OnDestroy { ).pipe(tap(resp => { const evt = this.evt.parse(resp); - if (evt) { this.activationBlocks.push(evt); } + if (evt) { + if (PO_ACTIVATION_WARNINGS.includes(evt.textcode)) { + this.activationWarnings.push(evt); + } else { + this.activationBlocks.push(evt); + } + } })).toPromise().then(_ => { @@ -214,6 +227,18 @@ export class PoSummaryComponent implements OnInit, OnDestroy { } activatePo(noAssets?: boolean) { + if (this.activationWarnings.length) { + this.confirmActivate.open().subscribe(confirmed => { + if (!confirmed) { return; } + + this._activatePo(noAssets); + }); + } else { + this._activatePo(noAssets); + } + } + + _activatePo(noAssets?: boolean) { this.activationEvent = null; this.progressDialog.open(); this.progressDialog.update({max: this.po().lineitem_count() * 3}); -- 2.11.0