Take the full heat-network standing charge, not both, when space heating is also on the network 🟩

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Daniel Roth 2026-07-15 13:46:08 +00:00
parent 43e69f159a
commit dd9e316796

View file

@ -9161,6 +9161,52 @@ def test_water_only_heat_network_half_charge_adds_to_the_dwellings_fuel_standing
assert abs(total - 84.0) <= 1e-9
def test_water_only_code_on_a_heat_network_space_main_takes_the_full_charge_not_both() -> None:
# Arrange — SAP 10.2 §C6's "unless" clause. A water-only WHC (950) can sit
# on a cert whose SPACE main is ALSO a heat network (SAP 301). C6 gives the
# half "unless the space heating is also a heat network (see next
# paragraph)", and that next paragraph (p.55) says "the total standing
# charge is the normal heat network standing charge" — £120 flat.
#
# So the half must NOT stack onto the full charge here: £180 would be the
# double-count this branch exists to prevent, and £120 is not additive with
# the dwelling's fuel standing either ("the TOTAL standing charge IS").
from dataclasses import replace
from domain.sap10_calculator.tables.table_12a import Tariff
base = _typical_semi_detached_epc()
network_main = MainHeatingDetail(
has_fghrs=False,
main_fuel_type=20, # EPC mains gas (community)
heat_emitter_type=1,
emitter_temperature=1,
main_heating_control=2306,
main_heating_category=6,
sap_main_heating_code=301, # community boilers — a heat network
)
epc = replace(
base,
sap_heating=make_sap_heating(
main_heating_details=[network_main],
water_heating_code=950,
water_heating_fuel=20,
),
)
# Act
total = _standing_charges_total_gbp(
epc,
network_main,
main_fuel_code=20,
water_heating_fuel_code=20,
tariff=Tariff.STANDARD,
)
# Assert — the full £120, not £120 + £60.
assert abs(total - 120.0) <= 1e-9
def test_water_only_heat_network_half_charge_reaches_the_fuel_cost_worksheet() -> None:
# Arrange — the §C6 half charge must reach worksheet (251), not just the
# helper. A gas-boiler main (SAP 102, not a network) with WHC 950 keeps the