diff --git a/CLAUDE.md b/CLAUDE.md index 866c75b..91baef4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -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.FromBills` over `IPeriodBill`; 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. 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`) +- **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, 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 diff --git a/Schaad.Accounting.Common/Models/WaterHeatingBill.cs b/Schaad.Accounting.Common/Models/WaterHeatingBill.cs index 656f0ad..f3703fb 100644 --- a/Schaad.Accounting.Common/Models/WaterHeatingBill.cs +++ b/Schaad.Accounting.Common/Models/WaterHeatingBill.cs @@ -35,18 +35,6 @@ 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")] @@ -132,10 +120,7 @@ namespace Schaad.Accounting.Models private static decimal Round(decimal value) => Math.Round(value, 2, MidpointRounding.AwayFromZero); - /// - /// Adds up consumption and CHF values; the per-mille shares and meter readings don't add up - /// and are left out. - /// + /// Adds up consumption and CHF values; the per-mille shares don't add up and are left out. public void AddShare(WaterHeatingBill other, decimal share) { WarmWaterM3 += other.WarmWaterM3 * share; diff --git a/Schaad.Accounting.Common/Models/WaterHeatingBillChecks.cs b/Schaad.Accounting.Common/Models/WaterHeatingBillChecks.cs index e38a557..e5a0bfe 100644 --- a/Schaad.Accounting.Common/Models/WaterHeatingBillChecks.cs +++ b/Schaad.Accounting.Common/Models/WaterHeatingBillChecks.cs @@ -17,9 +17,8 @@ namespace Schaad.Accounting.Models /// /// Plausibility checks for a , 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. + /// property manager's per-mille shares must match, and the prices per unit shouldn't jump + /// against the previous bill. Checks whose optional inputs are missing are left out. /// public static class WaterHeatingBillChecks { @@ -27,7 +26,6 @@ namespace Schaad.Accounting.Models public const decimal MaxPriceChange = 0.25m; private const decimal PermilleTolerance = 0.005m; - private const decimal MeterTolerance = 0.0005m; private static readonly CultureInfo SwissNumbers = CreateSwissNumbers(); @@ -58,10 +56,6 @@ namespace Schaad.Accounting.Models $"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) @@ -77,26 +71,6 @@ namespace Schaad.Accounting.Models return checks; } - private static void AddMeterCheck(List 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 checks, string name, string unit, decimal? price, decimal? previousPrice) { if (price is not decimal now) @@ -129,8 +103,6 @@ namespace Schaad.Accounting.Models 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"); diff --git a/Schaad.Accounting.Tests/WaterHeatingBillChecksTestShould.cs b/Schaad.Accounting.Tests/WaterHeatingBillChecksTestShould.cs index 7f77ecc..42f6d11 100644 --- a/Schaad.Accounting.Tests/WaterHeatingBillChecksTestShould.cs +++ b/Schaad.Accounting.Tests/WaterHeatingBillChecksTestShould.cs @@ -70,43 +70,6 @@ public class WaterHeatingBillChecksTestShould 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() { diff --git a/Schaad.Accounting.UI/Components/Pages/Dialogs/WaterHeatingBillDialog.razor b/Schaad.Accounting.UI/Components/Pages/Dialogs/WaterHeatingBillDialog.razor index 2fa7254..f64fb8b 100644 --- a/Schaad.Accounting.UI/Components/Pages/Dialogs/WaterHeatingBillDialog.razor +++ b/Schaad.Accounting.UI/Components/Pages/Dialogs/WaterHeatingBillDialog.razor @@ -25,11 +25,6 @@ - - - - -
NeoVac – Anteil (‰)
@@ -68,10 +63,13 @@ Total @M3(Content.TotalM3) · @Mwh(Content.HeatingMwh) · @Chf(Content.TotalChf) -
Kontrolle
- @foreach (var check in Checks) + @if (Checks is { Count: > 0 } checks) { -
@CheckSymbol(check.Result) @check.Text
+
Kontrolle
+ @foreach (var check in checks) + { +
@CheckSymbol(check.Result) @check.Text
+ } } diff --git a/Schaad.Accounting.UI/Components/Pages/Dialogs/WaterHeatingBillDialog.razor.cs b/Schaad.Accounting.UI/Components/Pages/Dialogs/WaterHeatingBillDialog.razor.cs index 9142356..2d05871 100644 --- a/Schaad.Accounting.UI/Components/Pages/Dialogs/WaterHeatingBillDialog.razor.cs +++ b/Schaad.Accounting.UI/Components/Pages/Dialogs/WaterHeatingBillDialog.razor.cs @@ -22,7 +22,7 @@ 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). + // The other bills, to find the previous one for the price checks. private List bills = []; [CascadingParameter] diff --git a/Schaad.Accounting.UI/Components/Pages/WaterHeating.razor.cs b/Schaad.Accounting.UI/Components/Pages/WaterHeating.razor.cs index 08f00f4..25eba78 100644 --- a/Schaad.Accounting.UI/Components/Pages/WaterHeating.razor.cs +++ b/Schaad.Accounting.UI/Components/Pages/WaterHeating.razor.cs @@ -111,7 +111,7 @@ public partial class WaterHeating : ComponentBase var dialog = await dialogService.ShowDialogAsync(data, new DialogParameters() { Width = "760px", - Height = "880px", + Height = "820px", Title = "Abrechnung hinzufügen", PreventDismissOnOverlayClick = true, PreventScroll = true, @@ -131,7 +131,7 @@ public partial class WaterHeating : ComponentBase var dialog = await dialogService.ShowDialogAsync(data, new DialogParameters() { Width = "760px", - Height = "880px", + Height = "820px", Title = "Abrechnung bearbeiten", PreventDismissOnOverlayClick = true, PreventScroll = true, diff --git a/Schaad.Accounting.UI/wwwroot/images/water-heating-bill-guide.svg b/Schaad.Accounting.UI/wwwroot/images/water-heating-bill-guide.svg index f1e4259..7892abe 100644 --- a/Schaad.Accounting.UI/wwwroot/images/water-heating-bill-guide.svg +++ b/Schaad.Accounting.UI/wwwroot/images/water-heating-bill-guide.svg @@ -27,7 +27,7 @@ 2.400 → Wärme (MWh) - „Stand neu“ ist der Zählerstand: optional in „Stand neu …“ für die Kontrolle, nicht als Verbrauch. + Den Verbrauch übernehmen, nicht „Stand neu“ – das ist der Zählerstand. NEOVAC – WASSERKOSTEN / WÄRMEKOSTEN, SPALTE „ANTEIL (‰)“