bill history transactions
authorBill Erickson <berick@esilibrary.com>
Wed, 28 May 2014 20:27:40 +0000 (16:27 -0400)
committerBill Erickson <berick@esilibrary.com>
Wed, 28 May 2014 20:27:40 +0000 (16:27 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/staff/circ/patron/t_bill_history.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/bills.js

index 1f2c75a..1795ff0 100644 (file)
@@ -18,9 +18,9 @@
     <div ng-if="bill_tab == 'transactions'">
       <div class="flex-row padded">
         <div>[% l('Selected Billed:') %]</div>
-        <div>{{selected_billed | currency}}</div>
+        <div>{{selected_billed() | currency}}</div>
         <div>[% l('Selected Paid:') %]</div>
-        <div>{{selected_paid | currency}}</div>
+        <div>{{selected_paid() | currency}}</div>
         <div class="flex-cell"></div>
         <div>[% l('Start Date:') %]</div>
         <div><input eg-date-input class="form-control" ng-model="dates.xact_start"/></div>
@@ -34,6 +34,7 @@
         id-field="id"
         query="xactQuery"
         activate-item="activateBill"
+        on-selection-change="gridSelectionChanged"
         revision="xactRevision">
 
         <eg-grid-action 
index a360c6c..b7a4fce 100644 (file)
@@ -204,6 +204,9 @@ function($q , egCore , patronSvc) {
 function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
          egGridDataProvider , billSvc , patronSvc , egPromptDialog , $modal) {
 
+    // TODO: move to fetching "mbt"+summary instead of "mobts" for
+    // consistency
+
     $scope.initTab('bills', $routeParams.id);
     billSvc.userId = $routeParams.id;
 
@@ -233,6 +236,7 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
     }
 
     // calculates amount owed, billed, and paid for selected items
+    // TODO: move me to service
     function selected_payment_info() {
         var info = {owed : 0, billed : 0, paid : 0};
         angular.forEach(selectedItems, function(item) {
@@ -612,8 +616,32 @@ function($scope,  $q , $routeParams , egCore , patronSvc , billSvc , egPromptDia
     $scope.initTab('bills', $routeParams.id);
     billSvc.userId = $routeParams.id;
     $scope.bill_tab = $routeParams.history_tab;
-    $scope.selected_billed = 0;
-    $scope.selected_paid = 0;
+
+    var selectedItems = [];
+    $scope.gridSelectionChanged = function(selected) {
+        selectedItems = selected;
+    }
+
+    // TODO; move me to service
+    function selected_payment_info() {
+        var info = {owed : 0, billed : 0, paid : 0};
+        angular.forEach(selectedItems, function(item) {
+            info.owed   += Number(item['summary.balance_owed']) * 100;
+            info.billed += Number(item['summary.total_owed']) * 100;
+            info.paid   += Number(item['summary.total_paid']) * 100;
+        });
+        info.owed /= 100;
+        info.billed /= 100;
+        info.paid /= 100;
+        return info;
+    }
+
+    $scope.selected_billed = function() {
+        return selected_payment_info().billed;
+    }
+    $scope.selected_paid = function() {
+        return selected_payment_info().paid;
+    }
 
     var start = new Date(); // now - 1 year
     start.setFullYear(start.getFullYear() - 1),
@@ -654,6 +682,7 @@ function($scope,  $q , $routeParams , egCore , patronSvc , billSvc , egPromptDia
         $scope.showFullDetails([xact]);
     }
 
+
 }])