LP1859701 replace "totals" row in each grid with a totals section above each grid
authorJason Etheridge <jason@EquinoxOLI.org>
Tue, 5 Apr 2022 22:53:08 +0000 (18:53 -0400)
committerMichele Morgan <mmorgan@noblenet.org>
Fri, 28 Oct 2022 19:44:38 +0000 (15:44 -0400)
Signed-off-by: Jason Etheridge <jason@EquinoxOLI.org>
Signed-off-by: Jane Sandberg <js7389@princeton.edu>
Signed-off-by: Michele Morgan <mmorgan@noblenet.org>
Open-ILS/src/eg2/src/app/staff/admin/local/cash-reports/cash-reports.component.html
Open-ILS/src/eg2/src/app/staff/admin/local/cash-reports/cash-reports.component.ts

index 3a44eb8..4191d6c 100644 (file)
     <ngb-tab title="Desk Payments">
       <ng-template ngbTabContent>
         <div class="mb-5">
+            <div class="row">
+                <div class="col-sm-2" i18n>Total Cash Payments</div>
+                <div class="col-sm-10">{{deskTotals.formatted_cash_payment}}</div>
+            </div>
+            <div class="row">
+                <div class="col-sm-2" i18n>Total Check Payments</div>
+                <div class="col-sm-10">{{deskTotals.formatted_check_payment}}</div>
+            </div>
+            <div class="row">
+                <div class="col-sm-2" i18n>Total Credit Card Payments</div>
+                <div class="col-sm-10">{{deskTotals.formatted_credit_card_payment}}</div>
+            </div>
             <eg-grid #deskPaymentGrid
                 [disableSelect]="true"
                 [disablePaging]="true"
     <ngb-tab title="User Payments">
         <ng-template ngbTabContent>
             <div class="mb-3">
+                <div class="row">
+                    <div class="col-sm-2" i18n>Total Credit Payments</div>
+                    <div class="col-sm-10">{{userTotals.formatted_credit_payment}}</div>
+                </div>
+                <div class="row">
+                    <div class="col-sm-2" i18n>Total Forgive Payments</div>
+                    <div class="col-sm-10">{{userTotals.formatted_forgive_payment}}</div>
+                </div>
+                <div class="row">
+                    <div class="col-sm-2" i18n>Total Work Payments</div>
+                    <div class="col-sm-10">{{userTotals.formatted_work_payment}}</div>
+                </div>
+                <div class="row">
+                    <div class="col-sm-2" i18n>Total Goods Payments</div>
+                    <div class="col-sm-10">{{userTotals.formatted_goods_payment}}</div>
+                </div>
                 <eg-grid #userPaymentGrid
                     (onRowActivate) = "onRowActivate($event)"
                     [disableSelect]="true"
index 065a928..ae98f80 100644 (file)
@@ -1,6 +1,7 @@
 import {Component, OnInit, Input, ViewChild} from '@angular/core';
 import {GridComponent} from '@eg/share/grid/grid.component';
 import {GridDataSource, GridColumn, GridRowFlairEntry} from '@eg/share/grid/grid';
+import {FormatService} from '@eg/core/format.service';
 import {IdlService} from '@eg/core/idl.service';
 import {NetService} from '@eg/core/net.service';
 import {AuthService} from '@eg/core/auth.service';
@@ -11,6 +12,9 @@ class DeskTotals {
     cash_payment = 0;
     check_payment = 0;
     credit_card_payment = 0;
+    formatted_cash_payment = '0.00';
+    formatted_check_payment = '0.00';
+    formatted_credit_card_payment = '0.00';
 };
 
 class UserTotals {
@@ -18,6 +22,10 @@ class UserTotals {
     work_payment = 0;
     credit_payment = 0;
     goods_payment = 0;
+    formatted_forgive_payment = '0.00';
+    formatted_work_payment = '0.00';
+    formatted_credit_payment = '0.00';
+    formatted_goods_payment = '0.00';
 };
 
 @Component({
@@ -49,6 +57,7 @@ export class CashReportsComponent implements OnInit {
         private idl: IdlService,
         private net: NetService,
         private org: OrgService,
+        private format: FormatService,
         private auth: AuthService){}
 
     ngOnInit() {
@@ -97,16 +106,23 @@ export class CashReportsComponent implements OnInit {
             let dataForTotal;
             if(idlClass === this.deskIdlClass) {
                 dataForTotal = this.getDeskTotal(result);
+                this.deskTotals.formatted_cash_payment = this.format.transform({value: this.deskTotals.cash_payment, datatype: 'money'});
+                this.deskTotals.formatted_check_payment = this.format.transform({value: this.deskTotals.check_payment, datatype: 'money'});
+                this.deskTotals.formatted_credit_card_payment = this.format.transform({value: this.deskTotals.credit_card_payment, datatype: 'money'});
             } else if(idlClass === this.userIdlClass) {
                 dataForTotal = this.getUserTotal(result);
+                this.userTotals.formatted_credit_payment = this.format.transform({value: this.userTotals.credit_payment, datatype: 'money'});
+                this.userTotals.formatted_forgive_payment = this.format.transform({value: this.userTotals.forgive_payment, datatype: 'money'});
+                this.userTotals.formatted_work_payment = this.format.transform({value: this.userTotals.work_payment, datatype: 'money'});
+                this.userTotals.formatted_goods_payment = this.format.transform({value: this.userTotals.goods_payment, datatype: 'money'});
                 result.forEach((userObject, index) => {
                     result[index].user = userObject.usr();
                     result[index].usr(userObject.usr().usrname())
                 });
             }
-            if(result.length > 0) {
-                result.push(dataForTotal);
-            }
+            //if(result.length > 0) {
+            //    result.push(dataForTotal);
+            //}
             this[dataSource].data = result;
             this.eraseUserGrid();
         });