Utilities module: property browser (list/search/detail) + trust renewals

Plan step 5. Properties, services and trust accounts become a first-class
browser the way /polizas is for insurance.

API (apps/api/src/properties):
  GET /properties         search over address, customer, service account
                          number, meter, trust number and phones; filters for
                          service kind, municipality, trust bank, trust bucket
                          (with|without|active|expiring|expired|undated) and
                          hasServices; 5 sorts
  GET /properties/stats   properties/owners/services/trusts, renewal counts,
                          service mix per kind
  GET /properties/facets  kinds, municipalities, banks — all with counts
  GET /properties/:id     services, fideicomiso, linked policy, owner and
                          sibling properties, owner-level utility ledger

Web: /servicios (renewals-first browser, clickable stat cells and service-mix
strip) and /servicios/[id]. Property cards on /clientes/[id] and linked
properties on /polizas/[id] now navigate into it.

Data findings baked into the design:
  - The trust deadline staff chase is trust_accounts.dueDate2 (DATMEX vence2),
    one year after vence1 on 531 of 541 dated trusts: 18 due within 30 days,
    119 already overdue. Every renewal bucket keys off dueDate2 alone.
  - properties.zone is dead (1444 of 1519 null, the rest near-unique), so the
    geographic filter is the municipality carried in the predial service's
    notes (ROSARITO 566 / TIJUANA 221 / ENSENADA 152, 939/939 populated).
  - PropertyService.notes means a different thing per kind (municipality, CFE
    PAR/IMPAR cycle, gas supply type, cable provider) and is labelled as such.
  - 240 of 1519 properties have no service rows at all — its own bucket.

Sorting by trust due date scopes to properties that have a trust, since MySQL
would otherwise float the ~966 trust-less NULLs above every real due date;
the sort label and the result meta both say so.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-22 22:04:07 -07:00
co-authored by Claude Opus 4.8
parent c291bc8d4c
commit 61193586a5
14 changed files with 2086 additions and 7 deletions
+18 -3
View File
@@ -216,9 +216,24 @@ Homebrew. No Access ODBC driver, `node_modules` not installed, staging Parquet n
premium, so every premium headline and the premium sort use `netPremium` (populated on
2377/2378). This also fixed a live bug on the customer detail page, which was showing
"$0.00 Total" for 1585 policies.
- **NEXT:** plan step 5 — Utilities module (properties / services / trust accounts as a
first-class browser, the way `/polizas` now is for insurance), then step 6, the shared
billing/statements view.
- **Utilities module (plan step 5) — DONE**: `apps/api/src/properties/` (`GET /properties`
with search over address / customer / service account number / meter / trust number /
phones, filters for service kind, municipality, trust bank, trust bucket
(with|without|active|expiring|expired|undated) and `hasServices`, 5 sorts;
`/properties/stats`, `/properties/facets`, `/properties/:id`) + web `/servicios`
(renewals-first property browser with clickable stat cells and a clickable service-mix
strip) and `/servicios/[id]` (services, fideicomiso, linked policy, owner + sibling
properties, owner-level utility ledger, documents). Cross-links both ways with the
customer and policy views. **Data findings:** (a) the trust renewal date staff chase is
`trust_accounts.dueDate2` — DATMEX's `vence2`, one year after `vence1` on 531 of 541
dated trusts (18 due within 30 days, 119 already overdue); (b) `properties.zone` is
effectively dead (1444 of 1519 null, the rest near-unique), so it is not a facet;
(c) the municipality that bills a property lives in the *predial* service's `notes`
(ROSARITO 566 / TIJUANA 221 / ENSENADA 152, 939/939 populated) — that is the real
geographic filter. `PropertyService.notes` means something different per kind
(municipality / CFE PAR-IMPAR cycle / gas supply type), so the UI labels it per kind.
240 of 1519 properties have no service rows at all — surfaced as its own bucket.
- **NEXT:** plan step 6 — the shared billing/statements view across both business lines.
- Full pipeline reproducible in one command: `run_all.py --env <env>` runs customers ->
properties -> policies -> transactions -> bank in order (all idempotent); add `--stage`
to re-extract from the Access files first. Verified end-to-end against dev.