fix(migration): the CFE meter and route belong to the electric service

DATMEX.MEDIDOR/RUTA were unpivoted onto the WATER row, so every electric
service arrived without a meter and water carried CFE's. They are filled
on exactly the 1113 rows that carry an RPU (100% overlap), the meters are
CFE's alphanumeric form (53MT58), and every legacy query that reads them
is a LUZ one. medidor2/ruta2 pair with rpu2 the same way.

Takes effect on the next reimport.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rmancinasandClaude Opus 5.5 committed 2026-10-11 23:20:44 -07:00
1 parent 36158ae761
commit 2cf07ed5ee
1 file changed
+14 -11
+14 -11
View File
@@ -164,18 +164,21 @@ def main():
services.append((str(uuid.uuid4()), pid, kind, account, meter, route, services.append((str(uuid.uuid4()), pid, kind, account, meter, route,
due, 1 if active else 0, notes)) due, 1 if active else 0, notes))
# WATER (primary + extra meters) # WATER — the CESPT account only. DATMEX has no water meter column.
if s(row["agua"]) or flag("water1", False): if s(row["agua"]) or flag("water1", False):
svc("WATER", account=s(row["agua"]), meter=s(row["medidor"]), svc("WATER", account=s(row["agua"]), due=s(row["diagua"]),
route=s(row["ruta"]), due=s(row["diagua"]), active=flag("water1")) active=flag("water1"))
for mcol, rcol in (("medidor2", "ruta2"), ("medidor3", "ruta3")): # ELECTRIC — rpu account + the CFE meter and route beside it. MEDIDOR/
if s(row[mcol]) or s(row[rcol]): # RUTA are the electric meter, not water: they are filled on exactly
svc("WATER", meter=s(row[mcol]), route=s(row[rcol]), # the 1113 rows that carry an RPU (100% overlap), the meters are CFE's
notes="secondary meter", active=flag("water1")) # alphanumeric `53MT58` form, and every legacy query that reads them is
# ELECTRIC (rpu account + extras); luz_tipo as note # a LUZ one (LUZ, FALTANTES DE LUZ, "luz ruta 325 y 329"). They used to
for rc in ("rpu", "rpu2", "rpu3"): # land on the WATER row, leaving every electric service without a meter.
if s(row[rc]): # Paired by suffix: medidor2/ruta2 belong to rpu2. luz_tipo as note.
svc("ELECTRIC", account=s(row[rc]), for rc, mc, rtc in (("rpu", "medidor", "ruta"), ("rpu2", "medidor2", "ruta2"),
("rpu3", "medidor3", "ruta3")):
if s(row[rc]) or s(row[mc]):
svc("ELECTRIC", account=s(row[rc]), meter=s(row[mc]), route=s(row[rtc]),
notes=s(row["luz_tipo"]) if rc == "rpu" else None, notes=s(row["luz_tipo"]) if rc == "rpu" else None,
active=flag("electric")) active=flag("electric"))
# GAS — the column mixes two things: an account/meter number for 160 of # GAS — the column mixes two things: an account/meter number for 160 of