Bill water-only community DHW on the heat-pump network fuel 🟩

A water-only community scheme (water_heating_code 950/951/952) is served
by its own heat network, independent of the space main. _water_heating_fuel_code
now resolves the network's SAP Table 12 community fuel (e.g. 41 = heat from
electric heat pump @ 4.24 p/kWh, COP already priced into the row) instead of
defaulting to the space main's fuel. For a direct-electric main this had
mis-billed communal heat-pump DHW at the 13.19p standard-electric rate.

Dovestone Apt 4 (cert 9556-3047-3304-5355-1200): hot-water cost £353 → £113,
SAP 67 → 80.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DX8oAGsGkBHq3U4dsxYRzz
This commit is contained in:
Jun-te Kim 2026-07-27 17:35:57 +00:00
parent c89843e384
commit 20268a4a6d
2 changed files with 27 additions and 0 deletions

View file

@ -1079,3 +1079,18 @@ class TestSapWaterOnlyCommunityDhw:
assert epc.sap_heating.community_water_heating_efficiency == pytest.approx(
301.6
)
def test_prices_community_dhw_on_the_heat_pump_network(self) -> None:
# Arrange — communal heat-pump DHW; the space main is direct electric.
from domain.sap10_calculator.calculator import Sap10Calculator
raw = load("sap_18_0_water_community_hp.json")
epc = EpcPropertyDataMapper.from_api_response(raw)
# Act
result = Sap10Calculator().calculate(epc)
# Assert — DHW bills on the community heat-pump fuel (SAP Table 32 code
# 41 @ 4.24 p/kWh, COP baked in), NOT the direct-electric main (code 39
# @ 13.19 p/kWh) it was defaulting to.
assert result.hot_water_fuel_code == 41

View file

@ -1943,6 +1943,18 @@ def _water_heating_fuel_code(epc: EpcPropertyData) -> Optional[int]:
no fuel_type lodged, so the old fallback resolved to None and CO2/
PE/cost lookups returned defaults instead of the gas-combi values.
"""
# A water-ONLY community scheme (WHC 950/951/952) is served by its own heat
# network, independent of the space main. Bill DHW on the network's SAP
# Table 12 community fuel (e.g. 41 = heat from electric heat pump @ 4.24
# p/kWh — the COP is already priced into the community row) rather than
# defaulting to the space main's fuel, which for a direct-electric main
# mis-billed communal heat-pump DHW at the 13.19p standard-electric rate.
community_water_fuel = epc.sap_heating.community_water_heating_fuel
if (
epc.sap_heating.water_heating_code in _WATER_HEAT_NETWORK_ONLY_CODES
and community_water_fuel is not None
):
return community_water_fuel
if epc.sap_heating.water_heating_fuel:
fuel = epc.sap_heating.water_heating_fuel
# When DHW is on a heat network, the colliding community fuels