Show budget, pt. 2
This commit is contained in:
@@ -12,6 +12,8 @@ curl --user adam@mail.com:test -i -X DELETE http://localhost:8080/transactions/4
|
|||||||
- account direkt in Transaction anzeigen http://docs.spring.io/spring-data/rest/docs/current/reference/html/#projections-excerpts.excerpting-commonly-accessed-data
|
- account direkt in Transaction anzeigen http://docs.spring.io/spring-data/rest/docs/current/reference/html/#projections-excerpts.excerpting-commonly-accessed-data
|
||||||
--> mit neuer Projektion: keine zusätzlichen GET-Requests für Creditor und Category, account per Parameter filtern (wie getDescriptionsByAccount), findFirst10 kann entfernt werden
|
--> mit neuer Projektion: keine zusätzlichen GET-Requests für Creditor und Category, account per Parameter filtern (wie getDescriptionsByAccount), findFirst10 kann entfernt werden
|
||||||
|
|
||||||
|
SELECT sum(t.amount) FROM Transaction t WHERE t.account_id = 1 AND t.category_id = 5 and DATE > (CURRENT_DATE() - DAY_OF_YEAR(CURRENT_DATE()))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Test-Datenbank lokal erreichbar machen:
|
# Test-Datenbank lokal erreichbar machen:
|
||||||
|
|||||||
@@ -105,18 +105,33 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$routePara
|
|||||||
$scope.checkCategory = function() {
|
$scope.checkCategory = function() {
|
||||||
|
|
||||||
// get current expense level for category
|
// 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
|
// 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) {
|
transformResponse: function(data, headersGetter, status) {
|
||||||
return {value: data};
|
return {value: data};
|
||||||
}}}).getText();
|
}}}).getText();
|
||||||
budgetInfo.$promise.then(function(data) {
|
expenseInfoMtl.$promise.then(function(data) {
|
||||||
$scope.transaction.category.percentage = parseFloat(budgetInfo.value) + 5;
|
$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);
|
// 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>
|
||||||
|
|
||||||
<div class="budgetArea">
|
<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>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|||||||
Reference in New Issue
Block a user