mirror of
https://github.com/gwenhael-le-moine/ledgerrb.git
synced 2025-01-10 05:24:24 +01:00
26 lines
838 B
JavaScript
26 lines
838 B
JavaScript
app.controller( 'BalanceCtrl',
|
|
[ '$scope', '$http',
|
|
function( $scope, $http ) {
|
|
var now = new Date();
|
|
|
|
$scope.xFunction = function() {
|
|
return function( d ) {
|
|
return d.account;
|
|
};
|
|
};
|
|
$scope.yFunction = function() {
|
|
return function( d ) {
|
|
return d.amount;
|
|
};
|
|
};
|
|
$scope.balance = { expenses: [],
|
|
income: [] };
|
|
$http.get( '/api/ledger/balance?period=' + now.getFullYear() + '-' + now.getMonth() + '&categories=Expenses' )
|
|
.then( function( response ) {
|
|
$scope.balance.expenses = response.data;
|
|
} );
|
|
$http.get( '/api/ledger/balance?period=' + now.getFullYear() + '-' + now.getMonth() + '&categories=Income' )
|
|
.then( function( response ) {
|
|
$scope.balance.income = response.data;
|
|
} );
|
|
}]);
|