AccountingNext/Schaad.Accounting.Common/Models/WaterBill.cs
Claudio Schaad 1e9e19ebad Add "Wasser" page for the water bills
Same layout as the Strom page: grid and dialog for the bills (warm and
cold water in m3 and CHF, base costs; total m3 and CHF are computed),
stored per mandator in water.json, and charts for consumption and total
costs with the period toggle (bill, calendar year, half-year).

The period grouping is now generic: ElectricityPeriod becomes
BillPeriod<T> over IPeriodBill<T>, implemented by ElectricityBill and
WaterBill. water.json can be edited in the JSON editor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 20:56:18 +01:00

63 lines
2.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace Schaad.Accounting.Models
{
/// <summary>
/// One water bill for the apartment. Like the electricity bills, these are stored once per
/// mandator instead of per calendar year, because the billing period (e.g. 1 July – 30 June)
/// doesn't align with calendar years (see WaterBillRepository in Schaad.Accounting.Db).
/// </summary>
public class WaterBill : IPeriodBill<WaterBill>
{
public string Id { get; set; }
[Display(Name = "Von")]
[Required]
public DateOnly PeriodFrom { get; set; }
[Display(Name = "Bis")]
[Required]
public DateOnly PeriodTo { get; set; }
[Display(Name = "Warmwasser")]
public decimal WarmWaterM3 { get; set; }
[Display(Name = "Kaltwasser")]
public decimal ColdWaterM3 { get; set; }
[Display(Name = "Warmwasser")]
public decimal WarmWaterChf { get; set; }
[Display(Name = "Kaltwasser")]
public decimal ColdWaterChf { get; set; }
[Display(Name = "Grundkosten")]
public decimal BaseCostsChf { get; set; }
/// <summary>Warm plus cold water, in m³.</summary>
[JsonIgnore]
[Display(Name = "Total")]
public decimal TotalM3 => WarmWaterM3 + ColdWaterM3;
/// <summary>Share of the consumption that was warm water, 0..1.</summary>
[JsonIgnore]
[Display(Name = "Warmwasser-Anteil")]
public decimal WarmWaterShare => TotalM3 == 0 ? 0 : WarmWaterM3 / TotalM3;
/// <summary>Warm water, cold water and base costs added up.</summary>
[JsonIgnore]
[Display(Name = "Total")]
public decimal TotalChf => WarmWaterChf + ColdWaterChf + BaseCostsChf;
public void AddShare(WaterBill other, decimal share)
{
WarmWaterM3 += other.WarmWaterM3 * share;
ColdWaterM3 += other.ColdWaterM3 * share;
WarmWaterChf += other.WarmWaterChf * share;
ColdWaterChf += other.ColdWaterChf * share;
BaseCostsChf += other.BaseCostsChf * share;
}
}
}