Co-authored-by: Claudio Schaad <c.schaad@pog.ch> Co-committed-by: Claudio Schaad <c.schaad@pog.ch>
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);
|
|
}
|
|
}
|