A new page (/electricity) to record one electricity bill per billing
period (1 July-30 June) with a grid, add/edit dialog, and two Chart.js
charts (kWh split grid/PV per period, CHF/kWh as a line).
- ElectricityBill (Common): Grid/PV kWh and CHF, side costs, advance
payment; computed TotalKwh, PvShare, TotalChf, Balance, ChfPerKwh.
- Stored once per mandator at {DataPath}/{mandator}/electricity.json
instead of per year, since the billing period doesn't align with
calendar years (new ISettingsService.GetMandatorPath(),
BaseRepository gets a directory-aware SaveAsync overload).
- electricity.json is also editable through the JSON editor
(RawDataRepository).
- charts.js: stackedBar/line charts can now show a unit other than
CHF (defaults to CHF, so the Analyse page is unaffected).
- The add/edit dialog links to an annotated example (SVG, placeholder
data) showing which value on the real NeoVac bill goes into which
field; opens in its own dialog since the main dialog has a fixed
height.
- Tests for the computed properties and the new repositories.
Also bumps the TargetFramework to net10.0 and updates the local
DataPath in appsettings.Development.json.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
67 lines
2.2 KiB
C#
67 lines
2.2 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
|
||
{
|
||
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; }
|
||
|
||
[Display(Name = "Akonto")]
|
||
public decimal AdvanceChf { 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, before the advance payment.</summary>
|
||
[JsonIgnore]
|
||
[Display(Name = "Total")]
|
||
public decimal TotalChf => GridChf + PvChf + SideCostsChf;
|
||
|
||
/// <summary>What is still owed (positive) or was overpaid (negative) after the advance.</summary>
|
||
[JsonIgnore]
|
||
[Display(Name = "Saldo")]
|
||
public decimal Balance => TotalChf - AdvanceChf;
|
||
|
||
/// <summary>Average price per kWh over the whole period.</summary>
|
||
[JsonIgnore]
|
||
[Display(Name = "CHF/kWh")]
|
||
public decimal ChfPerKwh => TotalKwh == 0 ? 0 : TotalChf / TotalKwh;
|
||
}
|
||
}
|