registers as pie charts details
This commit is contained in:
parent
ad409cde9f
commit
27f149140a
1 changed files with 43 additions and 11 deletions
|
@ -1,6 +1,6 @@
|
||||||
app.controller( 'BalanceCtrl',
|
app.controller( 'BalanceCtrl',
|
||||||
[ '$scope', '$http',
|
[ '$scope', '$http', '$filter',
|
||||||
function( $scope, $http ) {
|
function( $scope, $http, $filter ) {
|
||||||
$scope.now = moment();
|
$scope.now = moment();
|
||||||
$scope.previous_period = function() {
|
$scope.previous_period = function() {
|
||||||
$scope.now.subtract( 'months', 1 );
|
$scope.now.subtract( 'months', 1 );
|
||||||
|
@ -23,10 +23,10 @@ app.controller( 'BalanceCtrl',
|
||||||
};
|
};
|
||||||
$scope.toolTipContentFunction = function() {
|
$scope.toolTipContentFunction = function() {
|
||||||
return function( key, x, y, e, graph ) {
|
return function( key, x, y, e, graph ) {
|
||||||
return '<h4>' + key + '</h4>' +
|
return $filter( 'json' )( $scope.balance.details[ key ] );
|
||||||
'<h3>' + x + ' €</h3>';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.colorsIncome = function() {
|
$scope.colorsIncome = function() {
|
||||||
var colors = [
|
var colors = [
|
||||||
'#00ff00', //Income:CAF:APL
|
'#00ff00', //Income:CAF:APL
|
||||||
|
@ -206,10 +206,11 @@ app.controller( 'BalanceCtrl',
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.balance = { expenses: [],
|
|
||||||
income: [] };
|
|
||||||
|
|
||||||
var retrieve_data = function() {
|
var retrieve_data = function() {
|
||||||
|
$scope.balance = { expenses: [],
|
||||||
|
income: [],
|
||||||
|
details: {} };
|
||||||
|
|
||||||
$http.get( '/api/ledger/balance?period='
|
$http.get( '/api/ledger/balance?period='
|
||||||
+ $scope.now.year()
|
+ $scope.now.year()
|
||||||
+ '-'
|
+ '-'
|
||||||
|
@ -219,6 +220,18 @@ app.controller( 'BalanceCtrl',
|
||||||
$scope.balance.expenses = _(response.data).sortBy( function( account ) {
|
$scope.balance.expenses = _(response.data).sortBy( function( account ) {
|
||||||
return 1 / account.amount;
|
return 1 / account.amount;
|
||||||
} );
|
} );
|
||||||
|
_($scope.balance.expenses).each(
|
||||||
|
function( account ) {
|
||||||
|
$http.get( '/api/ledger/register?period='
|
||||||
|
+ $scope.now.year()
|
||||||
|
+ '-'
|
||||||
|
+ ( $scope.now.month() + 1 )
|
||||||
|
+ '&category='
|
||||||
|
+ account.account )
|
||||||
|
.then( function( response ) {
|
||||||
|
$scope.balance.details[ account.account ] = response.data;
|
||||||
|
} );
|
||||||
|
} );
|
||||||
$scope.balance.expenses_total = _(response.data).reduce( function( memo, account ){ return memo + account.amount; }, 0 );
|
$scope.balance.expenses_total = _(response.data).reduce( function( memo, account ){ return memo + account.amount; }, 0 );
|
||||||
} );
|
} );
|
||||||
$http.get( '/api/ledger/balance?period='
|
$http.get( '/api/ledger/balance?period='
|
||||||
|
@ -227,10 +240,29 @@ app.controller( 'BalanceCtrl',
|
||||||
+ ( $scope.now.month() + 1 )
|
+ ( $scope.now.month() + 1 )
|
||||||
+ '&categories=Income' )
|
+ '&categories=Income' )
|
||||||
.then( function( response ) {
|
.then( function( response ) {
|
||||||
$scope.balance.income = _(response.data).sortBy( function( account ) {
|
$scope.balance.income = _(response.data)
|
||||||
return account.amount;
|
.map( function( account ) {
|
||||||
} );
|
account.amount = account.amount * -1;
|
||||||
$scope.balance.income_total = _(response.data).reduce( function( memo, account ){ return memo + account.amount; }, 0 );
|
return account;
|
||||||
|
} );
|
||||||
|
$scope.balance.income = _($scope.balance.income)
|
||||||
|
.sortBy( function( account ) {
|
||||||
|
return account.amount;
|
||||||
|
} );
|
||||||
|
_($scope.balance.income)
|
||||||
|
.each( function( account ) {
|
||||||
|
$http.get( '/api/ledger/register?period='
|
||||||
|
+ $scope.now.year()
|
||||||
|
+ '-'
|
||||||
|
+ ( $scope.now.month() + 1 )
|
||||||
|
+ '&category='
|
||||||
|
+ account.account )
|
||||||
|
.then( function( response ) {
|
||||||
|
$scope.balance.details[ account.account ] = response.data;
|
||||||
|
} );
|
||||||
|
} );
|
||||||
|
$scope.balance.income_total = _(response.data)
|
||||||
|
.reduce( function( memo, account ){ return memo + account.amount; }, 0 );
|
||||||
} );
|
} );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue