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>
78 lines
2.7 KiB
C#
78 lines
2.7 KiB
C#
using System;
|
||
using System.ComponentModel.DataAnnotations;
|
||
using System.Text.Json.Serialization;
|
||
|
||
namespace Schaad.Accounting.Models
|
||
{
|
||
/// <summary>
|
||
/// One yearly NeoVac electricity bill for the apartment. The billing period runs
|
||
/// 1 July – 30 June, so these are not stored per calendar year like the other data files
|
||
/// (see ElectricityBillRepository in Schaad.Accounting.Db).
|
||
/// </summary>
|
||
public class ElectricityBill : IPeriodBill<ElectricityBill>
|
||
{
|
||
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 = "Netzbezug")]
|
||
public decimal GridKwh { get; set; }
|
||
|
||
[Display(Name = "PV-Produktion")]
|
||
public decimal PvKwh { get; set; }
|
||
|
||
[Display(Name = "Netzbezug")]
|
||
public decimal GridChf { get; set; }
|
||
|
||
[Display(Name = "PV")]
|
||
public decimal PvChf { get; set; }
|
||
|
||
[Display(Name = "Nebenkosten")]
|
||
public decimal SideCostsChf { get; set; }
|
||
|
||
/// <summary>Grid draw plus own PV consumption, in kWh.</summary>
|
||
[JsonIgnore]
|
||
[Display(Name = "Total")]
|
||
public decimal TotalKwh => GridKwh + PvKwh;
|
||
|
||
/// <summary>Share of the consumption covered by PV, 0..1.</summary>
|
||
[JsonIgnore]
|
||
[Display(Name = "PV-Anteil")]
|
||
public decimal PvShare => TotalKwh == 0 ? 0 : PvKwh / TotalKwh;
|
||
|
||
/// <summary>Grid, PV and side costs added up.</summary>
|
||
[JsonIgnore]
|
||
[Display(Name = "Total")]
|
||
public decimal TotalChf => GridChf + PvChf + SideCostsChf;
|
||
|
||
/// <summary>Average price per kWh over the whole period.</summary>
|
||
[JsonIgnore]
|
||
[Display(Name = "CHF/kWh")]
|
||
public decimal ChfPerKwh => TotalKwh == 0 ? 0 : TotalChf / TotalKwh;
|
||
|
||
/// <summary>Price per kWh of grid electricity; null if there was no grid draw.</summary>
|
||
[JsonIgnore]
|
||
[Display(Name = "CHF/kWh Netz")]
|
||
public decimal? GridChfPerKwh => GridKwh == 0 ? null : GridChf / GridKwh;
|
||
|
||
/// <summary>Price per kWh of PV electricity; null if there was no PV consumption.</summary>
|
||
[JsonIgnore]
|
||
[Display(Name = "CHF/kWh PV")]
|
||
public decimal? PvChfPerKwh => PvKwh == 0 ? null : PvChf / PvKwh;
|
||
|
||
public void AddShare(ElectricityBill other, decimal share)
|
||
{
|
||
GridKwh += other.GridKwh * share;
|
||
PvKwh += other.PvKwh * share;
|
||
GridChf += other.GridChf * share;
|
||
PvChf += other.PvChf * share;
|
||
SideCostsChf += other.SideCostsChf * share;
|
||
}
|
||
}
|
||
}
|