From: Galen Charlton Date: Tue, 14 Dec 2021 02:15:51 +0000 (-0500) Subject: LP#1942220: fixes to PO item deletion X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a03ae140bcd361bf1cd98572f7fd8c4abc597f4b;p=working%2FEvergreen.git LP#1942220: fixes to PO item deletion - use an open-ils.acq method rather than PCRUD - display the delete button under more circumstances Signed-off-by: Galen Charlton --- 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 6e4d85011e..27bf722bc2 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 @@ -82,7 +82,7 @@ + (click)="removeCharge(charge)" *ngIf="canDelete(charge)" i18n>Remove 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 705be70ea4..21464f993c 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 @@ -113,6 +113,27 @@ export class PoChargesComponent implements OnInit, OnDestroy { return true; // we're likely OK to disencumber } + canDelete(charge: IdlObject): boolean { + if (!this.po()) { + return false; + } + + const debit = charge.fund_debit(); + if (debit && debit.encumbrance() === 'f') { + return false; // if it's expended, we can't just delete it + } + if (debit.invoice_entry()) { + return false; // we shouldn't actually be a po_item that is + // linked to an invoice_entry, but if we are, + // do NOT touch + } + if (debit.invoice_items() && debit.invoice_items().length) { + return false; // we're linked to an invoice item, so the disposition of the + // invoice entry should govern things + } + return true; // we're likely OK to delete + } + disencumberCharge(charge: IdlObject) { this.disencumberChargeDialog.charge = charge; this.disencumberChargeDialog.open().subscribe(doIt => { @@ -135,8 +156,14 @@ export class PoChargesComponent implements OnInit, OnDestroy { ); if (!charge.isnew()) { - this.pcrud.remove(charge).toPromise() - .then(_ => this.poService.refreshOrderSummary()); + return this.net.request( + 'open-ils.acq', + 'open-ils.acq.po_item.delete', + this.auth.token(), charge.id() + ).toPromise().then(res => { + const evt = this.evt.parse(res); + if (evt) { return Promise.reject(evt + ''); } + }).then(_ => this.poService.refreshOrderSummary(true)); } } }