From: Bill Erickson Date: Tue, 22 Jun 2021 18:06:00 +0000 (-0400) Subject: LP1929741 Blanket order finalizing; improved charges handling X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ac35eddd8ce95e5a2c637806b789225be0a72bdc;p=evergreen%2Fmasslnc.git LP1929741 Blanket order finalizing; improved charges handling Signed-off-by: Bill Erickson Signed-off-by: Galen Charlton Signed-off-by: Jane Sandberg --- diff --git a/Open-ILS/src/eg2/src/app/staff/acq/po/charges.component.html b/Open-ILS/src/eg2/src/app/staff/acq/po/charges.component.html index a51e067b90..7ee04843df 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/po/charges.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/po/charges.component.html @@ -51,7 +51,7 @@
{{charge.estimated_cost() | currency}}
diff --git a/Open-ILS/src/eg2/src/app/staff/acq/po/charges.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/po/charges.component.ts index 3087aed6a1..288c4b1cc9 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/po/charges.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/po/charges.component.ts @@ -50,7 +50,8 @@ export class PoChargesComponent implements OnInit { } saveCharge(charge: IdlObject) { - if (!charge.inv_item_type()) { return; } + if (!charge.inv_item_type() || !charge.fund()) { return; } + if (typeof charge.estimated_cost() !== 'number') { return; } charge.id(undefined); this.pcrud.create(charge).toPromise() 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 e89d43e3a6..262b020549 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 @@ -1,6 +1,11 @@ + +
@@ -202,6 +207,13 @@ Activate Order + + | + + check_circle + Finalize Blanket Order + +
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 2cef47f5fe..8d28763b29 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 @@ -39,6 +39,7 @@ export class PoSummaryComponent implements OnInit { showNotes = false; zeroCopyActivate = false; canActivate: boolean = null; + canFinalize = false; activationBlocks: EgEvent[] = []; activationEvent: EgEvent; @@ -46,6 +47,7 @@ export class PoSummaryComponent implements OnInit { @ViewChild('cancelDialog') cancelDialog: CancelDialogComponent; @ViewChild('progressDialog') progressDialog: ProgressDialogComponent; + @ViewChild('confirmFinalize') confirmFinalize: ConfirmDialogComponent; constructor( private router: Router, @@ -85,7 +87,8 @@ export class PoSummaryComponent implements OnInit { {purchase_order: this.poId}, {}, {idlist: true, atomic: true} ).toPromise().then(ids => this.ediMessageCount = ids.length); - }).then(_ => { + }) + .then(_ => { // Invoice count return this.net.request('open-ils.acq', @@ -94,7 +97,9 @@ export class PoSummaryComponent implements OnInit { null, null, {id_list: true} ).toPromise().then(ids => this.invoiceCount = ids.length); - }).then(_ => this.setCanActivate()); + }) + .then(_ => this.setCanActivate()) + .then(_ => this.setCanFinalize()); } // Can run via Enter or blur. If it just ran via Enter, avoid @@ -226,6 +231,42 @@ export class PoSummaryComponent implements OnInit { } }); } + + setCanFinalize() { + + if (this.po().state() === 'received') { return; } + + var invTypes = []; + + // get the unique set of invoice item type IDs + this.po().po_items().forEach(item => { + if (!invTypes.includes(item.inv_item_type())) { + invTypes.push(item.inv_item_type()); + } + }); + + if (invTypes.length == 0) { return; } + + this.pcrud.search('aiit', + {code: invTypes, blanket: 't'}, {limit: 1}) + .subscribe(_ => this.canFinalize = true); + } + + finalizePo() { + + this.confirmFinalize.open().subscribe(confirmed => { + if (!confirmed) { return; } + + this.net.request('open-ils.acq', + 'open-ils.acq.purchase_order.blanket.finalize', + this.auth.token(), this.poId + ).subscribe(resp => { + if (Number(resp) === 1) { + location.href = location.href; + } + }); + }); + } }