From 1fa1671497710818dd72ecf12284913284c5eb16 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 24 Feb 2022 17:05:20 -0500 Subject: [PATCH] LP1904036 Improve bill voiding handling (avoid repeat confirmation) Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- .../src/app/staff/circ/patron/bills.component.ts | 29 ++++++++++++------- 1 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/bills.component.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/bills.component.ts index 94404bc..7df7b61 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/bills.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/bills.component.ts @@ -354,7 +354,10 @@ export class BillsComponent implements OnInit, AfterViewInit { const payments = []; this.gridDataSource.data.forEach(row => { if (row.paymentPending) { - payments.push([row.id, row.paymentPending]); + // NOTE passing the pending payment amount as a string + // instead of a number bypasses some funky rounding + // errors on the server side. + payments.push([row.id, row.paymentPending.toFixed(2)]); } }); return payments; @@ -551,9 +554,10 @@ export class BillsComponent implements OnInit, AfterViewInit { const billIds = []; let cents = 0; - from(xactIds) + console.debug('Voiding transactions', xactIds); + // Grab the billings - .pipe(concatMap(xactId => { + from(xactIds).pipe(concatMap(xactId => { return this.pcrud.search('mb', {xact: xactId}, {}, {authoritative: true}) .pipe(tap(billing => { if (billing.voided() === 'f') { @@ -561,24 +565,27 @@ export class BillsComponent implements OnInit, AfterViewInit { billIds.push(billing.id()); } })); - })) + })).toPromise() + // Confirm the void action - .pipe(concatMap(_ => { + .then(_ => { this.voidAmount = cents / 100; - return this.voidBillsDialog.open(); - })) + return this.voidBillsDialog.open().toPromise(); + }) + // Do the void - .pipe(concatMap(confirmed => { + .then(confirmed => { if (!confirmed) { return empty(); } return this.net.requestWithParamList( 'open-ils.circ', 'open-ils.circ.money.billing.void', [this.auth.token()].concat(billIds) // positional params - ); - })) + ).toPromise(); + }) + // Clean up and refresh data - .subscribe(resp => { + .then(resp => { if (!resp || this.reportError(resp)) { return; } this.sessionVoided = (this.sessionVoided * 100 + cents) / 100; -- 1.7.2.5