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>
63 lines
2.1 KiB
C#
63 lines
2.1 KiB
C#
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;
|
||
}
|
||
}
|
||
}
|