From bdab7264af09bbde031a9ab1216a989d58d12fcb Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Thu, 31 Jul 2014 18:08:40 +0200 Subject: [PATCH] sort by asc amount --- public/app/js/main/controllers/BalanceCtrl.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/public/app/js/main/controllers/BalanceCtrl.js b/public/app/js/main/controllers/BalanceCtrl.js index 7077b6ac..694763a8 100644 --- a/public/app/js/main/controllers/BalanceCtrl.js +++ b/public/app/js/main/controllers/BalanceCtrl.js @@ -216,7 +216,9 @@ app.controller( 'BalanceCtrl', + ( $scope.now.month() + 1 ) + '&categories=Expenses' ) .then( function( response ) { - $scope.balance.expenses = response.data; + $scope.balance.expenses = _(response.data).sortBy( function( account ) { + return account.amount; + } ); $scope.balance.expenses_total = _(response.data).reduce( function( memo, account ){ return memo + account.amount; }, 0 ); } ); $http.get( '/api/ledger/balance?period=' @@ -225,7 +227,9 @@ app.controller( 'BalanceCtrl', + ( $scope.now.month() + 1 ) + '&categories=Income' ) .then( function( response ) { - $scope.balance.income = response.data; + $scope.balance.income = _(response.data).sortBy( function( account ) { + return account.amount; + } ); $scope.balance.income_total = _(response.data).reduce( function( memo, account ){ return memo + account.amount; }, 0 ); } ); };