AccountingNext/Schaad.Accounting.Common/Models/ElectricityBill.cs
Claudio Schaad ec0bf7d602 Split the CHF/kWh chart by Netz/PV and fix its axis scale
The price-per-kWh line only showed the blended total; add GridChfPerKwh
and PvChfPerKwh (null when there was no draw/consumption of that kind,
so the chart shows a gap instead of a misleading 0) and plot Netz, PV
and Total as separate lines.

Also fixes the y-axis: ticks used a fixed 0-decimal formatter, so
CHF/kWh values (well under 1) all rounded to "0". charts.js now takes
an optional data.axisDecimals (defaults to 0, so the Analyse page is
unaffected); the Strom page passes 2 for its CHF/kWh chart.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-26 16:27:17 +01:00

77 lines
2.7 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 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;
/// <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;
}
}