lp1772955 total billed total paid inaccurate user/mrisher/lp1772955-total-billed-inaccurate
authorMike Risher <mrisher@catalyte.io>
Tue, 28 Jan 2020 23:54:05 +0000 (23:54 +0000)
committerMike Risher <mrisher@catalyte.io>
Tue, 28 Jan 2020 23:54:05 +0000 (23:54 +0000)
Fix the bug on the patron billing UI that's causing the total billed
and total paid amounts to be inaccurate. The bug causes it to include
amounts from bills that have already been completely paid.

Signed-off-by: Mike Risher <mrisher@catalyte.io>
 Changes to be committed:
modified:   Open-ILS/src/templates/staff/circ/patron/t_bills.tt2
modified:   Open-ILS/web/js/ui/default/staff/circ/patron/bills.js

Open-ILS/src/templates/staff/circ/patron/t_bills.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/bills.js

index b2d41cc..9394d2b 100644 (file)
@@ -4,22 +4,24 @@
 
     <div class="row">
       <div class="col-md-4">[% l('Total Owed:') %]</div>
-      <div class="col-md-2 strong-text">{{(summary.balance_owed() || 0) | currency}}</div>
+      <div class="col-md-2 strong-text">{{owed_all() | currency}}</div>
       <div class="col-md-4">[% l('Refunds Available:') %]</div>
       <div class="col-md-2">{{refunds_available() | currency}}</div>
     </div>
     <div class="row">
       <div class="col-md-4">[% l('Total Billed:') %]</div>
-      <div class="col-md-2">{{(summary.total_owed() || 0) | currency}}</div>
+      <div class="col-md-2">{{billed_all() | currency}}</div>
       <div class="col-md-4">[% l('Credit Available:') %]</div>
       <div class="col-md-2">{{patron().credit_forward_balance() | currency}}</div>
     </div>
     <div class="row">
       <div class="col-md-4">[% l('Total Paid/Credited:') %]</div>
-      <div class="col-md-2">{{(summary.total_paid() || 0) | currency}}</div>
+      <div class="col-md-2">{{paid_all() | currency}}</div>
       <div class="col-md-4">[% l('Session Voided:') %]</div>
       <div class="col-md-2">{{session_voided | currency}}</div>
     </div>
+    
+
     <div class="row"><hr/></div>
     <div class="row">
       <div class="col-md-4">[% l('Owed for Selected:') %]</div>
index 25a01d8..90669cc 100644 (file)
@@ -292,6 +292,19 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
         return info;
     }
 
+    function all_payment_info() {
+        var info = {owed : 0, billed : 0, paid : 0};
+        angular.forEach($scope.gridControls.allItems(), 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.pending_payment = function() {
         return pending_payment_info().payment;
     }
@@ -307,6 +320,15 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
     $scope.paid_selected = function() {
         return selected_payment_info().paid;
     }
+    $scope.owed_all = function() {
+        return all_payment_info().owed; 
+    }
+    $scope.billed_all = function() {
+        return all_payment_info().billed;
+    }
+    $scope.paid_all = function() {
+        return all_payment_info().paid;
+    }
     $scope.refunds_available = function() {
         var amount = 0;
         angular.forEach($scope.gridControls.allItems(), function(item) {