Skip to content

Commit

Permalink
wip: Try to fix Heizkostenabrechnung
Browse files Browse the repository at this point in the history
  • Loading branch information
klawr committed May 30, 2024
1 parent 9e96b46 commit 7224b7e
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,9 @@ private double GetVerbrauchAnteil(Betriebskostenrechnung rechnung, List<Note> no

var verbrauchAnteil = verbrauchAnteile.First();


if (verbrauchAnteil.Anteil.Count > 1)
{
notes.Add($"Verbrauch von Rechnung {rechnung.Umlage.Typ} enthält mehr als einen Zählertypen",
notes.Add($"Verbrauch von Rechnung {rechnung.Umlage.Typ.Bezeichnung} enthält mehr als einen Zählertypen",
Severity.Error);

return 0;
Expand Down
4 changes: 4 additions & 0 deletions Deeplex.Saverwalter.BetriebskostenabrechnungService/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ public static double GetKaltMiete(Vertrag vertrag, Zeitraum zeitraum)
{
return 0;
}
else if (version.Beginn > zeitraum.Abrechnungsende)
{
return 0;
}
else
{
var last = Min(versionEnde ?? zeitraum.Abrechnungsende, zeitraum.Abrechnungsende).Month;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public VerbrauchAnteil(Umlage umlage, Wohnung wohnung, Zeitraum zeitraum, List<N
continue;
}
// Done because the first entry should not be in the last month.
if (zaehler.Ende < zeitraum.Abrechnungsbeginn)
{
continue;
}
var daysToFirstZaehler = zaehler.Staende
.OrderBy(stand => stand.Stand)
.FirstOrDefault()?
Expand All @@ -60,7 +64,11 @@ public VerbrauchAnteil(Umlage umlage, Wohnung wohnung, Zeitraum zeitraum, List<N
{
continue;
}
var verbrauch = new Verbrauch(zaehler, zeitraum.Abrechnungsbeginn, zeitraum.Abrechnungsende, notes);
var verbrauch = new Verbrauch(
zaehler,
zeitraum.Abrechnungsbeginn,
zeitraum.Abrechnungsende,
notes);
AlleZaehler[unit].Add(verbrauch);
AlleVerbrauch[unit] += verbrauch.Delta;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,11 @@ private void SetOptionalValues(Umlage entity, UmlageEntry entry)
{
if (hkvo.Id == 0)
{
var newHKVO = new HKVO(hkvo.HKVO_P7 / 100, hkvo.HKVO_P8 / 100, (HKVO_P9A2)hkvo.HKVO_P9.Id, hkvo.Strompauschale / 100)
var newHKVO = new HKVO(
((double)hkvo.HKVO_P7) / 100,
((double)hkvo.HKVO_P8) / 100,
(HKVO_P9A2)hkvo.HKVO_P9.Id,
((double)hkvo.Strompauschale) / 100)
{
Betriebsstrom = Ctx.Umlagen.Single(e => e.UmlageId == hkvo.Stromrechnung.Id)
};
Expand All @@ -190,10 +194,10 @@ private void SetOptionalValues(Umlage entity, UmlageEntry entry)
else
{
var oldHKVO = Ctx.HKVO.Single(e => e.HKVOId == hkvo.Id);
oldHKVO.HKVO_P7 = (double)hkvo.HKVO_P7 / 100;
oldHKVO.HKVO_P8 = (double)hkvo.HKVO_P8 / 100;
oldHKVO.HKVO_P7 = ((double)hkvo.HKVO_P7) / 100;
oldHKVO.HKVO_P8 = ((double)hkvo.HKVO_P8) / 100;
oldHKVO.HKVO_P9 = (HKVO_P9A2)hkvo.HKVO_P9.Id;
oldHKVO.Strompauschale = (double)hkvo.Strompauschale / 100;
oldHKVO.Strompauschale = ((double)hkvo.Strompauschale) / 100;
oldHKVO.Betriebsstrom = Ctx.Umlagen.Single(e => e.UmlageId == hkvo.Stromrechnung.Id);
Ctx.HKVO.Update(oldHKVO);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
function change(e: Event, p9a2: WalterSelectionEntry[]) {
if ((e.target as HTMLInputElement).checked) {
entry.hKVO = {
id: oldHKVO.id || 0,
hkvO_P7: oldHKVO.hkvO_P7 || 50,
hkvO_P8: oldHKVO.hkvO_P8 || 50,
hkvO_P9: oldHKVO.hkvO_P9 || p9a2[1],
Expand All @@ -132,13 +133,13 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
}
</script>

{#if entry.schluessel?.id === '3'}
{#if `${entry.schluessel?.id}` === '3'}
<Tile>
<Row>
{#await hkvo_p9a2 then p9a2}
<div>
<Checkbox
checked={visible}
bind:checked={visible}
on:change={(e) => change(e, p9a2)}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
WalterUmlage,
WalterZaehlerList,
WalterLinks,
WalterLinkTile
WalterLinkTile,
WalterZaehler
} from '$walter/components';
import { convertDateCanadian } from '$walter/services/utils';
import {
Expand Down Expand Up @@ -94,7 +95,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
rows={data.entry.betriebskostenrechnungen}
/>
<!-- Only show if Schlüssel is "nach Verbrauch" -->
{#if data.entry?.schluessel?.id === '3'}
{#if `${data.entry?.schluessel?.id}` === "3"}
<WalterZaehlerList
fetchImpl={data.fetchImpl}
title="Zähler"
Expand Down

0 comments on commit 7224b7e

Please sign in to comment.