Add "Wasser & Heizung" page for the NeoVac water and heating bills #19

Merged
clayschaad merged 5 commits from water-bill-guide into main 2026-11-01 18:41:15 +00:00
8 changed files with 405 additions and 34 deletions
Showing only changes of commit a58f08e82a - Show all commits

View file

@ -67,7 +67,7 @@ When a new year is opened, the previous year's data is copied as the starting po
- **AnalyticsService** — loads all years of the current mandator (via `MultiYearRepository`) into an `AccountingAnalysis` (expenses, income, net, assets) for the Analyse page; queries run in memory
- **Strom** page (`Electricity`, `/electricity`, under "Charts" in the menu) — grid and dialog (FluentDataGrid/`ElectricityBillDialog`) over `IElectricityBillRepository`'s `ElectricityBill` records (one yearly NeoVac bill each: kWh/CHF for grid and PV, side costs; `TotalKwh`, `PvShare`, `TotalChf`, `ChfPerKwh` are computed); three Chart.js charts via `ChartJsChart` (stacked kWh, CHF/kWh lines, total CHF), filtered by the shared `BillChartToolbar` (`BillChartFilter`): grouped per bill, calendar year (default) or half-year (`BillPeriod<T>.FromBills` over `IPeriodBill<T>`; a bill reaching over several periods is spread evenly over its months and the page shows a note) and limited to a from/to year range (periods overlapping it are kept whole)
- **Wasser** page (`Water`, `/water`, under "Charts" in the menu) — same layout as Strom over `IWaterBillRepository`'s `WaterBill` records (warm/cold water m³ and CHF, base costs; `TotalM3`, `WarmWaterShare`, `TotalChf` are computed); two charts (stacked m³, total CHF) with the same `BillChartToolbar`
- **Wasser & Heizung** page (`WaterHeating`, `/water-heating`, under "Charts" in the menu) — same layout for NeoVac bills where only per-mille shares are known, over `IWaterHeatingBillRepository`'s `WaterHeatingBill` records: consumption (warm/cold m³, heat MWh) and ‰ shares from NeoVac, own water/heating costs in CHF from the property manager's statement; `WaterHeatingBillDialog` calls `CalculateCosts`, which stores the CHF parts (water split into base/consumption by ‰, consumption split by m³, warm water part of the heating), so `AddShare` can sum them per period; `RoomHeatingChf` is the rest of the heating. Three charts (stacked m³, MWh, stacked CHF) and a guide image (`water-heating-bill-guide.svg`)
- **Wasser & Heizung** page (`WaterHeating`, `/water-heating`, under "Charts" in the menu) — same layout for NeoVac bills where only per-mille shares are known, over `IWaterHeatingBillRepository`'s `WaterHeatingBill` records: consumption (warm/cold m³, heat MWh) and ‰ shares from NeoVac, own water/heating costs in CHF from the property manager's statement; `WaterHeatingBillDialog` calls `CalculateCosts`, which stores the CHF parts (water split into base/consumption by ‰, consumption split by m³, warm water part of the heating), so `AddShare` can sum them per period; `RoomHeatingChf` is the rest of the heating. The dialog shows plausibility checks from `WaterHeatingBillChecks` (NeoVac ‰ vs. the optional ‰ of the property manager, optional meter readings continuing from the previous bill, implied property totals, prices per unit vs. the previous bill, flagged above ±25 %). Three charts (stacked m³, MWh, stacked CHF) and a guide image (`water-heating-bill-guide.svg`)
### UI structure

View file

@ -35,6 +35,18 @@ namespace Schaad.Accounting.Models
[Display(Name = "Wärme")]
public decimal HeatingMwh { get; set; }
// Optional meter readings ("Stand neu"), only for the checks (see WaterHeatingBillChecks):
// the previous bill's reading plus this consumption must give this reading.
[Display(Name = "Zählerstand Warmwasser")]
public decimal? WarmWaterMeter { get; set; }
[Display(Name = "Zählerstand Kaltwasser")]
public decimal? ColdWaterMeter { get; set; }
[Display(Name = "Zählerstand Wärme")]
public decimal? HeatingMeter { get; set; }
// NeoVac per-mille shares of the property, column "Anteil (‰)".
[Display(Name = "Wasser Grundkosten-Anteil")]
@ -59,6 +71,15 @@ namespace Schaad.Accounting.Models
[Display(Name = "Heizkosten")]
public decimal HeatingCostsChf { get; set; }
// Optional per-mille shares as listed by the property manager, only for the checks: they
// must match the NeoVac ones.
[Display(Name = "Wasser-Anteil Verwaltung")]
public decimal? ManagerWaterPermille { get; set; }
[Display(Name = "Heizungs-Anteil Verwaltung")]
public decimal? ManagerHeatingPermille { get; set; }
// Calculated by CalculateCosts.
[Display(Name = "Grundkosten Wasser")]
@ -111,7 +132,10 @@ namespace Schaad.Accounting.Models
private static decimal Round(decimal value) => Math.Round(value, 2, MidpointRounding.AwayFromZero);
/// <summary>Adds up consumption and CHF values; the per-mille shares don't add up and are left out.</summary>
/// <summary>
/// Adds up consumption and CHF values; the per-mille shares and meter readings don't add up
/// and are left out.
/// </summary>
public void AddShare(WaterHeatingBill other, decimal share)
{
WarmWaterM3 += other.WarmWaterM3 * share;

View file

@ -0,0 +1,141 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
namespace Schaad.Accounting.Models
{
public enum BillCheckResult
{
/// <summary>A value to compare by hand with the statements.</summary>
Info,
Ok,
Warning
}
public record BillCheck(BillCheckResult Result, string Text);
/// <summary>
/// Plausibility checks for a <see cref="WaterHeatingBill"/>, shown in its dialog: the NeoVac and
/// property manager's per-mille shares must match, the meter readings must continue from the
/// previous bill, and the prices per unit shouldn't jump. Checks whose optional inputs are
/// missing are left out.
/// </summary>
public static class WaterHeatingBillChecks
{
/// <summary>Price changes against the previous bill above this share are flagged.</summary>
public const decimal MaxPriceChange = 0.25m;
private const decimal PermilleTolerance = 0.005m;
private const decimal MeterTolerance = 0.0005m;
private static readonly CultureInfo SwissNumbers = CreateSwissNumbers();
/// <summary>The bill that ended last before <paramref name="bill"/> started, if any.</summary>
public static WaterHeatingBill PreviousOf(IEnumerable<WaterHeatingBill> bills, WaterHeatingBill bill)
=> bills.Where(b => b.Id != bill.Id && b.PeriodTo < bill.PeriodFrom).MaxBy(b => b.PeriodTo);
public static IReadOnlyList<BillCheck> Check(WaterHeatingBill bill, WaterHeatingBill previous)
{
var checks = new List<BillCheck>();
var waterPermille = bill.WaterBasePermille + bill.WaterConsumptionPermille;
if (bill.ManagerWaterPermille is decimal managerWater)
{
checks.Add(new BillCheck(
Result(Math.Abs(waterPermille - managerWater) < PermilleTolerance),
$"Wasser: NeoVac {N(bill.WaterBasePermille)} + {N(bill.WaterConsumptionPermille)} = {N(waterPermille)} ‰, Verwaltung {N(managerWater)} ‰"));
}
if (bill.ManagerHeatingPermille is decimal managerHeating)
{
checks.Add(new BillCheck(
Result(Math.Abs(bill.HeatingPermille - managerHeating) < PermilleTolerance),
$"Heizung: NeoVac {N(bill.HeatingPermille)} ‰, Verwaltung {N(managerHeating)} ‰"));
}
if (bill.WarmWaterHeatingPermille > bill.HeatingPermille)
{
checks.Add(new BillCheck(BillCheckResult.Warning,
$"Heizung WW {N(bill.WarmWaterHeatingPermille)} ‰ ist grösser als Heizung total {N(bill.HeatingPermille)} ‰"));
}
AddMeterCheck(checks, "Warmwasser", bill.WarmWaterMeter, bill.WarmWaterM3, previous?.WarmWaterMeter);
AddMeterCheck(checks, "Kaltwasser", bill.ColdWaterMeter, bill.ColdWaterM3, previous?.ColdWaterMeter);
AddMeterCheck(checks, "Wärme", bill.HeatingMeter, bill.HeatingMwh, previous?.HeatingMeter);
// The own share divided by the per-mille share gives the costs of the whole property,
// which are on the property manager's statement.
if (waterPermille != 0 && bill.HeatingPermille != 0)
{
checks.Add(new BillCheck(BillCheckResult.Info,
$"Liegenschaft: Wasserkosten {N(bill.WaterCostsChf * 1000 / waterPermille)} CHF, Heizkosten {N(bill.HeatingCostsChf * 1000 / bill.HeatingPermille)} CHF"));
}
AddPriceCheck(checks, "Wasser", "CHF/m³", WaterPrice(bill), previous is null ? null : WaterPrice(previous));
AddPriceCheck(checks, "Heizung Warmwasser", "CHF/m³", WarmWaterHeatingPrice(bill), previous is null ? null : WarmWaterHeatingPrice(previous));
AddPriceCheck(checks, "Heizung Räume", "CHF/MWh", RoomHeatingPrice(bill), previous is null ? null : RoomHeatingPrice(previous));
return checks;
}
private static void AddMeterCheck(List<BillCheck> checks, string name, decimal? reading, decimal consumption, decimal? previousReading)
{
if (reading is not decimal now)
{
return;
}
if (previousReading is decimal before)
{
var expected = before + consumption;
var ok = Math.Abs(expected - now) < MeterTolerance;
checks.Add(new BillCheck(Result(ok),
$"Zähler {name}: {M(before)} (Vorperiode) + {M(consumption)} = {M(expected)}" + (ok ? "" : $", Stand neu ist {M(now)}")));
}
else
{
checks.Add(new BillCheck(BillCheckResult.Info,
$"Zähler {name}: Stand alt = {M(now)} − {M(consumption)} = {M(now - consumption)}"));
}
}
private static void AddPriceCheck(List<BillCheck> checks, string name, string unit, decimal? price, decimal? previousPrice)
{
if (price is not decimal now)
{
return;
}
if (previousPrice is decimal before && before != 0)
{
var change = now / before - 1;
checks.Add(new BillCheck(Result(Math.Abs(change) <= MaxPriceChange),
$"{name}: {N(now)} {unit} (Vorperiode {N(before)}, {change.ToString("+0%;−0%;0%", SwissNumbers)})"));
}
else
{
checks.Add(new BillCheck(BillCheckResult.Info, $"{name}: {N(now)} {unit}"));
}
}
/// <summary>Water consumption costs (without base costs) per m³.</summary>
private static decimal? WaterPrice(WaterHeatingBill bill)
=> bill.TotalM3 == 0 ? null : (bill.WarmWaterChf + bill.ColdWaterChf) / bill.TotalM3;
private static decimal? WarmWaterHeatingPrice(WaterHeatingBill bill)
=> bill.WarmWaterM3 == 0 ? null : bill.WarmWaterHeatingChf / bill.WarmWaterM3;
private static decimal? RoomHeatingPrice(WaterHeatingBill bill)
=> bill.HeatingMwh == 0 ? null : bill.RoomHeatingChf / bill.HeatingMwh;
private static BillCheckResult Result(bool ok) => ok ? BillCheckResult.Ok : BillCheckResult.Warning;
private static string N(decimal value) => value.ToString("#,0.00", SwissNumbers);
private static string M(decimal value) => value.ToString("#,0.000", SwissNumbers);
private static CultureInfo CreateSwissNumbers()
{
var culture = new CultureInfo("de-CH");
culture.NumberFormat.NumberGroupSeparator = "'";
return culture;
}
}
}

View file

@ -0,0 +1,151 @@
using Schaad.Accounting.Models;
using Shouldly;
namespace Schaad.Accounting.Tests;
public class WaterHeatingBillChecksTestShould
{
// Values of the 2024/25 bill: NeoVac per-mille shares and the own share from the property manager.
private static WaterHeatingBill Bill()
{
var bill = new WaterHeatingBill
{
Id = "b2025",
PeriodFrom = new DateOnly(2024, 7, 1),
PeriodTo = new DateOnly(2025, 6, 30),
WarmWaterM3 = 16.399m,
ColdWaterM3 = 51.464m,
HeatingMwh = 2.458m,
WaterBasePermille = 19.52m,
WaterConsumptionPermille = 68.50m,
HeatingPermille = 62.82m,
WarmWaterHeatingPermille = 12.66m,
WaterCostsChf = 304.30m,
HeatingCostsChf = 451.65m
};
bill.CalculateCosts();
return bill;
}
[Fact]
public void PassWhenNeoVacPermilleMatchesPropertyManager()
{
var bill = Bill();
bill.ManagerWaterPermille = 88.02m;
bill.ManagerHeatingPermille = 62.82m;
var checks = WaterHeatingBillChecks.Check(bill, null);
checks.ShouldContain(c => c.Result == BillCheckResult.Ok && c.Text.StartsWith("Wasser: NeoVac 19.52 + 68.50 = 88.02 ‰"));
checks.ShouldContain(c => c.Result == BillCheckResult.Ok && c.Text.StartsWith("Heizung: NeoVac 62.82 ‰"));
}
[Fact]
public void WarnWhenNeoVacPermilleDiffersFromPropertyManager()
{
var bill = Bill();
bill.ManagerWaterPermille = 88.20m;
var checks = WaterHeatingBillChecks.Check(bill, null);
checks.ShouldContain(c => c.Result == BillCheckResult.Warning && c.Text.StartsWith("Wasser: NeoVac"));
}
[Fact]
public void LeaveOutPermilleChecksWhenPropertyManagerValuesAreMissing()
{
var checks = WaterHeatingBillChecks.Check(Bill(), null);
checks.ShouldNotContain(c => c.Text.StartsWith("Wasser: NeoVac") || c.Text.StartsWith("Heizung: NeoVac"));
}
[Fact]
public void WarnWhenWarmWaterHeatingPermilleIsAboveHeatingPermille()
{
var bill = Bill();
bill.WarmWaterHeatingPermille = 70m;
var checks = WaterHeatingBillChecks.Check(bill, null);
checks.ShouldContain(c => c.Result == BillCheckResult.Warning && c.Text.StartsWith("Heizung WW 70.00 ‰"));
}
[Fact]
public void PassWhenMeterContinuesFromPreviousBill()
{
var previous = Bill();
previous.WarmWaterMeter = 134.151m;
var bill = Bill();
bill.WarmWaterMeter = 150.550m;
var checks = WaterHeatingBillChecks.Check(bill, previous);
checks.ShouldContain(new BillCheck(BillCheckResult.Ok, "Zähler Warmwasser: 134.151 (Vorperiode) + 16.399 = 150.550"));
}
[Fact]
public void WarnWhenMeterDoesNotContinueFromPreviousBill()
{
var previous = Bill();
previous.ColdWaterMeter = 333.273m;
var bill = Bill();
bill.ColdWaterMeter = 384.740m;
var checks = WaterHeatingBillChecks.Check(bill, previous);
checks.ShouldContain(new BillCheck(BillCheckResult.Warning, "Zähler Kaltwasser: 333.273 (Vorperiode) + 51.464 = 384.737, Stand neu ist 384.740"));
}
[Fact]
public void ShowOldMeterReadingWhenThereIsNoPreviousReading()
{
var bill = Bill();
bill.HeatingMeter = 21.575m;
var checks = WaterHeatingBillChecks.Check(bill, null);
checks.ShouldContain(new BillCheck(BillCheckResult.Info, "Zähler Wärme: Stand alt = 21.575 − 2.458 = 19.117"));
}
[Fact]
public void ShowPropertyCostsDerivedFromOwnShare()
{
var checks = WaterHeatingBillChecks.Check(Bill(), null);
checks.ShouldContain(new BillCheck(BillCheckResult.Info, "Liegenschaft: Wasserkosten 3'457.17 CHF, Heizkosten 7'189.59 CHF"));
}
[Fact]
public void ShowPricesPerUnitWhenThereIsNoPreviousBill()
{
var checks = WaterHeatingBillChecks.Check(Bill(), null);
checks.ShouldContain(new BillCheck(BillCheckResult.Info, "Wasser: 3.49 CHF/m³"));
checks.ShouldContain(new BillCheck(BillCheckResult.Info, "Heizung Warmwasser: 5.55 CHF/m³"));
checks.ShouldContain(new BillCheck(BillCheckResult.Info, "Heizung Räume: 146.72 CHF/MWh"));
}
[Fact]
public void WarnWhenPriceChangesMoreThanAllowedAgainstPreviousBill()
{
var previous = Bill();
previous.HeatingCostsChf = 300m;
previous.CalculateCosts();
var checks = WaterHeatingBillChecks.Check(Bill(), previous);
checks.ShouldContain(c => c.Result == BillCheckResult.Warning && c.Text.StartsWith("Heizung Räume: 146.72 CHF/MWh (Vorperiode"));
checks.ShouldContain(c => c.Result == BillCheckResult.Ok && c.Text == "Wasser: 3.49 CHF/m³ (Vorperiode 3.49, 0%)");
}
[Fact]
public void PickBillThatEndedLastBeforeThisOneAsPrevious()
{
var bill = Bill();
var older = new WaterHeatingBill { Id = "a", PeriodFrom = new DateOnly(2022, 7, 1), PeriodTo = new DateOnly(2023, 6, 30) };
var last = new WaterHeatingBill { Id = "b", PeriodFrom = new DateOnly(2023, 7, 1), PeriodTo = new DateOnly(2024, 6, 30) };
var later = new WaterHeatingBill { Id = "c", PeriodFrom = new DateOnly(2025, 7, 1), PeriodTo = new DateOnly(2026, 6, 30) };
WaterHeatingBillChecks.PreviousOf([later, older, bill, last], bill).ShouldBeSameAs(last);
}
}

View file

@ -1,5 +1,6 @@
@implements IDialogContentComponent<Schaad.Accounting.Models.WaterHeatingBill>
@rendermode InteractiveServer
@using Schaad.Accounting.Models
<FluentDialogHeader ShowDismiss="true">
<FluentStack VerticalAlignment="VerticalAlignment.Center">
@ -14,33 +15,40 @@
<EditForm EditContext="@editContext">
<DataAnnotationsValidator />
<FluentStack Orientation="Orientation.Horizontal">
<FluentDatePicker @bind-Value="@periodFrom" Label="Von" Style="width: 170px;" />
<FluentDatePicker @bind-Value="@periodTo" Label="Bis" Style="width: 170px;" />
<FluentDatePicker @bind-Value="@periodFrom" @bind-Value:after="SyncPeriod" Label="Von" Style="width: 210px;" />
<FluentDatePicker @bind-Value="@periodTo" @bind-Value:after="SyncPeriod" Label="Bis" Style="width: 210px;" />
</FluentStack>
<div style="@SectionStyle">NeoVac – Ablesequittung (Verbrauch verrechnet)</div>
<div style="@SectionStyle">NeoVac – Ablesequittung</div>
<FluentStack Orientation="Orientation.Horizontal">
<FluentNumberField @bind-Value="@Content.WarmWaterM3" @bind-Value:after="Content.CalculateCosts" Label="Warmwasser (m³)" Style="width: 170px;" />
<FluentNumberField @bind-Value="@Content.ColdWaterM3" @bind-Value:after="Content.CalculateCosts" Label="Kaltwasser (m³)" Style="width: 170px;" />
<FluentNumberField @bind-Value="@Content.WarmWaterM3" @bind-Value:after="Content.CalculateCosts" Label="Warmwasser (m³)" Style="width: 210px;" />
<FluentNumberField @bind-Value="@Content.ColdWaterM3" @bind-Value:after="Content.CalculateCosts" Label="Kaltwasser (m³)" Style="width: 210px;" />
<FluentNumberField @bind-Value="@Content.HeatingMwh" Label="Wärme (MWh)" Style="width: 210px;" />
</FluentStack>
<FluentStack Orientation="Orientation.Horizontal">
<FluentNumberField @bind-Value="@Content.HeatingMwh" Label="Wärme (MWh)" Style="width: 170px;" />
<FluentNumberField @bind-Value="@Content.WarmWaterMeter" Label="Stand neu WW (optional)" Style="width: 210px;" />
<FluentNumberField @bind-Value="@Content.ColdWaterMeter" Label="Stand neu KW (optional)" Style="width: 210px;" />
<FluentNumberField @bind-Value="@Content.HeatingMeter" Label="Stand neu Wärme (optional)" Style="width: 210px;" />
</FluentStack>
<div style="@SectionStyle">NeoVac – Anteil (‰)</div>
<FluentStack Orientation="Orientation.Horizontal">
<FluentNumberField @bind-Value="@Content.WaterBasePermille" @bind-Value:after="Content.CalculateCosts" Label="Wasser Grund (‰)" Style="width: 170px;" />
<FluentNumberField @bind-Value="@Content.WaterConsumptionPermille" @bind-Value:after="Content.CalculateCosts" Label="Wasser Verbrauch (‰)" Style="width: 170px;" />
<FluentNumberField @bind-Value="@Content.WaterBasePermille" @bind-Value:after="Content.CalculateCosts" Label="Wasser Grund (‰)" Style="width: 210px;" />
<FluentNumberField @bind-Value="@Content.WaterConsumptionPermille" @bind-Value:after="Content.CalculateCosts" Label="Wasser Verbrauch (‰)" Style="width: 210px;" />
</FluentStack>
<FluentStack Orientation="Orientation.Horizontal">
<FluentNumberField @bind-Value="@Content.HeatingPermille" @bind-Value:after="Content.CalculateCosts" Label="Heizung total (‰)" Style="width: 170px;" />
<FluentNumberField @bind-Value="@Content.WarmWaterHeatingPermille" @bind-Value:after="Content.CalculateCosts" Label="Heizung WW (‰)" Style="width: 170px;" />
<FluentNumberField @bind-Value="@Content.HeatingPermille" @bind-Value:after="Content.CalculateCosts" Label="Heizung total (‰)" Style="width: 210px;" />
<FluentNumberField @bind-Value="@Content.WarmWaterHeatingPermille" @bind-Value:after="Content.CalculateCosts" Label="Heizung WW (‰)" Style="width: 210px;" />
</FluentStack>
<div style="@SectionStyle">Verwaltung – Ihr Anteil (CHF)</div>
<div style="@SectionStyle">Verwaltung – Ihr Anteil</div>
<FluentStack Orientation="Orientation.Horizontal">
<FluentNumberField @bind-Value="@Content.WaterCostsChf" @bind-Value:after="Content.CalculateCosts" Label="Wasserkosten (CHF)" Style="width: 170px;" />
<FluentNumberField @bind-Value="@Content.HeatingCostsChf" @bind-Value:after="Content.CalculateCosts" Label="Heizkosten (CHF)" Style="width: 170px;" />
<FluentNumberField @bind-Value="@Content.WaterCostsChf" @bind-Value:after="Content.CalculateCosts" Label="Wasserkosten (CHF)" Style="width: 210px;" />
<FluentNumberField @bind-Value="@Content.HeatingCostsChf" @bind-Value:after="Content.CalculateCosts" Label="Heizkosten (CHF)" Style="width: 210px;" />
</FluentStack>
<FluentStack Orientation="Orientation.Horizontal">
<FluentNumberField @bind-Value="@Content.ManagerWaterPermille" Label="Wasser (‰, optional)" Style="width: 210px;" />
<FluentNumberField @bind-Value="@Content.ManagerHeatingPermille" Label="Heizung (‰, optional)" Style="width: 210px;" />
</FluentStack>
<div>
<FluentValidationSummary />
@ -60,6 +68,12 @@
Total <strong>@M3(Content.TotalM3)</strong> · <strong>@Mwh(Content.HeatingMwh)</strong> · <strong>@Chf(Content.TotalChf)</strong>
</div>
<div style="@SectionStyle">Kontrolle</div>
@foreach (var check in Checks)
{
<div style="font-size: 13px; color: @CheckColor(check.Result);">@CheckSymbol(check.Result) @check.Text</div>
}
<FluentButton Appearance="Appearance.Lightweight" Style="margin-top: 12px; padding: 0; font-size: 13px;" OnClick="ShowGuideAsync">
Woher kommen die Werte? (NeoVac-Abrechnung)
</FluentButton>
@ -78,7 +92,7 @@
</FluentDialogFooter>
@code {
private const string SectionStyle = "margin-top: 14px; font-size: 11px; font-weight: bold; color: #898781; text-transform: uppercase;";
private const string SectionStyle = "margin-top: 14px; margin-bottom: 4px; font-size: 11px; font-weight: bold; color: #898781; text-transform: uppercase;";
// Shown in its own dialog (see ShowGuideAsync) instead of expanding inline: this dialog has a
// fixed Height, and FluentDialogBody doesn't resize to fit growing content.
@ -86,4 +100,18 @@
@<img src="/images/water-heating-bill-guide.svg"
alt="Beispiel-Abrechnung mit Markierungen, welcher Wert in welches Feld gehört"
style="width: 100%; height: auto; display: block;" />;
private static string CheckSymbol(BillCheckResult result) => result switch
{
BillCheckResult.Ok => "✓",
BillCheckResult.Warning => "⚠",
_ => "·"
};
private static string CheckColor(BillCheckResult result) => result switch
{
BillCheckResult.Ok => "#1a7f37",
BillCheckResult.Warning => "#c4314b",
_ => "#52514e"
};
}

View file

@ -9,7 +9,8 @@ namespace Schaad.Accounting.UI.Components.Pages.Dialogs;
/// <summary>
/// NeoVac water and heating bill: consumption and per-mille shares from NeoVac, own costs from the
/// property manager's statement; the CHF parts are calculated (see <see cref="WaterHeatingBill.CalculateCosts"/>).
/// property manager's statement; the CHF parts are calculated (see <see cref="WaterHeatingBill.CalculateCosts"/>)
/// and checked (see <see cref="WaterHeatingBillChecks"/>).
/// </summary>
public partial class WaterHeatingBillDialog : ComponentBase
{
@ -21,6 +22,9 @@ public partial class WaterHeatingBillDialog : ComponentBase
private DateTime? periodFrom;
private DateTime? periodTo;
// The other bills, to find the previous one for the checks (meter readings, prices).
private List<WaterHeatingBill> bills = [];
[CascadingParameter]
public FluentDialog Dialog { get; set; } = null!;
@ -33,13 +37,31 @@ public partial class WaterHeatingBillDialog : ComponentBase
[Inject]
private IDialogService dialogService { get; set; } = null!;
protected override void OnInitialized()
protected override async Task OnInitializedAsync()
{
bills = await waterHeatingBillRepository.GetWaterHeatingBillListAsync();
periodFrom = Content.PeriodFrom == default ? null : Content.PeriodFrom.ToDateTime(TimeOnly.MinValue);
periodTo = Content.PeriodTo == default ? null : Content.PeriodTo.ToDateTime(TimeOnly.MinValue);
editContext = new EditContext(Content);
}
private IReadOnlyList<BillCheck> Checks
=> WaterHeatingBillChecks.Check(Content, WaterHeatingBillChecks.PreviousOf(bills, Content));
// Keeps the period on the bill up to date while editing, so the checks find the right
// previous bill.
private void SyncPeriod()
{
if (periodFrom is not null)
{
Content.PeriodFrom = DateOnly.FromDateTime(periodFrom.Value);
}
if (periodTo is not null)
{
Content.PeriodTo = DateOnly.FromDateTime(periodTo.Value);
}
}
private async Task SaveAsync()
{
if (periodFrom is null || periodTo is null)

View file

@ -110,8 +110,8 @@ public partial class WaterHeating : ComponentBase
var data = new WaterHeatingBill();
var dialog = await dialogService.ShowDialogAsync<WaterHeatingBillDialog>(data, new DialogParameters()
{
Width = "560px",
Height = "640px",
Width = "760px",
Height = "880px",
Title = "Abrechnung hinzufügen",
PreventDismissOnOverlayClick = true,
PreventScroll = true,
@ -130,8 +130,8 @@ public partial class WaterHeating : ComponentBase
var data = await waterHeatingBillRepository.GetWaterHeatingBillAsync(id);
var dialog = await dialogService.ShowDialogAsync<WaterHeatingBillDialog>(data, new DialogParameters()
{
Width = "560px",
Height = "640px",
Width = "760px",
Height = "880px",
Title = "Abrechnung bearbeiten",
PreventDismissOnOverlayClick = true,
PreventScroll = true,

View file

@ -1,7 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 782" role="img" aria-labelledby="guide-title">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 824" role="img" aria-labelledby="guide-title">
<title id="guide-title">Beispiel-Abrechnung: Wo stehen die Werte?</title>
<rect x="8" y="8" width="624" height="766" rx="10" fill="#fcfcfb" stroke="#e1e0d9" />
<rect x="8" y="8" width="624" height="808" rx="10" fill="#fcfcfb" stroke="#e1e0d9" />
<text x="24" y="38" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="16" font-weight="bold" fill="#0b0b0b">Beispiel: Wo stehen die Werte auf der Abrechnung?</text>
<text x="24" y="58" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12" fill="#52514e">Platzhalterwerte – der Aufbau entspricht der NeoVac-Abrechnung und der Aufstellung der Verwaltung.</text>
@ -27,7 +27,7 @@
<rect x="380" y="239" width="232" height="22" rx="4" fill="none" stroke="#e34948" stroke-width="2" />
<text x="604" y="255" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" font-weight="bold" fill="#0b0b0b">2.400</text>
<text x="604" y="273" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="11" font-weight="bold" fill="#e34948">→ Wärme (MWh)</text>
<text x="24" y="298" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12" fill="#52514e">Den Verbrauch übernehmen, nicht „Stand neu“ – das ist der Zählerstand.</text>
<text x="24" y="298" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12" fill="#52514e">„Stand neu“ ist der Zählerstand: optional in „Stand neu …“ für die Kontrolle, nicht als Verbrauch.</text>
<line x1="24" y1="312" x2="616" y2="312" stroke="#e1e0d9" stroke-width="1" />
<text x="24" y="338" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="11" font-weight="bold" fill="#898781">NEOVAC – WASSERKOSTEN / WÄRMEKOSTEN, SPALTE „ANTEIL (‰)“</text>
<!-- Wasser Grund (‰) -->
@ -51,7 +51,7 @@
<text x="604" y="495" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" font-weight="bold" fill="#0b0b0b">12.00</text>
<text x="604" y="513" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="11" font-weight="bold" fill="#c98500">→ Heizung WW (‰)</text>
<line x1="24" y1="528" x2="616" y2="528" stroke="#e1e0d9" stroke-width="1" />
<text x="24" y="554" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="11" font-weight="bold" fill="#898781">VERWALTUNG – AUFSTELLUNG, IHR ANTEIL IN CHF</text>
<text x="24" y="554" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="11" font-weight="bold" fill="#898781">VERWALTUNG – AUFSTELLUNG, IHR ANTEIL</text>
<!-- Wasserkosten (CHF) -->
<text x="24" y="589" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" fill="#0b0b0b">Wasserkosten</text>
<rect x="380" y="569" width="232" height="22" rx="4" fill="none" stroke="#1a9bb0" stroke-width="2" />
@ -62,13 +62,18 @@
<rect x="380" y="611" width="232" height="22" rx="4" fill="none" stroke="#c98500" stroke-width="2" />
<text x="604" y="627" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" font-weight="bold" fill="#0b0b0b">450.00</text>
<text x="604" y="645" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="11" font-weight="bold" fill="#c98500">→ Heizkosten (CHF)</text>
<text x="24" y="670" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12" fill="#52514e">Die Promille der Verwaltung entsprechen Grund + Verbrauch bzw. dem Wärmekostenanteil.</text>
<line x1="24" y1="684" x2="616" y2="684" stroke="#e1e0d9" stroke-width="1" />
<!-- Wasser / Heizung (‰, optional) -->
<text x="24" y="673" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" fill="#0b0b0b">Promille Wasser / Heizung</text>
<rect x="380" y="653" width="232" height="22" rx="4" fill="none" stroke="#898781" stroke-width="2" />
<text x="604" y="669" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="13" font-weight="bold" fill="#0b0b0b">90.000 / 60.000</text>
<text x="604" y="687" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="11" font-weight="bold" fill="#898781">→ Wasser / Heizung (‰, optional)</text>
<text x="24" y="712" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12" fill="#52514e">Die Kontrolle vergleicht sie mit Grund + Verbrauch bzw. dem Wärmekostenanteil von NeoVac.</text>
<line x1="24" y1="726" x2="616" y2="726" stroke="#e1e0d9" stroke-width="1" />
<!-- Worked example, informational only -->
<text x="24" y="710" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12" fill="#898781">Grundkosten 300.00 × 20 / 90</text>
<text x="604" y="710" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12" fill="#898781">66.67</text>
<text x="24" y="732" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12" fill="#898781">Verbrauch 233.33, davon 15 von 60 m³ warm</text>
<text x="604" y="732" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12" fill="#898781">Warmwasser 58.33 · Kaltwasser 175.00</text>
<text x="24" y="754" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12" fill="#898781">Heizung Warmwasser 450.00 × 12 / 60</text>
<text x="604" y="754" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12" fill="#898781">Heizung Warmwasser 90.00 · Räume 360.00</text>
<text x="24" y="752" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12" fill="#898781">Grundkosten 300.00 × 20 / 90</text>
<text x="604" y="752" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12" fill="#898781">66.67</text>
<text x="24" y="774" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12" fill="#898781">Verbrauch 233.33, davon 15 von 60 m³ warm</text>
<text x="604" y="774" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12" fill="#898781">Warmwasser 58.33 · Kaltwasser 175.00</text>
<text x="24" y="796" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12" fill="#898781">Heizung Warmwasser 450.00 × 12 / 60</text>
<text x="604" y="796" text-anchor="end" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12" fill="#898781">Heizung Warmwasser 90.00 · Räume 360.00</text>
</svg>

After

Width:  |  Height:  |  Size: 9.7 KiB