namespace MeterVault.Infrastructure.Dashboard;
/// One month of the PV panel: generation, and (when role-tagged meters exist) the
/// self-consumption / grid-draw / savings split that reproduces the sheet's Netz-Einsparung column.
public sealed record SolarMonth(
DateOnly Period,
double Generation,
double? SelfConsumption,
double? GridImport,
double? TotalLoad,
double? Savings);
/// Per-generation-meter total over the selected period (for the ranked list).
public sealed record GenerationMeterRow(int MeterId, string Name, double Generation);
///
/// The PV / solar panel read model (SDD ยง8.4): total generation plus, when the install has tagged
/// a total_load and grid_import meter, self-consumption, autarky %, self-consumption %
/// and savings (Ersparnis). Derived metrics are null when no role config exists.
///
public sealed record SolarSummary(
double Generation,
double? TotalLoad,
double? GridImport,
double? SelfConsumption,
double? Autarky,
double? SelfConsumptionRatio,
double? Savings,
IReadOnlyList Meters,
IReadOnlyList Months)
{
/// True when the install has the role-tagged meters needed for self-consumption metrics.
public bool HasLoadContext => TotalLoad is not null && GridImport is not null;
/// True when at least one generation meter exists.
public bool HasGeneration => Meters.Count > 0;
}