diff --git a/domain/modelling/generators/heating_recommendation.py b/domain/modelling/generators/heating_recommendation.py index cdadf50bf..7efbc05a4 100644 --- a/domain/modelling/generators/heating_recommendation.py +++ b/domain/modelling/generators/heating_recommendation.py @@ -283,10 +283,14 @@ _OIL_FUEL_CODES = frozenset({28, 4, 71, 73, 75, 76}) _LPG_FUEL_CODES = frozenset({27, 2, 3, 5, 9}) -def ashp_cost_inputs(epc: EpcPropertyData) -> AshpCostInputs: +def ashp_cost_inputs( + epc: EpcPropertyData, design_heat_loss_kw: Optional[float] = None +) -> AshpCostInputs: """Read an `EpcPropertyData` into the typed inputs `Products.ashp_bundle_cost` - needs: the existing system, property-size band, design heat loss (floor-area - proxy), radiator count, and whether a wet system can be reused (ADR-0025).""" + needs: the existing system, property-size band, design heat loss, radiator + count, and whether a wet system can be reused (ADR-0025). ``design_heat_loss_kw`` + (the calculator's value, ADR-0049) sizes the cost band; when omitted it falls + back to the floor-area proxy so cost and pump size share one figure.""" system: AshpExistingSystem = _existing_system(epc) floor_area: float = epc.total_floor_area_m2 return AshpCostInputs( diff --git a/tests/domain/modelling/test_ashp_cost_inputs.py b/tests/domain/modelling/test_ashp_cost_inputs.py index c75cf52fc..ce528f1bb 100644 --- a/tests/domain/modelling/test_ashp_cost_inputs.py +++ b/tests/domain/modelling/test_ashp_cost_inputs.py @@ -82,3 +82,19 @@ def test_oil_and_lpg_dwellings_are_reusable_wet_systems() -> None: assert ashp_cost_inputs(_with_fuel(28)).existing_system is AshpExistingSystem.OIL assert ashp_cost_inputs(_with_fuel(27)).existing_system is AshpExistingSystem.LPG assert ashp_cost_inputs(_with_fuel(28)).has_reusable_wet_system is True + + +def test_threaded_design_heat_loss_drives_the_cost_band_over_the_proxy() -> None: + # When the caller threads the calculator's real design heat loss (ADR-0049), + # the ASHP cost sizes to it — not the floor-area proxy — so a leaky dwelling's + # bigger pump is priced on the right band. + # Arrange + epc = parse_recommendation_summary( + "ashp_from_system_boiler_with_cylinder_001431_before.pdf" + ) + + # Act + inputs: AshpCostInputs = ashp_cost_inputs(epc, design_heat_loss_kw=17.5) + + # Assert — the threaded value, not the 4.5 kW proxy. + assert inputs.design_heat_loss_kw == 17.5