from __future__ import annotations from collections.abc import Mapping from dataclasses import dataclass from domain.fuel_rates.fuel import Fuel, UnpricedFuel @dataclass(frozen=True) class FuelRate: """One fuel's current tariff: unit price + daily standing charge. Off-gas fuels (oil / LPG / solid / wood) carry a ``0.0`` standing charge — they are delivered, not metered, so there is no daily charge. """ unit_rate_p_per_kwh: float standing_charge_p_per_day: float @dataclass(frozen=True) class FuelRates: """A current Fuel Rates snapshot — the rate per billing Fuel plus the SEG export credit (ADR-0014). ``period`` records which window it is for, since a committed snapshot goes stale on the Ofgem-cap (quarterly) cadence. Pricing a fuel the snapshot does not carry raises ``UnpricedFuel`` rather than defaulting — see [[reference-unmapped-sap-code]] for the same strict discipline on the calculator side. """ period: str seg_export_p_per_kwh: float rates: Mapping[Fuel, FuelRate] def unit_rate_p_per_kwh(self, fuel: Fuel) -> float: return self._rate(fuel).unit_rate_p_per_kwh def standing_charge_p_per_day(self, fuel: Fuel) -> float: return self._rate(fuel).standing_charge_p_per_day def _rate(self, fuel: Fuel) -> FuelRate: rate = self.rates.get(fuel) if rate is None: raise UnpricedFuel(fuel) return rate