fixes
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
table {
|
||||
width: 75%;
|
||||
border-spacing: 20px;
|
||||
}
|
||||
|
||||
.spacer {
|
||||
@ -23,9 +24,10 @@ table {
|
||||
}
|
||||
|
||||
.rightaligned {
|
||||
justify-self: right;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.large {
|
||||
font-size: large;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,12 @@
|
||||
<mat-datepicker-toggle matSuffix [for]="createdAtPicker"></mat-datepicker-toggle>
|
||||
<mat-datepicker #createdAtPicker></mat-datepicker>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Kategorie</mat-label>
|
||||
<mat-select [(ngModel)]="newAccountEntry.account_entry_category" name="category" disabled="shallBeRentPayment">
|
||||
<mat-option *ngFor="let p of accountEntryCategories" [value]="p.id">{{p.description}}</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Betrag (€)</mat-label>
|
||||
<input matInput type="number" name="amount" [(ngModel)]="newAccountEntry.amount"/>
|
||||
@ -39,17 +45,25 @@
|
||||
</div>
|
||||
<div id="secondBlock">
|
||||
<table mat-table [dataSource]="accountEntriesDataSource" #zftable>
|
||||
<ng-container matColumnDef="createdAt">
|
||||
<th mat-header-cell *matHeaderCellDef>Datum</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.rawAccountEntry.created_at | date}}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="description">
|
||||
<th mat-header-cell *matHeaderCellDef>Beschreibung</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.description}}</td>
|
||||
<td mat-cell *matCellDef="let element">{{element.rawAccountEntry.description}}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="amount">
|
||||
<th mat-header-cell *matHeaderCellDef>Betrag</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.amount | number:'1.2-2'}} €</td>
|
||||
<td mat-cell *matCellDef="let element" class="rightaligned">{{element.rawAccountEntry.amount | number:'1.2-2'}} €</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="createdAt">
|
||||
<th mat-header-cell *matHeaderCellDef>Datum</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.created_at | date}}</td>
|
||||
<ng-container matColumnDef="category">
|
||||
<th mat-header-cell *matHeaderCellDef>Kategorie</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.accountEntryCategory}}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="overhead_relevant">
|
||||
<th mat-header-cell *matHeaderCellDef>BK relevant</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.overheadRelevant}}</td>
|
||||
</ng-container>
|
||||
<tr mat-header-row *matHeaderRowDef="accountEntriesDisplayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: accountEntriesDisplayedColumns;"></tr>
|
||||
|
@ -1,12 +1,21 @@
|
||||
import { Component, Input, OnInit, OnChanges, ViewChild } from '@angular/core';
|
||||
import { MatButton } from '@angular/material/button';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
import { AccountEntryService, AccountService } from '../data-object-service';
|
||||
import { Account, AccountEntry, NULL_AccountEntry } from '../data-objects';
|
||||
import { AccountEntryCategoryService, AccountEntryService, AccountService } from '../data-object-service';
|
||||
import { Account, AccountEntry, AccountEntryCategory, NULL_AccountEntry } from '../data-objects';
|
||||
import { ExtApiService } from '../ext-data-object-service';
|
||||
import { Saldo } from '../ext-data-objects';
|
||||
import { MessageService } from '../message.service';
|
||||
|
||||
|
||||
|
||||
interface DN_AccountEntry {
|
||||
rawAccountEntry: AccountEntry
|
||||
accountEntryCategory: string
|
||||
overheadRelevant: boolean
|
||||
}
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-account',
|
||||
templateUrl: './account.component.html',
|
||||
@ -15,16 +24,20 @@ import { MessageService } from '../message.service';
|
||||
export class AccountComponent implements OnInit {
|
||||
|
||||
@Input() selectedAccountId: number
|
||||
@Input() shallBeRentPayment: boolean
|
||||
@ViewChild('addAccountEntryButton') addAccountEntryButton: MatButton
|
||||
|
||||
collapse: boolean = false
|
||||
|
||||
account: Account
|
||||
accountEntries: AccountEntry[]
|
||||
accountEntriesDataSource: MatTableDataSource<AccountEntry>
|
||||
accountEntriesDisplayedColumns: string[] = [ "description", "amount", "createdAt" ]
|
||||
accountEntries: DN_AccountEntry[]
|
||||
accountEntriesDataSource: MatTableDataSource<DN_AccountEntry>
|
||||
accountEntriesDisplayedColumns: string[] = [ "description", "amount", "createdAt", "category", "overhead_relevant" ]
|
||||
saldo: Saldo
|
||||
|
||||
accountEntryCategories: AccountEntryCategory[]
|
||||
accountEntryCategoriesMap: Map<number, AccountEntryCategory>
|
||||
accountEntryCategoriesInverseMap: Map<string, AccountEntryCategory>
|
||||
|
||||
newAccountEntry: AccountEntry = NULL_AccountEntry
|
||||
|
||||
@ -33,6 +46,7 @@ export class AccountComponent implements OnInit {
|
||||
private accountService: AccountService,
|
||||
private accountEntryService: AccountEntryService,
|
||||
private extApiService: ExtApiService,
|
||||
private accountEntryCategoryService: AccountEntryCategoryService,
|
||||
private messageService: MessageService
|
||||
) { }
|
||||
|
||||
@ -51,12 +65,23 @@ export class AccountComponent implements OnInit {
|
||||
|
||||
async getAccountEntries(): Promise<void> {
|
||||
try {
|
||||
this.accountEntries = await this.accountEntryService.getAccountEntrysByAccount(this.selectedAccountId)
|
||||
this.accountEntries.reverse()
|
||||
this.messageService.add(`AccountEntries: ${JSON.stringify(this.accountEntries, undefined, 4)}`)
|
||||
this.accountEntriesDataSource = new MatTableDataSource<AccountEntry>(this.accountEntries)
|
||||
const rawAccountEntries = await this.accountEntryService.getAccountEntrysByAccount(this.selectedAccountId)
|
||||
rawAccountEntries.reverse()
|
||||
this.messageService.add(`AccountEntries: ${JSON.stringify(rawAccountEntries, undefined, 4)}`)
|
||||
this.accountEntries = []
|
||||
for (let f of rawAccountEntries) {
|
||||
this.accountEntries.push({
|
||||
rawAccountEntry: f,
|
||||
accountEntryCategory: this.accountEntryCategoriesMap.get(f.account_entry_category).description,
|
||||
overheadRelevant: this.accountEntryCategoriesMap.get(f.account_entry_category).overhead_relevant
|
||||
})
|
||||
}
|
||||
|
||||
this.accountEntriesDataSource = new MatTableDataSource<DN_AccountEntry>(this.accountEntries)
|
||||
this.saldo = await this.extApiService.getAccountSaldo(this.selectedAccountId)
|
||||
} catch (err) {
|
||||
throw err
|
||||
|
||||
this.messageService.add(`Error in getAccountEntries: ${JSON.stringify(err, undefined, 4)}`)
|
||||
}
|
||||
}
|
||||
@ -68,7 +93,7 @@ export class AccountComponent implements OnInit {
|
||||
this.messageService.add(`addAccountEntry: ${ JSON.stringify(this.newAccountEntry, undefined, 4) }`)
|
||||
this.newAccountEntry = await this.accountEntryService.postAccountEntry(this.newAccountEntry)
|
||||
this.messageService.add(`New accountEntry created: ${this.newAccountEntry.id}`)
|
||||
this.newAccountEntry = { 'account': this.account.id, 'amount': undefined, 'created_at': '', 'description': '', 'id': 0 }
|
||||
this.newAccountEntry = { 'account': this.account.id, 'amount': undefined, 'created_at': '', 'description': '', 'id': 0, 'account_entry_category': 0 }
|
||||
this.getAccountEntries()
|
||||
} catch (err) {
|
||||
this.messageService.add(`Error in addAccountEntry: ${JSON.stringify(err, undefined, 4)}`)
|
||||
@ -77,14 +102,38 @@ export class AccountComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.messageService.add(`AccountComponent.ngOnInit, account: ${this.selectedAccountId}`)
|
||||
async getAccountEntryCategories(): Promise<void> {
|
||||
try {
|
||||
this.accountEntryCategories = await this.accountEntryCategoryService.getAccountEntryCategorys()
|
||||
this.accountEntryCategoriesMap = new Map<number, AccountEntryCategory>()
|
||||
this.accountEntryCategoriesInverseMap = new Map<string, AccountEntryCategory>()
|
||||
for (let p of this.accountEntryCategories) {
|
||||
this.accountEntryCategoriesMap.set(p.id, p)
|
||||
this.accountEntryCategoriesInverseMap.set(p.description, p)
|
||||
}
|
||||
|
||||
this.messageService.add(`getAccountEntryCategories: ${JSON.stringify(this.accountEntryCategories, undefined, 4)}`)
|
||||
} catch (err) {
|
||||
this.messageService.add(`Error in getAccountEntryCategories: ${JSON.stringify(err, undefined, 4)}`)
|
||||
}
|
||||
}
|
||||
|
||||
private async init(): Promise<void> {
|
||||
this.messageService.add(`AccountComponent.init, account: ${this.selectedAccountId}`)
|
||||
this.getAccount()
|
||||
await this.getAccountEntryCategories()
|
||||
if (this.shallBeRentPayment) {
|
||||
this.messageService.add('shall be rentpayment')
|
||||
this.newAccountEntry.account_entry_category = this.accountEntryCategoriesInverseMap.get('Mietzahlung').id
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.init()
|
||||
}
|
||||
|
||||
ngOnChanges(): void {
|
||||
this.messageService.add(`AccountComponent.ngOnChanges, account: ${this.selectedAccountId}`)
|
||||
this.getAccount()
|
||||
this.init()
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user