LP#1697954: Provide custom comparator for sorting money on checkin
authorMike Rylander <mrylander@gmail.com>
Wed, 14 Jun 2017 16:11:27 +0000 (12:11 -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/checkin/t_checkin_table.tt2
Open-ILS/web/js/ui/default/staff/circ/checkin/app.js

index 5c6268a..920ee2b 100644 (file)
@@ -30,7 +30,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 a9b70ca..099b1be 100644 (file)
@@ -58,6 +58,14 @@ function($scope , $q , $window , $location , egCore , checkinSvc , egGridDataPro
         suppress_popups = set['ui.circ.suppress_checkin_popups'];
     });
 
+    $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
+    }
+
     // checkin & hold capture modifiers
     var modifiers = [
         'void_overdues',