diff --git a/ui/hv2-ui/src/app/account/account.component.html b/ui/hv2-ui/src/app/account/account.component.html index b2aea9e..e07279e 100644 --- a/ui/hv2-ui/src/app/account/account.component.html +++ b/ui/hv2-ui/src/app/account/account.component.html @@ -10,9 +10,9 @@ Jahr - + Kategorie - + {{p.description}} @@ -22,7 +22,7 @@ Beschreibung - + @@ -52,7 +52,7 @@ Saldo: {{saldo?.saldo | number:'1.2-2'}} € Betrag {{element.rawAccountEntry.amount | number:'1.2-2'}} € - + Kategorie {{element.accountEntryCategory}} diff --git a/ui/hv2-ui/src/app/account/account.component.ts b/ui/hv2-ui/src/app/account/account.component.ts index 3df2285..3ad9853 100644 --- a/ui/hv2-ui/src/app/account/account.component.ts +++ b/ui/hv2-ui/src/app/account/account.component.ts @@ -37,7 +37,7 @@ export class AccountComponent implements OnInit { account: Account accountEntries: DN_AccountEntry[] accountEntriesDataSource: MatTableDataSource - accountEntriesDisplayedColumns: string[] = [ "description", "document_no", "amount", "createdAt", "fiscalYear", "accountEntryCategory", "overhead_relevant" ] + accountEntriesDisplayedColumns: string[] = [ "description", "document_no", "amount", "createdAt", "fiscalYear", "category", "overhead_relevant" ] saldo: Saldo accountEntryCategories: AccountEntryCategory[] @@ -45,6 +45,8 @@ export class AccountComponent implements OnInit { accountEntryCategoriesInverseMap: Map presetFiscalYear: FormControl + presetCategory: FormControl + presetDescription: FormControl constructor( private accountService: AccountService, @@ -99,23 +101,14 @@ export class AccountComponent implements OnInit { let uniquenumber: UniqueNumber = await this.extApiService.getUniqueNumber(); this.messageService.add(`Got unique number as document_no: ${uniquenumber.number}`) let newAccountEntry: AccountEntry = { - description: formData.value.description, + description: this.presetDescription.value, account: this.account.id, created_at: formData.value.createdAt, fiscal_year: this.presetFiscalYear.value, amount: formData.value.amount, id: 0, document_no: uniquenumber.number, - account_entry_category: 0 - } - - if (this.shallBeRentPayment) { - newAccountEntry.account_entry_category = this.accountEntryCategoriesInverseMap.get('Mietzahlung').id - newAccountEntry.description = "Miete" - this.messageService.add(`shall be rentpayment, category is ${newAccountEntry.account_entry_category}`) - } else { - newAccountEntry.account_entry_category = formData.value.category - this.messageService.add(`category is ${newAccountEntry.account_entry_category}`) + account_entry_category: this.presetCategory.value } this.messageService.add(`addAccountEntry: ${ JSON.stringify(newAccountEntry, undefined, 4) }`) @@ -149,12 +142,25 @@ export class AccountComponent implements OnInit { } private async init(): Promise { + this.messageService.add(`AccountComponent.init start, account: ${this.selectedAccountId}`) let currentDate = new Date() let y = currentDate.getFullYear() this.presetFiscalYear = new FormControl(y) + + this.messageService.add(`AccountComponent.init a, account: ${this.selectedAccountId}`) + await this.getAccountEntryCategories() + + if (this.shallBeRentPayment) { + this.messageService.add(`AccountComponent.init b, account: ${this.selectedAccountId}`) + this.presetCategory = new FormControl(this.accountEntryCategoriesInverseMap.get('Mietzahlung').id) + this.messageService.add(`AccountComponent.init c, account: ${this.selectedAccountId}`) + this.presetDescription = new FormControl("Miete") + this.messageService.add(`shall be rentpayment`) + this.messageService.add(`AccountComponent.init d, account: ${this.selectedAccountId}`) + } + this.messageService.add(`AccountComponent.init, account: ${this.selectedAccountId}`) this.getAccount() - await this.getAccountEntryCategories() }