Show budget, pt. 2
This commit is contained in:
@@ -105,18 +105,33 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$routePara
|
||||
$scope.checkCategory = function() {
|
||||
|
||||
// get current expense level for category
|
||||
$scope.transaction.category.percentage = 0;
|
||||
$scope.transaction.category.percentageMtl = 0;
|
||||
$scope.transaction.category.spentMtl = 0;
|
||||
$scope.transaction.category.budgetMtl = ($scope.transaction.category.budget / 12).toFixed(0);
|
||||
$scope.transaction.category.percentageYrl = 0;
|
||||
$scope.transaction.category.spentYrl = 0;
|
||||
|
||||
// https://stackoverflow.com/a/30119263
|
||||
var budgetInfo = $resource('/api/categories/search/expenseLevelYear', { accountId: $scope.account.id, categoryId: $scope.transaction.category.id }, {'getText': {
|
||||
var expenseInfoMtl = $resource('/api/categories/search/expenseLevelMonth', { accountId: $scope.account.id, categoryId: $scope.transaction.category.id }, {'getText': {
|
||||
transformResponse: function(data, headersGetter, status) {
|
||||
return {value: data};
|
||||
}}}).getText();
|
||||
budgetInfo.$promise.then(function(data) {
|
||||
$scope.transaction.category.percentage = parseFloat(budgetInfo.value) + 5;
|
||||
expenseInfoMtl.$promise.then(function(data) {
|
||||
$scope.transaction.category.spentMtl = (-expenseInfoMtl.value).toFixed(0);
|
||||
$scope.transaction.category.percentageMtl = (-expenseInfoMtl.value / ($scope.transaction.category.budgetMtl / 100)).toFixed(0);
|
||||
// console.log(budgetInfo.value);
|
||||
});
|
||||
|
||||
var expenseInfoYrl = $resource('/api/categories/search/expenseLevelMonth', { accountId: $scope.account.id, categoryId: $scope.transaction.category.id }, {'getText': {
|
||||
transformResponse: function(data, headersGetter, status) {
|
||||
return {value: data};
|
||||
}}}).getText();
|
||||
expenseInfoYrl.$promise.then(function(data) {
|
||||
$scope.transaction.category.spentYrl = (-expenseInfoYrl.value).toFixed(0);
|
||||
$scope.transaction.category.percentageYrl = (-expenseInfoYrl.value / ($scope.transaction.category.budget / 100)).toFixed(0);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -85,7 +85,9 @@
|
||||
</div>
|
||||
|
||||
<div class="budgetArea">
|
||||
Budget: <span class="budgetCalculation"><span ng-bind="transaction.category.budget"></span> <span ng-bind="transaction.category.percentage"></span></span>
|
||||
Monat: <span class="budgetCalculation"><span ng-bind="transaction.category.spentMtl"></span> / <span ng-bind="transaction.category.budgetMtl"></span> € (<span ng-bind="transaction.category.percentageMtl"></span>%)</span>
|
||||
<br/>
|
||||
Jahr: <span class="budgetCalculation"><span ng-bind="transaction.category.spentYrl"></span> / <span ng-bind="transaction.category.budget"></span> € (<span ng-bind="transaction.category.percentageYrl"></span>%)</span>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
Reference in New Issue
Block a user