LP1737540: Add Patron Information to Receipts
authorJason Boyer <jboyer@library.in.gov>
Mon, 29 Jan 2018 22:02:01 +0000 (17:02 -0500)
committerChris Sharp <csharp@georgialibraries.org>
Thu, 19 Apr 2018 20:12:19 +0000 (16:12 -0400)
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>
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 054ed7f..16d9fb2 100644 (file)
@@ -349,9 +349,11 @@ 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'
         },
index e1a4ef2..24d2e54 100644 (file)
@@ -352,6 +352,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];
 
@@ -379,7 +381,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 0b558e3..2218659 100644 (file)
@@ -344,7 +344,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({
@@ -356,6 +357,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',