This commit is contained in:
Gwenhael Le Moine 2015-05-24 11:46:05 +02:00
parent 6549a17c95
commit ff892ddadb
2 changed files with 19 additions and 4 deletions

View file

@ -88,9 +88,24 @@ app.controller( 'DashboardCtrl',
} );
}
bucket.total = _( bucket.data ).reduce( function ( memo, account ) {
return memo + account.amount;
}, 0 );
bucket.total_detailed = _.chain( bucket.data )
.groupBy( function( account ) {
return account.account.split(':')[0];
} )
.each( function( category ) {
category.total = _( category ).reduce( function ( memo, account ) {
return memo + account.amount;
}, 0 );
} )
.value();
bucket.total_detailed = _.chain(bucket.total_detailed)
.keys()
.map( function( key ) {
return { account: key,
amount: bucket.total_detailed[key].total };
} )
.value();
} );
};

View file

@ -19,7 +19,7 @@
<md-card flex="48" layout="column"
data-ng-repeat="bucket in balance.buckets">
<md-toolbar>
<h3>{{bucket.categories}}, total = {{bucket.total | number:2}} €</h3>
<h4 data-ng-repeat="account in bucket.total_detailed">{{account.account}}, total = {{account.amount | number:2}} €</h4>
<!-- <md-slider discrete
aria-label="score threshold"
min="0" max="10" step="1"