Merge branch 'master' of ssh://repo.hottis.de:2922/hv2/hv2-all-in-one
This commit is contained in:
commit
06e8a2f4bf
@ -116,7 +116,7 @@ $$;
|
||||
CREATE TRIGGER maintain_ledger_trigger
|
||||
AFTER INSERT ON account_entry_t
|
||||
FOR EACH ROW
|
||||
WHEN (NEW.account != 1000 AND NEW.account_entry_category NOT IN (3, 4))
|
||||
WHEN (NEW.account != 1000 AND NEW.account_entry_category NOT IN (3, 4, 29))
|
||||
EXECUTE FUNCTION maintain_ledger();
|
||||
|
||||
|
||||
|
@ -10,9 +10,9 @@
|
||||
<mat-label>Jahr</mat-label>
|
||||
<input matInput type="number" name="fiscalYear" [formControl]="presetFiscalYear" ngModel/>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline" *ngIf="!shallBeRentPayment">
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Kategorie</mat-label>
|
||||
<mat-select ngModel name="category" [disabled]="shallBeRentPayment">
|
||||
<mat-select ngModel name="category" [formControl]="presetCategory" >
|
||||
<mat-option *ngFor="let p of accountEntryCategories" [value]="p.id">{{p.description}}</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
@ -22,7 +22,7 @@
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Beschreibung</mat-label>
|
||||
<input matInput name="description" ngModel/>
|
||||
<input matInput name="description" [formControl]="presetDescription" ngModel/>
|
||||
</mat-form-field>
|
||||
<button #addAccountEntryButton type="submit" mat-raised-button color="primary">Buchung speichern</button>
|
||||
</form>
|
||||
@ -31,13 +31,13 @@
|
||||
Saldo: {{saldo?.saldo | number:'1.2-2'}} €
|
||||
</div>
|
||||
<div id="secondBlock">
|
||||
<table mat-table [dataSource]="accountEntriesDataSource" matSort #zftable>
|
||||
<table mat-table [dataSource]="accountEntriesDataSource" #zftable>
|
||||
<ng-container matColumnDef="createdAt">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>Datum</th>
|
||||
<th mat-header-cell *matHeaderCellDef >Datum</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.rawAccountEntry.created_at | date}}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="fiscalYear">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>Jahr</th>
|
||||
<th mat-header-cell *matHeaderCellDef >Jahr</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.rawAccountEntry.fiscal_year}}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="description">
|
||||
@ -45,7 +45,7 @@ Saldo: {{saldo?.saldo | number:'1.2-2'}} €
|
||||
<td mat-cell *matCellDef="let element">{{element.rawAccountEntry.description}}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="document_no">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>Belegnummer</th>
|
||||
<th mat-header-cell *matHeaderCellDef >Belegnummer</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.rawAccountEntry.document_no}}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="amount">
|
||||
@ -53,11 +53,11 @@ Saldo: {{saldo?.saldo | number:'1.2-2'}} €
|
||||
<td mat-cell *matCellDef="let element" class="rightaligned">{{element.rawAccountEntry.amount | number:'1.2-2'}} €</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="category">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>Kategorie</th>
|
||||
<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 mat-sort-header>BK relevant</th>
|
||||
<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>
|
||||
|
@ -31,6 +31,7 @@ export class AccountComponent implements OnInit {
|
||||
@Input() shallBeRentPayment: boolean
|
||||
@ViewChild('addAccountEntryButton') addAccountEntryButton: MatButton
|
||||
|
||||
|
||||
account: Account
|
||||
accountEntries: DN_AccountEntry[]
|
||||
accountEntriesDataSource: MatTableDataSource<DN_AccountEntry>
|
||||
@ -42,6 +43,8 @@ export class AccountComponent implements OnInit {
|
||||
accountEntryCategoriesInverseMap: Map<string, AccountEntryCategory>
|
||||
|
||||
presetFiscalYear: FormControl
|
||||
presetCategory: FormControl
|
||||
presetDescription: FormControl
|
||||
|
||||
constructor(
|
||||
private accountService: AccountService,
|
||||
@ -96,23 +99,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) }`)
|
||||
@ -146,12 +140,28 @@ export class AccountComponent implements OnInit {
|
||||
}
|
||||
|
||||
private async init(): Promise<void> {
|
||||
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}`)
|
||||
} else {
|
||||
this.presetCategory = new FormControl()
|
||||
this.presetDescription = new FormControl()
|
||||
}
|
||||
|
||||
this.messageService.add(`AccountComponent.init, account: ${this.selectedAccountId}`)
|
||||
this.getAccount()
|
||||
await this.getAccountEntryCategories()
|
||||
|
||||
}
|
||||
|
||||
@ -163,5 +173,4 @@ export class AccountComponent implements OnInit {
|
||||
this.init()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ import { EnterPaymentComponent } from './enter-payment/enter-payment.component';
|
||||
import { HomeComponent } from './home/home.component';
|
||||
import { LedgerComponent } from './ledger/ledger.component';
|
||||
import { ErrorDialogComponent } from './error-dialog/error-dialog.component'
|
||||
import { MatSortModule } from '@angular/material/sort';
|
||||
|
||||
registerLocaleData(localeDe)
|
||||
|
||||
@ -102,7 +103,8 @@ registerLocaleData(localeDe)
|
||||
MatSelectModule,
|
||||
MatDatepickerModule,
|
||||
MatNativeDateModule,
|
||||
MatExpansionModule
|
||||
MatExpansionModule,
|
||||
MatSortModule
|
||||
],
|
||||
exports: [
|
||||
MatMomentDateModule
|
||||
|
@ -5,6 +5,16 @@
|
||||
</mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<app-account #fallbackAccountComponent [selectedAccountId]="fallbackAccountId" [shallBeRentPayment]="false"></app-account>
|
||||
<div>
|
||||
<span>Konto auswählen: </span>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-select #mapSelect [(ngModel)]="accountId" name="account">
|
||||
<mat-label>Mieter</mat-label>
|
||||
<mat-option *ngFor="let p of accounts" [value]="p.id">{{p.description}}</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
||||
<app-account [selectedAccountId]="accountId" [shallBeRentPayment]="false"></app-account>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
@ -1,5 +1,6 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { AccountComponent } from '../account/account.component';
|
||||
import { AccountService } from '../data-object-service';
|
||||
import { Account } from '../data-objects';
|
||||
import { ExtApiService } from '../ext-data-object-service';
|
||||
import { MessageService } from '../message.service';
|
||||
@ -11,23 +12,23 @@ import { MessageService } from '../message.service';
|
||||
})
|
||||
export class LedgerComponent implements OnInit {
|
||||
|
||||
fallbackAccount: Account
|
||||
fallbackAccountId: number
|
||||
accounts: Account[]
|
||||
accountId: number
|
||||
|
||||
|
||||
@ViewChild('fallbackAccountComponent') fallbackAccountComponent: AccountComponent
|
||||
@ViewChild('accountComponent') accountComponent: AccountComponent
|
||||
|
||||
|
||||
constructor(
|
||||
private extApiService: ExtApiService,
|
||||
private accountService: AccountService,
|
||||
private messageService: MessageService
|
||||
) { }
|
||||
|
||||
async getAccount(): Promise<void> {
|
||||
try {
|
||||
this.messageService.add("Trying to load fallback account")
|
||||
this.fallbackAccount = await this.extApiService.getAccountByDescription('fallback_account')
|
||||
this.messageService.add("Account loaded")
|
||||
this.messageService.add("Trying to load accounts")
|
||||
this.accounts = await this.accountService.getAccounts()
|
||||
this.messageService.add("Accounts loaded")
|
||||
} catch (err) {
|
||||
this.messageService.add(JSON.stringify(err, undefined, 4))
|
||||
}
|
||||
@ -35,7 +36,6 @@ export class LedgerComponent implements OnInit {
|
||||
|
||||
async ngOnInit(): Promise<void> {
|
||||
await this.getAccount()
|
||||
this.fallbackAccountId = this.fallbackAccount.id
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user