more ledger stuff

This commit is contained in:
2021-10-31 22:27:00 +01:00
parent 2b883aee02
commit 797151d547
2 changed files with 36 additions and 8 deletions

View File

@ -1,5 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { AccountService } from '../data-object-service';
import { Account } from '../data-objects';
import { ExtApiService } from '../ext-data-object-service';
import { MessageService } from '../message.service';
@ -11,8 +10,14 @@ import { MessageService } from '../message.service';
})
export class LedgerComponent implements OnInit {
account: Account
accountId: number
incomeAccount: Account
incomeAccountId: number
expenseAccount: Account
expenseAccountId: number
collapseIncomeDetails: boolean = false
collapseExpenseDetails: boolean = false
constructor(
private extApiService: ExtApiService,
@ -22,7 +27,8 @@ export class LedgerComponent implements OnInit {
async getAccount(): Promise<void> {
try {
this.messageService.add("Trying to load ledger account")
this.account = await this.extApiService.getAccountByDescription('Ledger')
this.incomeAccount = await this.extApiService.getAccountByDescription('LedgerIncome')
this.expenseAccount = await this.extApiService.getAccountByDescription('LedgerExpense')
this.messageService.add("Account loaded")
} catch (err) {
this.messageService.add(JSON.stringify(err, undefined, 4))
@ -31,7 +37,8 @@ export class LedgerComponent implements OnInit {
async ngOnInit(): Promise<void> {
await this.getAccount()
this.accountId = this.account.id
this.incomeAccountId = this.incomeAccount.id
this.expenseAccountId = this.expenseAccount.id
}
}