feat: add account hierarchy, budget types (GWG/Anlagen/Instandhaltung), and Buchhaltung UI overhaul with collapsible tree, pending badge, and konto detail page

This commit is contained in:
Matthias Hochmeister
2026-03-30 09:49:28 +02:00
parent bc39963746
commit 0c5432b50e
9 changed files with 673 additions and 116 deletions

View File

@@ -0,0 +1,25 @@
-- 1. Add parent_id for account hierarchy
ALTER TABLE buchhaltung_konten ADD COLUMN parent_id INT REFERENCES buchhaltung_konten(id) ON DELETE SET NULL;
CREATE INDEX idx_buch_konten_parent ON buchhaltung_konten(parent_id);
-- 2. Replace budget_betrag with three type-specific budget columns
ALTER TABLE buchhaltung_konten ADD COLUMN budget_gwg NUMERIC(12,2) NOT NULL DEFAULT 0;
ALTER TABLE buchhaltung_konten ADD COLUMN budget_anlagen NUMERIC(12,2) NOT NULL DEFAULT 0;
ALTER TABLE buchhaltung_konten ADD COLUMN budget_instandhaltung NUMERIC(12,2) NOT NULL DEFAULT 0;
-- Migrate existing budget to GWG as default
UPDATE buchhaltung_konten SET budget_gwg = COALESCE(budget_betrag, 0);
ALTER TABLE buchhaltung_konten DROP COLUMN budget_betrag;
-- 3. Add ausgaben_typ to transactions (nullable: einnahmen have no type)
ALTER TABLE buchhaltung_transaktionen ADD COLUMN ausgaben_typ TEXT CHECK (ausgaben_typ IN ('gwg', 'anlagen', 'instandhaltung'));
-- 4. Add wiederkehrend_id to track auto-generated transactions
ALTER TABLE buchhaltung_transaktionen ADD COLUMN wiederkehrend_id INT REFERENCES buchhaltung_wiederkehrend(id) ON DELETE SET NULL;
CREATE INDEX idx_buch_trans_wiederkehrend ON buchhaltung_transaktionen(wiederkehrend_id);
-- 5. Update planpositionen to have type-specific budgets
ALTER TABLE buchhaltung_planpositionen ADD COLUMN budget_gwg NUMERIC(12,2) NOT NULL DEFAULT 0;
ALTER TABLE buchhaltung_planpositionen ADD COLUMN budget_anlagen NUMERIC(12,2) NOT NULL DEFAULT 0;
ALTER TABLE buchhaltung_planpositionen ADD COLUMN budget_instandhaltung NUMERIC(12,2) NOT NULL DEFAULT 0;
UPDATE buchhaltung_planpositionen SET budget_gwg = COALESCE(plan_betrag, 0);
ALTER TABLE buchhaltung_planpositionen DROP COLUMN plan_betrag;