LP1904036 Refund shows styled neg. amount; other fixes
authorBill Erickson <berickxx@gmail.com>
Thu, 24 Feb 2022 16:38:39 +0000 (11:38 -0500)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:13:41 +0000 (20:13 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <js7389@princeton.edu>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/circ/patron/bills.component.html
Open-ILS/src/eg2/src/app/staff/circ/patron/bills.component.ts

index 7e5a27b..7d540cc 100644 (file)
 <eg-grid #billGrid idlClass="mbt" [dataSource]="gridDataSource"
   persistKey="circ.patron.bills" [sortable]="true" 
   (onRowActivate)="showStatement($event)"
+  [cellClassCallback]="cellClassCallback"
   [reloadOnColumnChange]="true"
   [showDeclaredFieldsOnly]="true"
   [rowClassCallback]="rowClassCallback"
index b125285..94404bc 100644 (file)
@@ -60,6 +60,7 @@ export class BillsComponent implements OnInit, AfterViewInit {
     cellTextGenerator: GridCellTextGenerator;
     rowClassCallback: (row: any) => string;
     rowFlairCallback: (row: any) => GridRowFlairEntry;
+    cellClassCallback: (row: any, col: GridColumn) => string;
 
     nowTime: number = new Date().getTime();
 
@@ -96,6 +97,16 @@ export class BillsComponent implements OnInit, AfterViewInit {
 
     ngOnInit() {
 
+        this.cellClassCallback = (row: any, col: GridColumn): string => {
+            if (col.name === 'paymentPending') {
+                const val = this.billGrid.context.getRowColumnBareValue(row, col);
+                if (val < 0) {
+                    return 'bg-warning p-1';
+                }
+            }
+            return '';
+        }
+
         this.cellTextGenerator = {
             title: row => row.title,
             copy_barcode: row => row.copy_barcode,
@@ -188,7 +199,10 @@ export class BillsComponent implements OnInit, AfterViewInit {
         // Recaclulate the amount owed per selected transaction as the
         // grid rows selections change.
         this.billGrid.context.rowSelector.selectionChange
-        .subscribe(_ => this.updatePendingColumn());
+        .subscribe(_ => {
+            this.refunding = false;
+            this.updatePendingColumn();
+        });
 
         this.focusPayAmount();
     }
@@ -401,6 +415,9 @@ export class BillsComponent implements OnInit, AfterViewInit {
         // Reset...
         this.gridDataSource.data.forEach(row => row.paymentPending = 0);
 
+        // No actions pending.  Reset and exit.
+        if (!this.paymentAmount && !this.refunding) { return; }
+
         let amount = this.pendingPayment();
         let done = false;
 
@@ -617,6 +634,7 @@ export class BillsComponent implements OnInit, AfterViewInit {
             if (!confirmed) { return; }
             this.refunding = true; // clearen in applyPayment()
             this.paymentAmount = null;
+            this.updatePendingColumn();
         });
     }