LP1737540: Add Patron Information to Receipts
authorJason Boyer <jboyer@library.in.gov>
Mon, 29 Jan 2018 22:02:01 +0000 (17:02 -0500)
committerJason Stephenson <jason@sigio.com>
Fri, 16 Feb 2018 13:35:43 +0000 (08:35 -0500)
Adds the following fields to a patron object on print_data:
first_given_name
second_given_name
family_name
suffix
barcode
money_summary.balance_owed
money_summary.total_paid
money_summary.total_owed
expire_date
alias
has_email
has_phone

On the following receipts: Checkout, Items Out, and Bill Payment.

(money_summary left out on bill payment because it will always be out of date.)

Signed-off-by: Jason Boyer <jboyer@library.in.gov>
Signed-off-by: Jason Stephenson <jason@sigio.com>

Open-ILS/src/templates/staff/share/print_templates/t_bill_payment.tt2
Open-ILS/src/templates/staff/share/print_templates/t_checkout.tt2
Open-ILS/src/templates/staff/share/print_templates/t_items_out.tt2
Open-ILS/web/js/ui/default/staff/admin/workstation/app.js
Open-ILS/web/js/ui/default/staff/circ/patron/bills.js
Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js
Open-ILS/web/js/ui/default/staff/circ/patron/items_out.js

index 57e50fe..d0189c9 100644 (file)
@@ -2,6 +2,18 @@
 Template for bill payment receipts. Data specific to this template
 includes:
 
+* patron - has several fields from the patron object, including a financial summary
+
+  * first_given_name
+  * second_given_name
+  * family_name
+  * suffix
+  * card.barcode
+  * expire_date
+  * alias - aka Holds Alias
+  * has_email - boolean value to show/hide elements on the receipt
+  * has_phone - same as has_email
+
 * current_location.name - name of workstation location
 * payment_type
 * payment_total - total paid
index 6b445b9..9ba5c31 100644 (file)
@@ -1,18 +1,28 @@
 <!--
 Template for printing checkout receipts; fields available include:
 
-* patron_money - summary of the patron's current financial obligations:
+* patron - has several fields from the patron object, including a financial summary
 
-  * patron_money.balance_owed - current balance
-  * patron_money.total_paid - payments made on outstanding fines/fees
-  * patron_money.total_owed - total of outstanding fines/fees
+  * first_given_name
+  * second_given_name
+  * family_name
+  * suffix
+  * card.barcode
+  * money_summary.balance_owed - current balance
+  * money_summary.total_paid - payments made on outstanding fines/fees
+  * money_summary.total_owed - total of outstanding fines/fees
+  * expire_date
+  * alias - aka Holds Alias
+  * has_email - boolean value to show/hide elements on the receipt
+  * has_phone - same as has_email
 
 * circulations - list of loans made during this session. Each
   includes:
 
   * title
-  * copy_barcode
-  * due_date
+  * author
+  * copy.barcode
+  * circ.due_date
 
 -->
 <div>
index 9d49e15..225fbb4 100644 (file)
@@ -2,11 +2,28 @@
 Template for printing a list of items that a patron has checked out.
 Fields include:
 
+* patron - has several fields from the patron object, including a financial summary
+
+  * first_given_name
+  * second_given_name
+  * family_name
+  * suffix
+  * card.barcode
+  * money_summary.balance_owed - current balance
+  * money_summary.total_paid - payments made on outstanding fines/fees
+  * money_summary.total_owed - total of outstanding fines/fees
+  * expire_date
+  * alias - aka Holds Alias
+  * has_email - boolean value to show/hide elements on the receipt
+  * has_phone - same as has_email
+
 * circulations - list of current loans, including
 
+  * title
+  * author
+  * call_number.label
   * copy.barcode
   * circ.due_date
-  * title
 
 -->
 <div>
index 71e9117..20973ff 100644 (file)
@@ -349,12 +349,23 @@ function($scope , $q , egCore , ngToast) {
     // alongside the templates.
     // NOTE: A lot of this data can be shared across templates.
     var seed_user = {
+        prefix : 'Mr',
         first_given_name : 'Slow',
         second_given_name : 'Joe',
         family_name : 'Jones',
+        suffix : 'III',
         card : {
             barcode : '30393830393'
-        }
+        },
+        money_summary : {
+            balance_owed : 4, // This is currently how these values are returned to the client
+            total_billed : '5.00',
+            total_paid : '1.00'
+        },
+        expire_date : '2020-12-31',
+        alias : 'the dude',
+        has_email : true,
+        has_phone : false
     }
     var seed_addr = {
         street1 : '123 Apple Rd',
index 97c2d93..ea21a3c 100644 (file)
@@ -350,6 +350,8 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
 
     function printReceipt(type, payment_ids, payments_made, note) {
         var payment_blobs = [];
+        var cusr = patronSvc.current;
+
         angular.forEach(payments_made, function(payment) {
             var xact_id = payment[0];
 
@@ -377,7 +379,21 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
             payments : payment_blobs,
             current_location : egCore.idl.toHash(
                 egCore.org.get(egCore.auth.user().ws_ou()))
-        }
+        };
+
+        // Not a good idea to use patron_stats.fines for this; it's out of date
+        print_data.patron = {
+            prefix : cusr.prefix(),
+            first_given_name : cusr.first_given_name(),
+            second_given_name : cusr.second_given_name(),
+            family_name : cusr.family_name(),
+            suffix : cusr.suffix(),
+            card : { barcode : cusr.card().barcode() },
+            expire_date : cusr.expire_date(),
+            alias : cusr.alias(),
+            has_email : Boolean(patronSvc.current.email() && patronSvc.current.email().match(/.*@.*/).length),
+            has_phone : Boolean(cusr.day_phone() || cusr.evening_phone() || cusr.other_phone())
+        };
 
         print_data.new_balance = (
             print_data.previous_balance * 100 - 
index 83a6a6f..10a97e4 100644 (file)
@@ -256,7 +256,8 @@ function($scope , $q , $routeParams , egCore , egUser , patronSvc ,
     }
 
     $scope.print_receipt = function() {
-        var print_data = {circulations : []}
+        var print_data = {circulations : []};
+        var cusr = patronSvc.current;
 
         if ($scope.checkouts.length == 0) return $q.when();
 
@@ -272,7 +273,21 @@ function($scope , $q , $routeParams , egCore , egUser , patronSvc ,
             };
         });
 
+        // This is repeated in patron.* so everyting is in one place but left here so existing templates don't break.
         print_data.patron_money = patronSvc.patron_stats.fines;
+        print_data.patron = {
+            prefix : cusr.prefix(),
+            first_given_name : cusr.first_given_name(),
+            second_given_name : cusr.second_given_name(),
+            family_name : cusr.family_name(),
+            suffix : cusr.suffix(),
+            card : { barcode : cusr.card().barcode() },
+            money_summary : patronSvc.patron_stats.fines,
+            expire_date : cusr.expire_date(),
+            alias : cusr.alias(),
+            has_email : Boolean($scope.has_email_address()),
+            has_phone : Boolean(cusr.day_phone() || cusr.evening_phone() || cusr.other_phone())
+        };
 
         return egCore.print.print({
             context : 'default', 
index 777900a..ac189f9 100644 (file)
@@ -345,7 +345,8 @@ function($scope,  $q,  $routeParams,  $timeout,  egCore , egUser,  patronSvc , $
 
     $scope.print_receipt = function(items) {
         if (items.length == 0) return $q.when();
-        var print_data = {circulations : []}
+        var print_data = {circulations : []};
+        var cusr = patronSvc.current;
 
         angular.forEach(patronSvc.items_out, function(circ) {
             print_data.circulations.push({
@@ -357,6 +358,20 @@ function($scope,  $q,  $routeParams,  $timeout,  egCore , egUser,  patronSvc , $
             })
         });
 
+        print_data.patron = {
+            prefix : cusr.prefix(),
+            first_given_name : cusr.first_given_name(),
+            second_given_name : cusr.second_given_name(),
+            family_name : cusr.family_name(),
+            suffix : cusr.suffix(),
+            card : { barcode : cusr.card().barcode() },
+            money_summary : patronSvc.patron_stats.fines,
+            expire_date : cusr.expire_date(),
+            alias : cusr.alias(),
+            has_email : Boolean(patronSvc.current.email() && patronSvc.current.email().match(/.*@.*/).length),
+            has_phone : Boolean(cusr.day_phone() || cusr.evening_phone() || cusr.other_phone())
+        };
+
         return egCore.print.print({
             context : 'default', 
             template : 'items_out',