Translate full-SAP 18-hour off-peak tariff (code 5) to EIGHTEEN_HOUR 🟩

Add code 5 → "off-peak 18 hour" to _SAP_TARIFF_TO_RDSAP_METER_TYPE so the
full-SAP meter translation covers the whole energy_tariff code space, not
just 1-4. Table 12a resolves the word alias to Tariff.EIGHTEEN_HOUR.

Real SAP-19.1.0/19.2.0 sample certs lodge tariff 5 and now resolve to the
18-hour off-peak split instead of defaulting to STANDARD (under/over-rated).
The same fix covers 17.0/17.1/18.0.0/19.0.0 — all route through the full-SAP
mapper via the assessment_type=SAP gate.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Khalim Conn-Kowlessar 2026-06-29 22:55:40 +00:00
parent c6c07c2c51
commit 7866b4a34c

View file

@ -2966,8 +2966,9 @@ def _sap_17_1_meter_type(electricity_tariff: Optional[int]) -> str:
The two code spaces *differ* (epc_codes.csv `energy_tariff` vs
`_METER_INT_TO_TARIFF`): full-SAP 1=standard / 2=off-peak-7hr / 3=off-peak-
10hr / 4=24-hour, whereas RdSAP meter 1=dual-7hr / 2=single / 3=unknown /
4=24-hour. Passing the full-SAP code straight through (the prior bug) read a
10hr / 4=24-hour / 5=off-peak-18hr, whereas RdSAP meter 1=dual-7hr /
2=single / 3=unknown / 4=24-hour. Passing the full-SAP code straight
through (the prior bug) read a
standard-tariff cert as Economy 7 (over-rated) and an Economy-7 cert as
single (under-rated). Map onto the RdSAP word aliases so the resolved tariff
is correct; absent/ND "" (the unknownstandard sentinel)."""
@ -2985,6 +2986,7 @@ _SAP_TARIFF_TO_RDSAP_METER_TYPE: dict[int, str] = {
2: "dual", # off-peak 7 hour (Economy 7)
3: "dual", # off-peak 10 hour (§12 dispatch resolves 7/10hr)
4: "dual (24 hour)", # 24-hour tariff
5: "off-peak 18 hour", # off-peak 18 hour (Table 12a EIGHTEEN_HOUR)
}