using System;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace Schaad.Accounting.Models
{
///
/// 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).
///
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; }
/// Grid draw plus own PV consumption, in kWh.
[JsonIgnore]
[Display(Name = "Total")]
public decimal TotalKwh => GridKwh + PvKwh;
/// Share of the consumption covered by PV, 0..1.
[JsonIgnore]
[Display(Name = "PV-Anteil")]
public decimal PvShare => TotalKwh == 0 ? 0 : PvKwh / TotalKwh;
/// Grid, PV and side costs added up, before the advance payment.
[JsonIgnore]
[Display(Name = "Total")]
public decimal TotalChf => GridChf + PvChf + SideCostsChf;
/// What is still owed (positive) or was overpaid (negative) after the advance.
[JsonIgnore]
[Display(Name = "Saldo")]
public decimal Balance => TotalChf - AdvanceChf;
/// Average price per kWh over the whole period.
[JsonIgnore]
[Display(Name = "CHF/kWh")]
public decimal ChfPerKwh => TotalKwh == 0 ? 0 : TotalChf / TotalKwh;
}
}