Fix transaction saving/loading
This commit is contained in:
parent
518ec83708
commit
d22fc6f7cc
6 changed files with 8 additions and 8 deletions
|
@ -137,7 +137,7 @@ export class BudgetDetailsComponent implements OnInit {
|
||||||
this.twigsService.getTransactions(this.budget.id, category).subscribe(transactions => {
|
this.twigsService.getTransactions(this.budget.id, category).subscribe(transactions => {
|
||||||
let balance = 0;
|
let balance = 0;
|
||||||
for (const transaction of transactions) {
|
for (const transaction of transactions) {
|
||||||
if (transaction.isExpense) {
|
if (transaction.expense) {
|
||||||
balance -= transaction.amount;
|
balance -= transaction.amount;
|
||||||
} else {
|
} else {
|
||||||
balance += transaction.amount;
|
balance += transaction.amount;
|
||||||
|
|
|
@ -46,7 +46,7 @@ export class CategoriesComponent implements OnInit {
|
||||||
this.twigsService.getTransactions(this.budgetId, category.id).subscribe(transactions => {
|
this.twigsService.getTransactions(this.budgetId, category.id).subscribe(transactions => {
|
||||||
let balance = 0;
|
let balance = 0;
|
||||||
for (const transaction of transactions) {
|
for (const transaction of transactions) {
|
||||||
if (transaction.isExpense) {
|
if (transaction.expense) {
|
||||||
balance -= transaction.amount;
|
balance -= transaction.amount;
|
||||||
} else {
|
} else {
|
||||||
balance += transaction.amount;
|
balance += transaction.amount;
|
||||||
|
|
|
@ -131,7 +131,7 @@ export class TwigsHttpService implements TwigsService {
|
||||||
description: string,
|
description: string,
|
||||||
amount: number,
|
amount: number,
|
||||||
date: Date,
|
date: Date,
|
||||||
isExpense: boolean,
|
expense: boolean,
|
||||||
category: number
|
category: number
|
||||||
): Observable<Transaction> {
|
): Observable<Transaction> {
|
||||||
const params = {
|
const params = {
|
||||||
|
@ -139,7 +139,7 @@ export class TwigsHttpService implements TwigsService {
|
||||||
'description': description,
|
'description': description,
|
||||||
'date': date,
|
'date': date,
|
||||||
'amount': amount,
|
'amount': amount,
|
||||||
'expense': isExpense,
|
'expense': expense,
|
||||||
'categoryId': category,
|
'categoryId': category,
|
||||||
'budgetId': budgetId
|
'budgetId': budgetId
|
||||||
};
|
};
|
||||||
|
|
|
@ -249,7 +249,7 @@ export class TwigsLocalService implements TwigsService {
|
||||||
transaction.description = description;
|
transaction.description = description;
|
||||||
transaction.amount = amount;
|
transaction.amount = amount;
|
||||||
transaction.date = date;
|
transaction.date = date;
|
||||||
transaction.isExpense = isExpense;
|
transaction.expense = isExpense;
|
||||||
transaction.categoryId = category;
|
transaction.categoryId = category;
|
||||||
transaction.budgetId = budgetId;
|
transaction.budgetId = budgetId;
|
||||||
transaction.id = this.transactions.length + 1;
|
transaction.id = this.transactions.length + 1;
|
||||||
|
|
|
@ -77,7 +77,7 @@ export class AddEditTransactionComponent implements OnInit, OnChanges, OnDestroy
|
||||||
amount: this.currentTransaction.amount * 100,
|
amount: this.currentTransaction.amount * 100,
|
||||||
date: this.currentTransaction.date,
|
date: this.currentTransaction.date,
|
||||||
category: this.currentTransaction.categoryId,
|
category: this.currentTransaction.categoryId,
|
||||||
isExpense: this.currentTransaction.isExpense
|
expense: this.currentTransaction.expense
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -88,7 +88,7 @@ export class AddEditTransactionComponent implements OnInit, OnChanges, OnDestroy
|
||||||
this.currentTransaction.description,
|
this.currentTransaction.description,
|
||||||
this.currentTransaction.amount * 100,
|
this.currentTransaction.amount * 100,
|
||||||
this.currentTransaction.date,
|
this.currentTransaction.date,
|
||||||
this.currentTransaction.isExpense,
|
this.currentTransaction.expense,
|
||||||
this.currentTransaction.categoryId,
|
this.currentTransaction.categoryId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ export class Transaction {
|
||||||
description: string = null;
|
description: string = null;
|
||||||
date: Date = new Date();
|
date: Date = new Date();
|
||||||
amount: number;
|
amount: number;
|
||||||
isExpense: boolean;
|
expense: boolean;
|
||||||
categoryId: number;
|
categoryId: number;
|
||||||
budgetId: number;
|
budgetId: number;
|
||||||
createdBy: number;
|
createdBy: number;
|
||||||
|
|
Loading…
Reference in a new issue