LP1840773 SCKO Angular
authorBill Erickson <berickxx@gmail.com>
Thu, 23 Jun 2022 21:18:31 +0000 (17:18 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 23 Jun 2022 21:18:31 +0000 (17:18 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/scko/fines.component.html
Open-ILS/src/eg2/src/app/scko/fines.component.ts
Open-ILS/src/eg2/src/app/scko/items.component.ts
Open-ILS/src/sql/Pg/upgrade/YYYY.data.scko-angular.sql

index 9a4223c..d4444c3 100644 (file)
@@ -1,3 +1,9 @@
+<div class="d-flex">
+  <div class="flex-1"></div>
+  <div>
+    <button class="btn btn-outline-dark" (click)="printList()" i18n>Print List</button>
+  </div>
+</div>
 <div id='oils-selfck-circ-table-div'>
   <table id='oils-selfck-circ-table' class='oils-selfck-item-table'>
     <thead>
             Miscellaneous
           </ng-container>
         </td>
-        <td>
-          <ng-container *ngIf="xact.summary().xact_type() == 'circulation'" i18n>
-            {{getTitle(xact)}}
-          </ng-container>
-          <ng-container *ngIf="xact.summary().xact_type() != 'circulation'" i18n>
-            {{xact.summary().last_billing_type()}}
-          </ng-container>
-        </td>
+        <td>{{getDetails(xact)}}</td>
         <td>{{xact.summary().total_owed() | currency}}</td>
         <td>{{xact.summary().total_paid() | currency}}</td>
         <td>{{xact.summary().balance_owed() | currency}}</td>
index e70b0d7..373f415 100644 (file)
@@ -6,6 +6,7 @@ import {PcrudService} from '@eg/core/pcrud.service';
 import {NetService} from '@eg/core/net.service';
 import {IdlObject} from '@eg/core/idl.service';
 import {SckoService} from './scko.service';
+import {PrintService} from '@eg/share/print/print.service';
 
 
 @Component({
@@ -22,6 +23,7 @@ export class SckoFinesComponent implements OnInit {
         private net: NetService,
         private auth: AuthService,
         private pcrud: PcrudService,
+        private printer: PrintService,
         public  scko: SckoService
     ) {}
 
@@ -75,5 +77,34 @@ export class SckoFinesComponent implements OnInit {
         return this.displayValue(xact, 'title');
     }
 
+    getDetails(xact: IdlObject): string {
+        if (xact.summary().xact_type() == 'circulation') {
+            return this.getTitle(xact);
+        } else {
+            return xact.summary().last_billing_type();
+        }
+    }
+
+    printList() {
+
+        const data = this.xacts.map(x => {
+            return {
+                xact: x, // full object if needed
+                details: this.getDetails(x),
+                total_owed: x.summary().total_owed(),
+                total_paid: x.summary().total_paid(),
+                balance_owed: x.summary().balance_owed(),
+            };
+        });
+
+        this.printer.print({
+            templateName: 'scko_fines',
+            contextData: {
+                xacts: data,
+                user: this.scko.patronSummary.patron
+            },
+            printContext: 'default'
+        });
+    }
 }
 
index e9ceba1..a4e3d8f 100644 (file)
@@ -103,7 +103,10 @@ export class SckoItemsComponent implements OnInit {
 
         this.printer.print({
             templateName: 'scko_items_out',
-            contextData: {checkouts: data},
+            contextData: {
+                checkouts: data,
+                user: this.scko.patronSummary.patron
+            },
             printContext: 'default'
         });
     }
index c92f1ef..0fc7040 100644 (file)
@@ -81,13 +81,60 @@ UPDATE config.print_template SET template = $TEMPLATE$
             [% END %]
           </td>
         </tr>
-      </div>
+      </table>
     </li>
   [% END %]
   </ol>
 </div>
 $TEMPLATE$ WHERE name = 'scko_holds';
 
+INSERT INTO config.print_template 
+    (name, label, owner, active, locale, content_type, template)
+VALUES ('scko_fines', 'Self-Checkout Fines', 1, TRUE, 'en-US', 'text/html', '');
+
+UPDATE config.print_template SET template = $TEMPLATE$
+[%- 
+    USE date;
+    USE money = format('$%.2f');
+    SET user = template_data.user;
+    SET xacts = template_data.xacts;
+-%]
+<div>
+  <style> li { padding: 8px; margin 5px; }</style>
+  <div>[% date.format(date.now, '%x %r') %]</div>
+  <br/>
+
+  [% user.pref_family_name || user.family_name %], 
+  [% user.pref_first_given_name || user.first_given_name %]
+
+  <ol>
+  [% FOR xact IN xacts %]
+    [% NEXT IF xact.balance_owed <= 0 %]
+    <li>
+      <table>
+        <tr>
+          <td>Details:</td>
+          <td>[% xact.details %]</td>
+        </tr>
+        <tr>
+          <td>Total Billed:</td>
+          <td>[% money(xact.total_owed) %]</td>
+        </tr>
+        <tr>
+          <td>Total Paid:</td>
+          <td>[% money(xact.total_paid) %]</td>
+        </tr>
+        <tr>
+          <td>Balance Owed:</td>
+          <td>[% money(xact.balance_owed) %]</td>
+        </tr>
+      </table>
+    </li>
+  [% END %]
+  </ol>
+</div>
+$TEMPLATE$ WHERE name = 'scko_fines';
+
 COMMIT;