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 a374866
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"ASPNETCORE_ENVIRONMENT": "Development",
"DATABASE_HOST": "walter_dev_db",
"DATABASE_PORT": "5432",
"DATABASE_NAME": "saverdb",
"DATABASE_NAME": "walter_dev_generic_db",
"DATABASE_USER": "postgres",
"DATABASE_PASS": "postgres",
"WALTER_PASSWORD": "postgres",
Expand Down
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 @@ -41,7 +41,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
let visible: boolean = false;
let oldHKVO: Partial<WalterHKVOEntry> = {};
let selectableUmlagen: Promise<WalterSelectionEntry[]>;
let selectableUmlagen: Promise<WalterSelectionEntry[]> = new Promise(
() => []
);
onMount(() => {
visible = !!entry.hKVO;
Expand Down Expand Up @@ -120,6 +122,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 +135,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
3 changes: 2 additions & 1 deletion Deeplex.Saverwalter.WebAPI/svelte/src/lib/WalterUmlage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ export class WalterUmlageEntry extends WalterApiHandler {
const selectedZaehler = json.selectedZaehler?.map(
WalterSelectionEntry.fromJson
);
// TODO: Check naming?
const hkvo =
json.hKVO && WalterHKVOEntry.fromJson(json.hKVO as WalterHKVOEntry);
json.hkvo && WalterHKVOEntry.fromJson(json.hkvo as WalterHKVOEntry);
const zaehler = json.zaehler?.map(WalterZaehlerEntry.fromJson);
const permissions =
json.permissions && WalterPermissions.fromJson(json.permissions);
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 a374866

Please sign in to comment.