Show budget, pt. 3
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
<div class="container">
|
||||
<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">
|
||||
<select
|
||||
ng-model='account'
|
||||
@@ -84,12 +90,6 @@
|
||||
</form>
|
||||
</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">
|
||||
<table class="listing">
|
||||
<tr>
|
||||
|
||||
@@ -18,7 +18,9 @@ label {
|
||||
.budgetArea {
|
||||
font-family: "Yanone Kaffeesatz", sans-serif;
|
||||
color: #eee;
|
||||
margin-top: .5em;
|
||||
margin: .5em;
|
||||
float: right;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.budgetCalculation {
|
||||
|
||||
Reference in New Issue
Block a user