diff --git a/query-jahresabrechnung.sql b/query-jahresabrechnung.sql index e61484b..00f4fea 100644 --- a/query-jahresabrechnung.sql +++ b/query-jahresabrechnung.sql @@ -91,4 +91,38 @@ end; delimiter ; +alter table objekt modify column flaeche decimal(20, 2) not null; +alter table wohnung modify column flaeche decimal(20, 2) not null; +alter table betriebskosten_abrechnung modify column betrag decimal(20, 2) not null; + +create or replace view jahresabrechnung_flat_v as + select o.shortname as objekt, + o.flaeche as gesamt_flaeche, + w.shortname as wohnung, + w.flaeche as flaeche, + m.anrede as anrede, + m.vorname as vorname, + m.nachname as nachname, + m.strasse as strasse, + m.plz as plz, + m.ort as ort, + j.nutzungszeit as nutzungszeit, + j.anteil_pro_flaeche as anteil_pro_flaeche, + j.anteil_pro_flaeche_nutzungszeit as anteil_pro_flaeche_nutzungszeit, + j.summe_zahlungen as summe_zahlungen, + j.summe_zahlungen_anteil_miete as summe_zahlungen_anteil_miete, + j.vorauszahlung as vorauszahlung, + j.nachzahlung as nachzahlung, + b.jahr as jahr, + b.betrag as gesamt_betriebskosten + from objekt o, + wohnung w, + mieter m, + jahresabrechnung_summary j, + betriebskosten_abrechnung b + where j.abrechnung = b.id and + j.mieter = m.id and + m.wohnung = w.id and + w.objekt = o.id; +