LP#1697954: Provide custom comparator for sorting money on renew
authorMike Rylander <mrylander@gmail.com>
Wed, 14 Jun 2017 16:07:52 +0000 (12:07 -0400)
committerMike Rylander <mrylander@gmail.com>
Fri, 30 Jun 2017 14:44:29 +0000 (10:44 -0400)
mbts.balance_owed often arrives as a string, so we provide here a custom
comparator function that runs the values through parseFloat() before comparing
them.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Andrea Neiman <abneiman@equinoxinitiative.org>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/templates/staff/circ/renew/t_renew.tt2
Open-ILS/web/js/ui/default/staff/circ/renew/app.js

index 9678176..7b0fdb7 100644 (file)
@@ -72,7 +72,7 @@
     path="acp.alert_message"></eg-grid-field>
 
   <eg-grid-field label="[% l('Balance Owed') %]"     
-    path='mbts.balance_owed'></eg-grid-field>
+    path='mbts.balance_owed' comparator="sort_money"></eg-grid-field>
 
   <eg-grid-field label="[% l('Barcode') %]" path="copy_barcode">
     <!-- FIXME: ng-if / ng-disabled not working since the contents 
index 85ed294..bb20b98 100644 (file)
@@ -40,6 +40,14 @@ function($scope , $window , $location , egCore , egGridDataProvider , egCirc) {
     var today = new Date();
     $scope.renewalArgs = {due_date : today};
 
+    $scope.sort_money = function (a,b) {
+        var ma = parseFloat(a);
+        var mb = parseFloat(b);
+        if (ma < mb) return -1;
+        if (ma > mb) return 1;
+        return 0
+    }
+
     $scope.gridDataProvider = egGridDataProvider.instance({
         get : function(offset, count) {
             return this.arrayNotifier($scope.renewals, offset, count);