feat(calculator): GREEN — consume overlay (winter,summer) ahead of Table 4b code

_main_heating_detail_efficiency uses the override winter (§206) and the Eq D1
water branch uses the override (winter,summer), both ahead of the PCDB/Table 4b
defaults — the same precedence the PCDB winter_efficiency_pct occupies. Guarded
on WHC 901 + not-electric-immersion for the water leg. Override-supplied only, so
the lodged-cert corpus is unmoved (ADR-0068). 256 calculator tests green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Khalim Conn-Kowlessar 2026-07-29 16:16:09 +00:00
parent be0fb08e65
commit 72840cbdf7

View file

@ -2112,7 +2112,18 @@ def _main_heating_detail_efficiency(
if main is not None and main.main_heating_index_number is not None
else None
)
if pcdb_main is not None and pcdb_main.winter_efficiency_pct is not None:
override_pct = (
main.seasonal_efficiency_override_pct if main is not None else None
)
if override_pct is not None:
# Landlord-Override SEDBUK-band efficiency — the fifth Heating Companion
# (ADR-0068). "Override wins": a system-replacing override makes the cert
# efficiency stale, so its `(winter, summer)` slot takes precedence over
# the Table 4b code default, occupying the same slot the PCDB
# `winter_efficiency_pct` does. Override-supplied only (lodged certs never
# set it), so the corpus is unmoved.
eff = override_pct[0] / 100.0
elif pcdb_main is not None and pcdb_main.winter_efficiency_pct is not None:
eff = pcdb_main.winter_efficiency_pct / 100.0
else:
eff = seasonal_efficiency(main_code, main_category, main_fuel)
@ -8154,8 +8165,21 @@ def cert_to_inputs(
# primary loss but ARE still eligible for Eq D1 — the spec's
# §D2.1 (2) test is "summer < winter" + "boiler provides both",
# not the primary-loss test.
override_pct = main.seasonal_efficiency_override_pct if main is not None else None
eq_d1_winter_summer_pct: Optional[tuple[float, float]] = None
if (
override_pct is not None
and epc.sap_heating.water_heating_code == _WHC_FROM_MAIN_HEATING
# Not when DHW is a separate electric immersion (WHC 903): the boiler
# does not provide water heating, so its efficiency must not reach Eq D1.
and not dhw_is_electric_immersion
):
# Landlord-Override SEDBUK-band `(winter, summer)` — the fifth Heating
# Companion (ADR-0068). It wins the Eq D1 water slot the same way it wins
# the §206 winter efficiency, ahead of the PCDB/Table 4b defaults, so a
# banded boiler's summer efficiency drives its hot-water fuel too.
eq_d1_winter_summer_pct = override_pct
elif (
pcdb_main is not None
and pcdb_main.winter_efficiency_pct is not None
and pcdb_main.summer_efficiency_pct is not None