mirror of
https://github.com/gwenhael-le-moine/ledgerrb.git
synced 2025-01-26 07:58:10 +01:00
reduce API calls for details
This commit is contained in:
parent
24c0d03448
commit
f73a3d20ef
1 changed files with 6 additions and 9 deletions
|
@ -14,7 +14,7 @@ app.controller( 'BalanceCtrl',
|
|||
$scope.toolTipContentFunction = function () {
|
||||
return function ( key, x, y, e, graph ) {
|
||||
var details = $scope.balance.details[ key ];
|
||||
return '<material-content><h3>' + details.key + '</h3>' + '<table>' + _( details.values ).map( function ( transaction ) {
|
||||
return '<material-content><h3>' + details.key + '</h3>' + '<table>' + _( details ).map( function ( transaction ) {
|
||||
return '<tr><td>' + transaction.date + '</td><td>' + transaction.payee + '</td><td style="text-align: right">' + $filter( 'number' )( transaction.amount, 2 ) + ' ' + transaction.currency + '</td></tr>';
|
||||
} ).join( '' ) + '<tr><th></th><th>Total :</th><th>' + x + ' €</th></tr>' + '</table></material-content>';
|
||||
};
|
||||
|
@ -113,18 +113,15 @@ app.controller( 'BalanceCtrl',
|
|||
return 1 / account.amount;
|
||||
} )
|
||||
.value();
|
||||
_( bucket.data ).each(
|
||||
function ( account ) {
|
||||
API.register( { period: period,
|
||||
categories: account.account } )
|
||||
.then( function ( response ) {
|
||||
$scope.balance.details[ account.account ] = response.data;
|
||||
} );
|
||||
} );
|
||||
bucket.total = _( response.data ).reduce( function ( memo, account ) {
|
||||
return memo + account.amount;
|
||||
}, 0 );
|
||||
} );
|
||||
API.register( { period: period,
|
||||
categories: bucket.categories } )
|
||||
.then( function ( response ) {
|
||||
$scope.balance.details = _($scope.balance.details).extend( _(response.data.values).groupBy('account') );
|
||||
} );
|
||||
} );
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue