LP1904036 more billing
authorBill Erickson <berickxx@gmail.com>
Mon, 19 Apr 2021 18:59:52 +0000 (14:59 -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/sql/Pg/upgrade/XXXX.data.angular-patron.sql

index f92b479..06d59b0 100644 (file)
           i18n-label label="Print Bills" (onClick)="printBills($event)">
         </eg-grid-toolbar-action>
 
-        <eg-grid-column path="summary.balance_owed"></eg-grid-column>
+        <eg-grid-toolbar-action
+          i18n-label label="Full Details" (onClick)="showStatement($event)">
+        </eg-grid-toolbar-action>
+
+        <eg-grid-column name="balance_owed" [required]="true" path="summary.balance_owed"></eg-grid-column>
         <eg-grid-column path="id" [index]="true" i18n-label label="Bill #" [required]="true"></eg-grid-column>
         <eg-grid-column path="xact_finish" i18n-label label="Finish" 
           datatype="timestamp" [datePlusTime]="true"></eg-grid-column>
         <eg-grid-column path="xact_start" i18n-label label="Start" 
           datatype="timestamp" [datePlusTime]="true"></eg-grid-column>
-        <eg-grid-column path="summary.total_owed" i18n-label label="Total Billed"></eg-grid-column>
-        <eg-grid-column path="summary.total_paid" i18n-label label="Total Paid"></eg-grid-column>
+        <eg-grid-column name="total_owed" [required]="true" 
+          path="summary.total_owed" i18n-label label="Total Billed"></eg-grid-column>
+        <eg-grid-column name="total_paid" [required]="true" 
+          path="summary.total_paid" i18n-label label="Total Paid"></eg-grid-column>
         <eg-grid-column path="summary.xact_type" i18n-label label="Type"></eg-grid-column>
-        <eg-grid-column path="summary.last_payment_ts" datatype="timestamp
-          [required]="true" [hidden]="true"></eg-grid-column>
+        <eg-grid-column name="last_payment_ts" path="summary.last_payment_ts
+          datatype="timestamp" [required]="true" [hidden]="true"></eg-grid-column>
 
         <eg-grid-column i18n-label label="Title" name="title" 
           [cellTemplate]="titleTemplate"
         [reloadOnColumnChange]="true"
         [dataSource]="paymentsDataSource" [sortable]="true">
 
+        <eg-grid-toolbar-action
+          i18n-label label="Full Details" (onClick)="showStatement($event, true)">
+        </eg-grid-toolbar-action>
+
         <eg-grid-column path="amount" i18n-label label="Amount"></eg-grid-column>
         <eg-grid-column path="id" [index]="true" i18n-label label="Payment ID" [required]="true"></eg-grid-column>
         <eg-grid-column path="payment_ts" i18n-label label="Payment Time" [datePlusTime]="true"></eg-grid-column>
index 735eb6d..67dcb8e 100644 (file)
@@ -85,8 +85,8 @@ export class BillingHistoryComponent implements OnInit {
                usr: this.patronId,
                xact_start: {between: [this.xactsStart, this.xactsEnd]},
                '-or': [
-                    {'summary.balance_owed': {'<>': 0}},
-                    {'summary.last_payment_ts': {'<>': null}}
+                    {balance_owed: {'<>': 0}},
+                    {last_payment_ts: {'<>': null}}
                ]
             };
 
@@ -116,7 +116,8 @@ export class BillingHistoryComponent implements OnInit {
         }
     }
 
-    showStatement(row: any, forPayment?: boolean) {
+    showStatement(row: any | any[], forPayment?: boolean) {
+        row = [].concat(row)[0];
         const id = forPayment ? row['xact.id'] : row.id;
         this.router.navigate(['/staff/circ/patron',
             this.patronId, 'bills', id, 'statement']);
@@ -151,7 +152,7 @@ export class BillingHistoryComponent implements OnInit {
 
         this.printer.print({
             templateName: 'bills_historical',
-            contextData: {xacts: rows.map(r => r.xact)},
+            contextData: {xacts: rows},
             printContext: 'default'
         });
     }
@@ -180,9 +181,9 @@ export class BillingHistoryComponent implements OnInit {
 
             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;
index 3562fb4..842855c 100644 (file)
@@ -44,7 +44,6 @@ 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$
 [% 
@@ -109,8 +108,6 @@ 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)
@@ -499,6 +496,143 @@ UPDATE config.print_template SET template = $TEMPLATE$
 
 $TEMPLATE$ WHERE name = 'holds_for_patron';
 
+
+INSERT INTO config.print_template 
+    (name, label, owner, active, locale, content_type, template)
+VALUES ('bills_historical', 'Bills, Historical', 1, TRUE, 'en-US', 'text/html', '');
+
+
+UPDATE config.print_template SET template = $TEMPLATE$
+[% 
+  USE date;
+  USE money = format('$%.2f');
+  SET xacts = template_data.xacts;
+%]
+<div>
+  <style>td { padding: 1px 3px 1px 3px; }</style>
+  <div>Welcome to [% staff_org.name %]</div>
+  <div>You have the following bills:</div>
+  <hr/>
+  <ol>
+  [% FOR xact IN xacts %]
+    <li>
+      <table>
+        <tr>
+          <td>Bill #:</td>
+          <td>[% xact.id %]</td>
+        </tr>
+        <tr>
+          <td>Date:</td>
+          <td>[% date.format(helpers.format_date(
+            xact.xact_start, staff_org_timezone), '%x %r') %]
+          </td>
+        </tr>
+        <tr>
+          <td>Last Billing:</td>
+          <td>[% xact.last_billing_type %]</td>
+        </tr>
+        <tr>
+          <td>Total Billed:</td>
+          <td>[% money(xact.total_owed) %]</td>
+        </tr>
+        <tr>
+          <td>Last Payment:</td>
+          <td>
+            [% 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.total_paid) %]</td>
+        </tr>
+        <tr>
+          <td>Balance:</td>
+          <td>[% money(xact.balance_owed) %]</td>
+        </tr>
+      </table>
+    </li>
+  [% END %]
+  </ol>
+  <hr/>
+  <div>[% staff_org.name %] [% date.format(date.now, '%x %r') %]</div>
+  <div>You were helped by [% staff.first_given_name %]</div>
+  <br/>
+</div>
+$TEMPLATE$ WHERE name = 'bills_historical';
+
+INSERT INTO config.print_template 
+    (name, label, owner, active, locale, content_type, template)
+VALUES ('bills_historical', 'Bills, Historical', 1, TRUE, 'en-US', 'text/html', '');
+
+
+UPDATE config.print_template SET template = $TEMPLATE$
+[% 
+  USE date;
+  USE money = format('$%.2f');
+  SET xacts = template_data.xacts;
+%]
+<div>
+  <style>td { padding: 1px 3px 1px 3px; }</style>
+  <div>Welcome to [% staff_org.name %]</div>
+  <div>You have the following bills:</div>
+  <hr/>
+  <ol>
+  [% FOR xact IN xacts %]
+    <li>
+      <table>
+        <tr>
+          <td>Bill #:</td>
+          <td>[% xact.id %]</td>
+        </tr>
+        <tr>
+          <td>Date:</td>
+          <td>[% date.format(helpers.format_date(
+            xact.xact_start, staff_org_timezone), '%x %r') %]
+          </td>
+        </tr>
+        <tr>
+          <td>Last Billing:</td>
+          <td>[% xact.last_billing_type %]</td>
+        </tr>
+        <tr>
+          <td>Total Billed:</td>
+          <td>[% money(xact.total_owed) %]</td>
+        </tr>
+        <tr>
+          <td>Last Payment:</td>
+          <td>
+            [% 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.total_paid) %]</td>
+        </tr>
+        <tr>
+          <td>Balance:</td>
+          <td>[% money(xact.balance_owed) %]</td>
+        </tr>
+      </table>
+    </li>
+  [% END %]
+  </ol>
+  <hr/>
+  <div>[% staff_org.name %] [% date.format(date.now, '%x %r') %]</div>
+  <div>You were helped by [% staff.first_given_name %]</div>
+  <br/>
+</div>
+$TEMPLATE$ WHERE name = 'bills_historical';
+
 */
 
 COMMIT;