Show budget, pt. 3
This commit is contained in:
@@ -24,7 +24,7 @@ public class Category {
|
|||||||
|
|
||||||
private Boolean retired = false;
|
private Boolean retired = false;
|
||||||
|
|
||||||
private Boolean incomeCategory = false;
|
private Boolean income = false;
|
||||||
|
|
||||||
private BigDecimal budget;
|
private BigDecimal budget;
|
||||||
|
|
||||||
@@ -64,12 +64,12 @@ public class Category {
|
|||||||
this.retired = retired;
|
this.retired = retired;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean isIncomeCategory() {
|
public Boolean isIncome() {
|
||||||
return incomeCategory;
|
return income;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIncomeCategory(Boolean incomeCategory) {
|
public void setIncome(Boolean income) {
|
||||||
this.incomeCategory = incomeCategory;
|
this.income = income;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getBudget() {
|
public BigDecimal getBudget() {
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
INSERT INTO User (id, name, username) VALUES (1, 'Adam', 'adam'), (2, 'Betty', 'betty'), (3, 'Curt', 'curt');
|
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 Account (id, name, owner_id) VALUES (1, 'Gemeinschaftskonto', 1), (2, 'Konto Adam', 1);
|
||||||
|
|
||||||
INSERT INTO Category (id, name, account_id, position, retired, budget) VALUES
|
INSERT INTO Category (id, name, account_id, position, retired, income, budget) VALUES
|
||||||
(null, 'Essen - Lebensmittel', 1, 2, false, 1000.0),
|
(null, 'Essen - Lebensmittel', 1, 2, false, false, 1000.0),
|
||||||
(null, 'Einnahmen - Gehalt', 1, 1, false, 70000.0),
|
(null, 'Einnahmen - Gehalt', 1, 1, false, true, 70000.0),
|
||||||
(null, 'Essen - Arbeit', 1, 3, false, 400.0),
|
(null, 'Essen - Arbeit', 1, 3, false, false, 400.0),
|
||||||
(null, 'Sonstiges - Projekt 1000', 1, 4, true, 2000.0),
|
(null, 'Sonstiges - Projekt 1000', 1, 4, true, false, 2000.0),
|
||||||
(null, 'Wohnen - Haushalt', 1, 5, false, 830.0),
|
(null, 'Wohnen - Haushalt', 1, 5, false, false, 830.0),
|
||||||
(null, 'Private Entnahme', 1, 6, false, 0.0),
|
(null, 'Private Entnahme', 1, 6, false, false, 0.0),
|
||||||
(null, 'Einnahmen - Gehalt', 2, 1, false, 50000.0),
|
(null, 'Einnahmen - Gehalt', 2, 1, false, true, 50000.0),
|
||||||
(null, 'Technik - Server und Hosting', 2, 2, false, 230.0),
|
(null, 'Technik - Server und Hosting', 2, 2, false, false, 230.0),
|
||||||
(null, 'Essen - Restaurant & Café', 1, 6, true, 380.0),
|
(null, 'Essen - Restaurant & Café', 1, 6, true, false, 380.0),
|
||||||
(null, 'Essen - Süßwaren & Genussmittel', 1, 7, true, 120.0),
|
(null, 'Essen - Süßwaren & Genussmittel', 1, 7, true, false, 120.0),
|
||||||
(null, 'Familie - Baby', 1, 8, true, 800.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);
|
INSERT INTO Account_User (account_id, user_id) VALUES (1, 1), (1, 2), (1, 3), (2, 1);
|
||||||
|
|
||||||
|
|||||||
@@ -117,16 +117,20 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$routePara
|
|||||||
return {value: data};
|
return {value: data};
|
||||||
}}}).getText();
|
}}}).getText();
|
||||||
expenseInfoMtl.$promise.then(function(data) {
|
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.spentMtl = (-expenseInfoMtl.value).toFixed(0);
|
||||||
$scope.transaction.category.percentageMtl = (-expenseInfoMtl.value / ($scope.transaction.category.budgetMtl / 100)).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) {
|
transformResponse: function(data, headersGetter, status) {
|
||||||
return {value: data};
|
return {value: data};
|
||||||
}}}).getText();
|
}}}).getText();
|
||||||
expenseInfoYrl.$promise.then(function(data) {
|
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.spentYrl = (-expenseInfoYrl.value).toFixed(0);
|
||||||
$scope.transaction.category.percentageYrl = (-expenseInfoYrl.value / ($scope.transaction.category.budget / 100)).toFixed(0);
|
$scope.transaction.category.percentageYrl = (-expenseInfoYrl.value / ($scope.transaction.category.budget / 100)).toFixed(0);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
|
<div class="budgetArea">
|
||||||
|
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 ng-show="accounts.length > 1">
|
<div ng-show="accounts.length > 1">
|
||||||
<select
|
<select
|
||||||
ng-model='account'
|
ng-model='account'
|
||||||
@@ -84,12 +90,6 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="budgetArea">
|
|
||||||
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">
|
<div class="row">
|
||||||
<table class="listing">
|
<table class="listing">
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -18,7 +18,9 @@ label {
|
|||||||
.budgetArea {
|
.budgetArea {
|
||||||
font-family: "Yanone Kaffeesatz", sans-serif;
|
font-family: "Yanone Kaffeesatz", sans-serif;
|
||||||
color: #eee;
|
color: #eee;
|
||||||
margin-top: .5em;
|
margin: .5em;
|
||||||
|
float: right;
|
||||||
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.budgetCalculation {
|
.budgetCalculation {
|
||||||
|
|||||||
Reference in New Issue
Block a user