diff --git a/schema/changes02.sql b/schema/changes02.sql index 64647ff..37601f0 100644 --- a/schema/changes02.sql +++ b/schema/changes02.sql @@ -93,7 +93,21 @@ CREATE OR REPLACE FUNCTION maintain_ledger() RETURNS TRIGGER LANGUAGE plpgsql AS $$ +DECLARE + tenant RECORD; + adjusted_description text; 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); RETURN NEW; END; diff --git a/ui/hv2-ui/src/app/account/account.component.html b/ui/hv2-ui/src/app/account/account.component.html index 233e1a6..23eeaea 100644 --- a/ui/hv2-ui/src/app/account/account.component.html +++ b/ui/hv2-ui/src/app/account/account.component.html @@ -20,9 +20,9 @@ Betrag (€) - + Beschreibung - + Buchung speichern diff --git a/ui/hv2-ui/src/app/config.ts b/ui/hv2-ui/src/app/config.ts index 7cdcad6..0d40f2a 100644 --- a/ui/hv2-ui/src/app/config.ts +++ b/ui/hv2-ui/src/app/config.ts @@ -1,5 +1,5 @@ -export const serviceBaseUrl = "https://api.hv.nober.de"; -// export const serviceBaseUrl = "http://172.16.10.38:5000"; +// export const serviceBaseUrl = "https://api.hv.nober.de"; +export const serviceBaseUrl = "http://172.16.3.96:8080"; // export const serviceBaseUrl = "http://localhost:8080" export const authserviceBaseUrl = "https://authservice.hottis.de" export const applicationId = "hv2" diff --git a/ui/hv2-ui/src/app/ledger/ledger.component.html b/ui/hv2-ui/src/app/ledger/ledger.component.html index 6e9ed38..0698b09 100644 --- a/ui/hv2-ui/src/app/ledger/ledger.component.html +++ b/ui/hv2-ui/src/app/ledger/ledger.component.html @@ -5,30 +5,6 @@ - - - - - Ausgaben - - - Betriebskosten-relevante Ausgaben nicht hier sondern im Betriebskostenkonto unter "Meine Häuser" erfassen. - - - - - - - - Einnahmen - - - - - - - + \ No newline at end of file diff --git a/ui/hv2-ui/src/app/ledger/ledger.component.ts b/ui/hv2-ui/src/app/ledger/ledger.component.ts index 04ea2d9..711f5d1 100644 --- a/ui/hv2-ui/src/app/ledger/ledger.component.ts +++ b/ui/hv2-ui/src/app/ledger/ledger.component.ts @@ -11,16 +11,11 @@ import { MessageService } from '../message.service'; }) export class LedgerComponent implements OnInit { - incomeAccount: Account - incomeAccountId: number - expenseAccount: Account - expenseAccountId: number + fallbackAccount: Account + fallbackAccountId: number - collapseIncomeDetails: boolean = false - collapseExpenseDetails: boolean = false - @ViewChild('incomeAccountComponent') incomeAccountComponent: AccountComponent - @ViewChild('expenseAccountComponent') expenseAccountComponent: AccountComponent + @ViewChild('fallbackAccountComponent') fallbackAccountComponent: AccountComponent constructor( @@ -30,9 +25,8 @@ export class LedgerComponent implements OnInit { async getAccount(): Promise { try { - this.messageService.add("Trying to load ledger account") - this.incomeAccount = await this.extApiService.getAccountByDescription('LedgerIncome') - this.expenseAccount = await this.extApiService.getAccountByDescription('LedgerExpense') + this.messageService.add("Trying to load fallback account") + this.fallbackAccount = await this.extApiService.getAccountByDescription('fallback_account') this.messageService.add("Account loaded") } catch (err) { this.messageService.add(JSON.stringify(err, undefined, 4)) @@ -41,8 +35,7 @@ export class LedgerComponent implements OnInit { async ngOnInit(): Promise { await this.getAccount() - this.incomeAccountId = this.incomeAccount.id - this.expenseAccountId = this.expenseAccount.id + this.fallbackAccountId = this.fallbackAccount.id } }