account entry reference stuff

This commit is contained in:
Wolfgang Hottgenroth 2022-03-31 16:07:00 +02:00
parent b346cc07d0
commit 4391cc1d8b
Signed by: wn
GPG Key ID: E49AF3B9EF6DD469
5 changed files with 25 additions and 42 deletions

View File

@ -93,7 +93,21 @@ CREATE OR REPLACE FUNCTION maintain_ledger()
RETURNS TRIGGER RETURNS TRIGGER
LANGUAGE plpgsql LANGUAGE plpgsql
AS $$ AS $$
DECLARE
tenant RECORD;
adjusted_description text;
BEGIN BEGIN
IF ((NEW.description = 'Miete') AND (NEW.account_entry_category = 2)) THEN
SELECT firstname, lastname
INTO tenant
FROM tenant_t
WHERE account = NEW.account;
adjusted_description := 'Miete ' || extract(year from NEW.created_at)::text || ' ' || to_char(to_date(extract(month from NEW.created_at)::text, 'MM'), 'Month') || tenant.firstname || ' ' || tenant.lastname;
UPDATE account_entry_t
SET description = adjusted_description
WHERE id = NEW.id;
END IF;
INSERT INTO account_entry_reference_t (account, account_entry) VALUES (1000, NEW.id); INSERT INTO account_entry_reference_t (account, account_entry) VALUES (1000, NEW.id);
RETURN NEW; RETURN NEW;
END; END;

View File

@ -20,9 +20,9 @@
<mat-label>Betrag (€)</mat-label> <mat-label>Betrag (€)</mat-label>
<input matInput type="number" name="amount" ngModel/> <input matInput type="number" name="amount" ngModel/>
</mat-form-field> </mat-form-field>
<mat-form-field appearance="outline" *ngIf="!shallBeRentPayment"> <mat-form-field appearance="outline">
<mat-label>Beschreibung</mat-label> <mat-label>Beschreibung</mat-label>
<input matInput name="description" [disabled]="shallBeRentPayment" ngModel/> <input matInput name="description" ngModel/>
</mat-form-field> </mat-form-field>
<button #addAccountEntryButton type="submit" mat-raised-button color="primary">Buchung speichern</button> <button #addAccountEntryButton type="submit" mat-raised-button color="primary">Buchung speichern</button>
</form> </form>

View File

@ -1,5 +1,5 @@
export const serviceBaseUrl = "https://api.hv.nober.de"; // export const serviceBaseUrl = "https://api.hv.nober.de";
// export const serviceBaseUrl = "http://172.16.10.38:5000"; export const serviceBaseUrl = "http://172.16.3.96:8080";
// export const serviceBaseUrl = "http://localhost:8080" // export const serviceBaseUrl = "http://localhost:8080"
export const authserviceBaseUrl = "https://authservice.hottis.de" export const authserviceBaseUrl = "https://authservice.hottis.de"
export const applicationId = "hv2" export const applicationId = "hv2"

View File

@ -5,30 +5,6 @@
</mat-card-title> </mat-card-title>
</mat-card-header> </mat-card-header>
<mat-card-content> <mat-card-content>
<mat-accordion> <app-account #fallbackAccountComponent [selectedAccountId]="fallbackAccountId" [shallBeRentPayment]="false"></app-account>
<mat-expansion-panel (opened)="collapseExpenseDetails = true"
(closed)="collapseExpenseDetails = false">
<mat-expansion-panel-header>
<mat-panel-title>
Ausgaben
</mat-panel-title>
<mat-panel-description>
<div>Betriebskosten-relevante Ausgaben nicht hier sondern im Betriebskostenkonto unter "Meine Häuser" erfassen.</div>
</mat-panel-description>
</mat-expansion-panel-header>
<app-account #expenseAccountComponent [selectedAccountId]="expenseAccountId" [shallBeRentPayment]="false"></app-account>
</mat-expansion-panel>
<mat-expansion-panel (opened)="collapseIncomeDetails = true"
(closed)="collapseIncomeDetails = false">
<mat-expansion-panel-header>
<mat-panel-title>
Einnahmen
</mat-panel-title>
<mat-panel-description>
</mat-panel-description>
</mat-expansion-panel-header>
<app-account #incomeAccountComponent [selectedAccountId]="incomeAccountId" [shallBeRentPayment]="false"></app-account>
</mat-expansion-panel>
</mat-accordion>
</mat-card-content> </mat-card-content>
</mat-card> </mat-card>

View File

@ -11,16 +11,11 @@ import { MessageService } from '../message.service';
}) })
export class LedgerComponent implements OnInit { export class LedgerComponent implements OnInit {
incomeAccount: Account fallbackAccount: Account
incomeAccountId: number fallbackAccountId: number
expenseAccount: Account
expenseAccountId: number
collapseIncomeDetails: boolean = false
collapseExpenseDetails: boolean = false
@ViewChild('incomeAccountComponent') incomeAccountComponent: AccountComponent @ViewChild('fallbackAccountComponent') fallbackAccountComponent: AccountComponent
@ViewChild('expenseAccountComponent') expenseAccountComponent: AccountComponent
constructor( constructor(
@ -30,9 +25,8 @@ export class LedgerComponent implements OnInit {
async getAccount(): Promise<void> { async getAccount(): Promise<void> {
try { try {
this.messageService.add("Trying to load ledger account") this.messageService.add("Trying to load fallback account")
this.incomeAccount = await this.extApiService.getAccountByDescription('LedgerIncome') this.fallbackAccount = await this.extApiService.getAccountByDescription('fallback_account')
this.expenseAccount = await this.extApiService.getAccountByDescription('LedgerExpense')
this.messageService.add("Account loaded") this.messageService.add("Account loaded")
} catch (err) { } catch (err) {
this.messageService.add(JSON.stringify(err, undefined, 4)) this.messageService.add(JSON.stringify(err, undefined, 4))
@ -41,8 +35,7 @@ export class LedgerComponent implements OnInit {
async ngOnInit(): Promise<void> { async ngOnInit(): Promise<void> {
await this.getAccount() await this.getAccount()
this.incomeAccountId = this.incomeAccount.id this.fallbackAccountId = this.fallbackAccount.id
this.expenseAccountId = this.expenseAccount.id
} }
} }