diff --git a/src/main/java/de/tilman/transactions/domain/Category.java b/src/main/java/de/tilman/transactions/domain/Category.java index f37e07c..57ab15e 100644 --- a/src/main/java/de/tilman/transactions/domain/Category.java +++ b/src/main/java/de/tilman/transactions/domain/Category.java @@ -24,7 +24,7 @@ public class Category { private Boolean retired = false; - private Boolean incomeCategory = false; + private Boolean income = false; private BigDecimal budget; @@ -64,12 +64,12 @@ public class Category { this.retired = retired; } - public Boolean isIncomeCategory() { - return incomeCategory; + public Boolean isIncome() { + return income; } - public void setIncomeCategory(Boolean incomeCategory) { - this.incomeCategory = incomeCategory; + public void setIncome(Boolean income) { + this.income = income; } public BigDecimal getBudget() { diff --git a/src/main/resources/data-h2.sql b/src/main/resources/data-h2.sql index 974cc3b..7088ac5 100644 --- a/src/main/resources/data-h2.sql +++ b/src/main/resources/data-h2.sql @@ -1,18 +1,18 @@ INSERT INTO User (id, name, username) VALUES (1, 'Adam', 'adam'), (2, 'Betty', 'betty'), (3, 'Curt', 'curt'); INSERT INTO Account (id, name, owner_id) VALUES (1, 'Gemeinschaftskonto', 1), (2, 'Konto Adam', 1); -INSERT INTO Category (id, name, account_id, position, retired, budget) VALUES - (null, 'Essen - Lebensmittel', 1, 2, false, 1000.0), - (null, 'Einnahmen - Gehalt', 1, 1, false, 70000.0), - (null, 'Essen - Arbeit', 1, 3, false, 400.0), - (null, 'Sonstiges - Projekt 1000', 1, 4, true, 2000.0), - (null, 'Wohnen - Haushalt', 1, 5, false, 830.0), - (null, 'Private Entnahme', 1, 6, false, 0.0), - (null, 'Einnahmen - Gehalt', 2, 1, false, 50000.0), - (null, 'Technik - Server und Hosting', 2, 2, false, 230.0), - (null, 'Essen - Restaurant & Café', 1, 6, true, 380.0), - (null, 'Essen - Süßwaren & Genussmittel', 1, 7, true, 120.0), - (null, 'Familie - Baby', 1, 8, true, 800.0); +INSERT INTO Category (id, name, account_id, position, retired, income, budget) VALUES + (null, 'Essen - Lebensmittel', 1, 2, false, false, 1000.0), + (null, 'Einnahmen - Gehalt', 1, 1, false, true, 70000.0), + (null, 'Essen - Arbeit', 1, 3, false, false, 400.0), + (null, 'Sonstiges - Projekt 1000', 1, 4, true, false, 2000.0), + (null, 'Wohnen - Haushalt', 1, 5, false, false, 830.0), + (null, 'Private Entnahme', 1, 6, false, false, 0.0), + (null, 'Einnahmen - Gehalt', 2, 1, false, true, 50000.0), + (null, 'Technik - Server und Hosting', 2, 2, false, false, 230.0), + (null, 'Essen - Restaurant & Café', 1, 6, true, false, 380.0), + (null, 'Essen - Süßwaren & Genussmittel', 1, 7, true, false, 120.0), + (null, 'Familie - Baby', 1, 8, true, false, 800.0); INSERT INTO Account_User (account_id, user_id) VALUES (1, 1), (1, 2), (1, 3), (2, 1); diff --git a/src/main/resources/static/app/controllers.js b/src/main/resources/static/app/controllers.js index 25f17d2..143e3c6 100644 --- a/src/main/resources/static/app/controllers.js +++ b/src/main/resources/static/app/controllers.js @@ -117,16 +117,20 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$routePara return {value: data}; }}}).getText(); expenseInfoMtl.$promise.then(function(data) { +// console.log(expenseInfoMtl.value); + if ($scope.transaction.category.income) + expenseInfoMtl.value = -expenseInfoMtl.value; $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': { + var expenseInfoYrl = $resource('/api/categories/search/expenseLevelYear', { accountId: $scope.account.id, categoryId: $scope.transaction.category.id }, {'getText': { transformResponse: function(data, headersGetter, status) { return {value: data}; }}}).getText(); expenseInfoYrl.$promise.then(function(data) { + if ($scope.transaction.category.income) + expenseInfoYrl.value = -expenseInfoYrl.value; $scope.transaction.category.spentYrl = (-expenseInfoYrl.value).toFixed(0); $scope.transaction.category.percentageYrl = (-expenseInfoYrl.value / ($scope.transaction.category.budget / 100)).toFixed(0); }); diff --git a/src/main/resources/static/app/transaction-list.html b/src/main/resources/static/app/transaction-list.html index 9b9c7a5..bf1a955 100644 --- a/src/main/resources/static/app/transaction-list.html +++ b/src/main/resources/static/app/transaction-list.html @@ -1,6 +1,12 @@