NeoVac only reports per-mille shares of the property; the own costs in CHF come from the property manager's statement. The new page stores both in water-heating.json (per mandator) and calculates the CHF parts: water base and consumption costs by their per-mille share, consumption split by m³ into warm and cold water, and the warm water part of the heating costs (the rest is room heating). Charts for water (m³), heat (MWh) and the stacked costs; the dialog has a guide image showing where each value is on the bills. The Wasser page stays for bills with the CHF values entered directly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
87 lines
2.4 KiB
C#
87 lines
2.4 KiB
C#
using Schaad.Accounting.Models;
|
|
using Shouldly;
|
|
|
|
namespace Schaad.Accounting.Tests;
|
|
|
|
public class WaterHeatingBillTestShould
|
|
{
|
|
// Values of the 2024/25 bill: NeoVac per-mille shares and the own share from the property manager.
|
|
private static WaterHeatingBill Bill() => new()
|
|
{
|
|
WarmWaterM3 = 16.399m,
|
|
ColdWaterM3 = 51.464m,
|
|
WaterBasePermille = 19.52m,
|
|
WaterConsumptionPermille = 68.50m,
|
|
HeatingPermille = 62.82m,
|
|
WarmWaterHeatingPermille = 12.66m,
|
|
WaterCostsChf = 304.30m,
|
|
HeatingCostsChf = 451.65m
|
|
};
|
|
|
|
[Fact]
|
|
public void SplitWaterCostsByPermilleAndM3WhenCalculatingCosts()
|
|
{
|
|
var bill = Bill();
|
|
|
|
bill.CalculateCosts();
|
|
|
|
bill.BaseCostsChf.ShouldBe(67.48m);
|
|
bill.WarmWaterChf.ShouldBe(57.23m);
|
|
bill.ColdWaterChf.ShouldBe(179.59m);
|
|
}
|
|
|
|
[Fact]
|
|
public void SplitHeatingCostsIntoWarmWaterAndRoomsWhenCalculatingCosts()
|
|
{
|
|
var bill = Bill();
|
|
|
|
bill.CalculateCosts();
|
|
|
|
bill.WarmWaterHeatingChf.ShouldBe(91.02m);
|
|
bill.RoomHeatingChf.ShouldBe(360.63m);
|
|
bill.TotalChf.ShouldBe(755.95m);
|
|
}
|
|
|
|
[Fact]
|
|
public void PutAllConsumptionCostsOnColdWaterWhenCalculatingCostsWithoutConsumption()
|
|
{
|
|
var bill = new WaterHeatingBill { WaterCostsChf = 100m, WaterBasePermille = 20m, WaterConsumptionPermille = 80m };
|
|
|
|
bill.CalculateCosts();
|
|
|
|
bill.BaseCostsChf.ShouldBe(20m);
|
|
bill.WarmWaterChf.ShouldBe(0m);
|
|
bill.ColdWaterChf.ShouldBe(80m);
|
|
}
|
|
|
|
[Fact]
|
|
public void LeaveHeatingCostsOnRoomsWhenCalculatingCostsWithoutPermilleShares()
|
|
{
|
|
var bill = new WaterHeatingBill { HeatingCostsChf = 450m };
|
|
|
|
bill.CalculateCosts();
|
|
|
|
bill.BaseCostsChf.ShouldBe(0m);
|
|
bill.WarmWaterHeatingChf.ShouldBe(0m);
|
|
bill.RoomHeatingChf.ShouldBe(450m);
|
|
}
|
|
|
|
[Fact]
|
|
public void AddShareOfConsumptionAndCostsWhenAddingShareOfOtherBill()
|
|
{
|
|
var other = Bill();
|
|
other.HeatingMwh = 2.458m;
|
|
other.CalculateCosts();
|
|
var sum = new WaterHeatingBill();
|
|
|
|
sum.AddShare(other, 0.5m);
|
|
|
|
sum.WarmWaterM3.ShouldBe(8.1995m);
|
|
sum.HeatingMwh.ShouldBe(1.229m);
|
|
sum.WaterCostsChf.ShouldBe(152.15m);
|
|
sum.HeatingCostsChf.ShouldBe(225.825m);
|
|
sum.ColdWaterChf.ShouldBe(89.795m);
|
|
sum.WarmWaterHeatingChf.ShouldBe(45.51m);
|
|
sum.WaterBasePermille.ShouldBe(0m);
|
|
}
|
|
}
|