The "Stand neu" fields for warm water, cold water and heat and their continuity checks are gone; the per-mille, property total and price checks stay. The "Kontrolle" heading is only shown when there is a check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
114 lines
4.1 KiB
C#
114 lines
4.1 KiB
C#
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 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);
|
|
}
|
|
}
|