monatl. forderung

This commit is contained in:
Wolfgang Hottgenroth 2021-01-20 16:14:07 +01:00
parent 727513ba65
commit e162424c81
Signed by: wn
GPG Key ID: E49AF3B9EF6DD469

View File

@ -0,0 +1,26 @@
create or replace view monatl_forderung_heute as
select
m.id as mieter,
w.id as wohnung,
o.id as objekt,
w.flaeche as flaeche,
b.betrag as bkv_qm,
(b.betrag * w.flaeche) as bkv,
mz.betrag as miete_qm,
(mz.betrag * w.flaeche) as miete
from
mieter m,
objekt o,
wohnung w,
betriebskosten_vorauszahlung b,
miete mz
where
o.id = w.objekt and
w.id = m.wohnung and
o.id = b.objekt and
w.id = mz.wohnung and
b.gueltig_ab <= now() and
(b.gueltig_bis is null or b.gueltig_bis >= now()) and
mz.gueltig_ab <= now() and
(mz.gueltig_bis is null or mz.gueltig_bis >= now());