LP1904036 more billing
authorBill Erickson <berickxx@gmail.com>
Mon, 19 Apr 2021 18:39:08 +0000 (14:39 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:13:32 +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/billing-history.component.html
Open-ILS/src/eg2/src/app/staff/circ/patron/billing-history.component.ts
Open-ILS/src/eg2/src/app/staff/circ/patron/bills.component.html
Open-ILS/src/eg2/src/app/staff/circ/patron/bills.component.ts
Open-ILS/src/eg2/src/app/staff/share/billing/billing.service.ts
Open-ILS/src/perlmods/lib/OpenILS/WWW/PrintTemplate.pm
Open-ILS/src/sql/Pg/upgrade/XXXX.data.angular-patron.sql

index 4b3f0f0..f92b479 100644 (file)
 
       <eg-grid idlClass="mp" #paymentsGrid
         persistKey="circ.patron.billhistory_payments"
-        (onRowActivate)="showStatement($event)"
+        (onRowActivate)="showStatement($event, true)"
         [showDeclaredFieldsOnly]="true"
         [reloadOnColumnChange]="true"
         [dataSource]="paymentsDataSource" [sortable]="true">
index 54c1e50..735eb6d 100644 (file)
@@ -116,9 +116,10 @@ export class BillingHistoryComponent implements OnInit {
         }
     }
 
-    showStatement(row: any) {
+    showStatement(row: any, forPayment?: boolean) {
+        const id = forPayment ? row['xact.id'] : row.id;
         this.router.navigate(['/staff/circ/patron',
-            this.patronId, 'bills', row.xact.id(), 'statement']);
+            this.patronId, 'bills', id, 'statement']);
     }
 
     addBillingForXact(rows: any[]) {
index fe26a62..390f74d 100644 (file)
   <eg-grid-column path="summary.xact_type"
     label="Type" i18n-label></eg-grid-column>
 
-  <eg-grid-column path="summary.last_billing_type"
-    label="Last Billing Type" i18n-label></eg-grid-column>
+  <eg-grid-column name="last_billing_type" path="summary.last_billing_type" 
+    [required]="true" label="Last Billing Type" i18n-label></eg-grid-column>
+
+  <eg-grid-column name="last_payment_type" path="summary.last_payment_type" 
+    [required]="true" label="Last Payment Type" i18n-label></eg-grid-column>
+
+  <eg-grid-column name="last_payment_ts" path="summary.last_payment_ts" 
+    [required]="true" label="Last Payment Time" i18n-label></eg-grid-column>
 
   <eg-grid-column name="billingLocation"
     label="Billing Location" i18n-label></eg-grid-column>
     path="circulation.target_copy.call_number.record.id" 
     [required]="true" [hidden]="true"></eg-grid-column>
 
-  <eg-grid-column path="summary.balance_owed" datatype="money"
+  <eg-grid-column name="balance_owed" path="summary.balance_owed" datatype="money"
     [required]="true" label="Balance Owed" i18n-label></eg-grid-column>
 
-  <eg-grid-column path="summary.total_owed" datatype="money"
-    label="Total Billed" i18n-label></eg-grid-column>
+  <eg-grid-column name="total_owed" path="summary.total_owed" 
+    datatype="money" [required]="true" label="Total Billed" i18n-label></eg-grid-column>
 
-  <eg-grid-column path="summary.total_paid" datatype="money"
-    label="Total Paid" i18n-label></eg-grid-column>
+  <eg-grid-column name="total_paid" path="summary.total_paid" datatype="money" 
+    [required]="true" label="Total Paid" i18n-label></eg-grid-column>
 
   <eg-grid-column name="paymentPending" datatype="money"
     label="Payment Pending" i18n-label></eg-grid-column>
     path="circulation.target_copy.call_number.record.simple_record.author">
   </eg-grid-column>
 
+  <eg-grid-column [hidden]="true" label="Grocery Billing Location" 
+    [required]="true" i18n-label path="grocery.billing_location.shortname">
+  </eg-grid-column>
+
+  <eg-grid-column [hidden]="true" label="Circulation Billing Location" 
+    [required]="true" i18n-label path="circulation.circ_lib.shortname">
+  </eg-grid-column>
+
   <eg-grid-column path="usr" [hidden]="true"></eg-grid-column>
   <eg-grid-column path="unrecovered" [hidden]="true"></eg-grid-column>
 
index 4282db8..887ae89 100644 (file)
@@ -101,13 +101,16 @@ export class BillsComponent implements OnInit, AfterViewInit {
             const query: any = {
                usr: this.patronId,
                xact_finish: null,
-               'summary.balance_owed' : {'<>' : 0}
+               balance_owed: {'<>' : 0}
             };
 
             return this.flatData.getRows(
                 this.billGrid.context, query, pager, sort)
             .pipe(tap(row => {
                 row.paymentPending = 0;
+                row.billingLocation =
+                    row['grocery.billing_location.shortname'] ||
+                    row['circulation.circ_lib.shortname']
             }));
         };
 
@@ -172,9 +175,9 @@ export class BillsComponent implements OnInit, AfterViewInit {
 
             if (!row) { return; } // Called mid-reload
 
-            info.owed   += Number(row['summary.balance_owed']) * 100;
-            info.billed += Number(row['summary.total_owed']) * 100;
-            info.paid   += Number(row['summary.total_paid']) * 100;
+            info.owed   += Number(row.balance_owed) * 100;
+            info.billed += Number(row.total_owed) * 100;
+            info.paid   += Number(row.total_paid) * 100;
         });
 
         info.owed /= 100;
@@ -215,7 +218,7 @@ export class BillsComponent implements OnInit, AfterViewInit {
     refundsAvailable(): number {
         let amount = 0;
         this.gridDataSource.data.forEach(row => {
-            const balance = row['summary.balance_owed'];
+            const balance = row.balance_owed;
             if (balance < 0) { amount += balance * 100; }
 
         });
@@ -266,7 +269,10 @@ export class BillsComponent implements OnInit, AfterViewInit {
                 this.convertChangeToCredit
             );
         })
-        .then(paymentIds => this.handlePayReceipt(payments, paymentIds))
+        .then(resp => {
+            this.patron().last_xact_id(resp.last_xact_id);
+            return this.handlePayReceipt(payments, resp.payments);
+        })
 
         // refresh affected xact IDs
         .then(_ => this.billGrid.reload())
@@ -355,7 +361,7 @@ export class BillsComponent implements OnInit, AfterViewInit {
             if (done) { return; }
 
             const row = this.billGrid.context.getRowByIndex(index);
-            const owed = Number(row['summary.balance_owed']);
+            const owed = Number(row.balance_owed);
 
             if (amount > owed) {
                 // Pending payment amount exceeds balance of this
@@ -411,7 +417,7 @@ export class BillsComponent implements OnInit, AfterViewInit {
         payments.forEach(payment => {
 
             const entry =
-                this.gridDataSource.data.filter(e => e.xact.id() === payment[0])[0];
+                this.gridDataSource.data.filter(e => e.id === payment[0])[0];
 
             context.payments.push({
                 amount: payment[1],
@@ -435,7 +441,7 @@ export class BillsComponent implements OnInit, AfterViewInit {
     selectRefunds() {
         this.billGrid.context.rowSelector.clear();
         this.gridDataSource.data.forEach(row => {
-            if (row['summary.balance_owed'] < 0) {
+            if (row.balance_owed < 0) {
                 this.billGrid.context.toggleSelectOneRow(row.id);
             }
         });
index 52ca1e5..89f04bd 100644 (file)
@@ -24,6 +24,11 @@ export interface CreditCardPaymentParams {
     note?: string;
 }
 
+interface PaymentResponse {
+    payments: number[];
+    last_xact_id: string;
+}
+
 @Injectable()
 export class BillingService {
     billingTypes: IdlObject[];
@@ -73,7 +78,7 @@ export class BillingService {
         paymentNote?: string,
         checkNumber?: string,
         creditCardParams?: CreditCardPaymentParams,
-        convertChangeToCredit?: boolean): Promise<number[]> {
+        convertChangeToCredit?: boolean): Promise<PaymentResponse> {
 
        return this.net.request(
             'open-ils.circ',
@@ -97,8 +102,7 @@ export class BillingService {
             }
 
             // TODO work log
-
-            return response.payments;
+            return response;
         });
     }
 }
index 318f849..d678fb3 100644 (file)
@@ -221,6 +221,15 @@ $helpers = {
         return $U->ou_ancestor_setting_value($org_id, $setting);
     },
 
+    # Useful for accessing hash values whose key contains dots (.), 
+    # which TT interprets as levels within a nested hash.
+    #
+    # e.g.  So you don't have to do stuff like this:
+    # SET field = 'summary.balance_owed'; xact.$field
+    hashval => sub {
+        my ($hash, $key) = @_;
+        return $hash ? $hash->{$key} : undef;
+    }
 };
 
 
index 04ff243..3562fb4 100644 (file)
@@ -44,11 +44,13 @@ INSERT INTO config.print_template
     (name, label, owner, active, locale, content_type, template)
 VALUES ('bills_current', 'Bills, Current', 1, TRUE, 'en-US', 'text/html', '');
 
+*/
+
 UPDATE config.print_template SET template = $TEMPLATE$
 [% 
   USE date;
   USE money = format('$%.2f');
-  xacts = template_data.xacts;
+  SET xacts = template_data.xacts;
 %]
 <div>
   <style>td { padding: 1px 3px 1px 3px; }</style>
@@ -71,29 +73,30 @@ UPDATE config.print_template SET template = $TEMPLATE$
         </tr>
         <tr>
           <td>Last Billing:</td>
-          <td>[% xact.summary.last_billing_type %]</td>
+          <td>[% xact.last_billing_type %]</td>
         </tr>
         <tr>
           <td>Total Billed:</td>
-          <td>[% money(xact.summary.total_owed) %]</td>
+          <td>[% money(xact.total_owed) %]</td>
         </tr>
         <tr>
           <td>Last Payment:</td>
           <td>
-            [% xact.summary.last_payment_type %]
-            [% IF xact.summary.last_payment_ts %]
-              at [% date.format(helpers.format_date(
-                xact.summary.last_payment_ts, staff_org_timezone), '%x %r') %]
+            [% xact.last_payment_type %]
+            [% IF xact.last_payment_ts %]
+              at [% date.format(
+                    helpers.format_date(
+                        xact.last_payment_ts, staff_org_timezone), '%x %r') %]
             [% END %]
           </td>
         </tr>
         <tr>
           <td>Total Paid:</td>
-          <td>[% money(xact.summary.total_paid) %]</td>
+          <td>[% money(xact.total_paid) %]</td>
         </tr>
         <tr>
           <td>Balance:</td>
-          <td>[% money(xact.summary.balance_owed) %]</td>
+          <td>[% money(xact.balance_owed) %]</td>
         </tr>
       </table>
     </li>
@@ -106,6 +109,8 @@ UPDATE config.print_template SET template = $TEMPLATE$
 </div>
 $TEMPLATE$ WHERE name = 'bills_current';
 
+/*
+
 
 INSERT INTO config.print_template 
     (name, label, owner, active, locale, content_type, template)
@@ -468,7 +473,6 @@ INSERT INTO config.print_template
     (name, label, owner, active, locale, content_type, template)
 VALUES ('holds_for_patron', 'Holds For Patron', 1, TRUE, 'en-US', 'text/html', '');
 
-*/
 
 UPDATE config.print_template SET template = $TEMPLATE$
 [% 
@@ -495,6 +499,8 @@ UPDATE config.print_template SET template = $TEMPLATE$
 
 $TEMPLATE$ WHERE name = 'holds_for_patron';
 
+*/
+
 COMMIT;