diff --git a/domain/fuel_rates/fuel_rates.py b/domain/fuel_rates/fuel_rates.py index 569c6f17..81f78ab0 100644 --- a/domain/fuel_rates/fuel_rates.py +++ b/domain/fuel_rates/fuel_rates.py @@ -35,7 +35,10 @@ class OffPeakRate: def blended_p_per_kwh(self, high_rate_fraction: float) -> float: """Effective p/kWh for an end use billing ``high_rate_fraction`` of its kWh at the day (high) rate and the remainder at the night (low) rate.""" - raise NotImplementedError + return ( + high_rate_fraction * self.day_p_per_kwh + + (1.0 - high_rate_fraction) * self.night_p_per_kwh + ) @dataclass(frozen=True) @@ -58,7 +61,9 @@ class FuelRates: """Blended day/night p/kWh for an Off-Peak Meter end use at the given High-Rate Fraction. Raises ``UnpricedFuel`` when the snapshot carries no off-peak entry.""" - raise NotImplementedError + if self.off_peak is None: + raise UnpricedFuel(Fuel.ELECTRICITY_OFF_PEAK) + return self.off_peak.blended_p_per_kwh(high_rate_fraction) def unit_rate_p_per_kwh(self, fuel: Fuel) -> float: return self._rate(fuel).unit_rate_p_per_kwh