Numeric RdSAP property-type codes map to their labels 🟩

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Khalim Conn-Kowlessar 2026-07-07 11:38:47 +00:00
parent 302861309c
commit dfe42a6374

View file

@ -76,6 +76,17 @@ def resolve_filtered_property_ids(
]
# RdSAP numeric codes as lodged on some certs; text labels pass through as-is
# (ADR-0056 — the mapping is part of the shared preview contract).
_PROPERTY_TYPE_CODES: dict[str, str] = {
"0": "House",
"1": "Bungalow",
"2": "Flat",
"3": "Maisonette",
"4": "Park home",
}
def _resolved_property_types(
session: Session, property_ids: list[int]
) -> dict[int, str]:
@ -97,7 +108,10 @@ def _resolved_property_types(
by_epc_source: dict[str, dict[int, str]] = {"lodged": {}, "predicted": {}}
for epc in epcs:
if epc.property_id is not None and epc.property_type is not None:
by_epc_source[epc.source][epc.property_id] = epc.property_type
value = epc.property_type
by_epc_source[epc.source][epc.property_id] = _PROPERTY_TYPE_CODES.get(
value, value
)
resolved: dict[int, str] = {}
for pid in property_ids: