fix/cfdi-columns
needs attentionviewing older commit0869f39 · fullpre-PRreviewed 2026-08-05 13:58 UTC1H · 8M · 5L · 5I- Purpose
- Historical CFE bills are missing CFDI stamp metadata because the old parser never walked cfdi:Complemento. Text-typed fields were rendering as numbers. Two enterprise customers raised the issue.
- Goal
- Surface CFDI fiscal stamp state on all existing bills and fix column rendering for text-typed concepts
- Sub-goals
- SG-1: Extend xml-parser to read cfdi:Complemento
- SG-2: Fix repeated-element array stringification
- SG-3: Derive cfdiStampStatus from UUID + error presence
- SG-4: Fix decideColumnType to use units catalog
- SG-5: Seed 4 new concepts into 11 tariff catalogs
- SG-6: Backfill 143k XML-backed bills
- SG-7: Add parseOrgs + orgInFilter for per-customer ramp
- What
- XML parser extended. decideColumnType refactored. 11 tariff JSONs + CANONICAL seeded. New backfill + rollback scripts. ops-guards gets parseOrgs + orgInFilter.
- Why
- cfdi:Complemento was outside the parser's walk path. Repeated XML elements produced comma-joined garbage. decideColumnType defaulted to number for unknown units.
- Areas
- services/utility/bills/cfe+328−7domains/utility+279−3scripts+448−0packages/database+78−0docs/development+182−0
- Blast
- 23 files, +1332/-7. Parser change affects all CFE XML ingestion. decideColumnType touches all bill table rendering.
Findings · 9
correctness2
Idempotency gate skips bills with cfdiStampStatus from Lambda before backfill runs
scripts/backfill-cfdi-fiscal-concepts.ts:191
byKey.has('cfdiStampStatus') && needsRepair.length===0 short-circuits even if error fields are absent. Fix: check all needed keys, not just the sentinel.
deriveStampStatus: ErrorCodigo alone does not trigger Error de timbrado
services/utility/bills/cfe/src/file-processor/xml-parser/xml-parser.ts:496
security2
parseOrgs accepts unvalidated argv strings
packages/database/src/ops-guards.ts
guardConnection is process-discipline, not a technical safeguard
packages/database/src/ops-guards.ts
tests4
cfdiStampStatus: missing edge case — UUID placeholder + error code both present
services/utility/bills/cfe/__tests__/unit/file-processor/xml-parser.test.ts
firstMeaningfulEntry: no test for whitespace-only first occurrence
services/utility/bills/cfe/__tests__/unit/file-processor/xml-parser.test.ts
No test verifying CANONICAL covers all concepts in tariff JSONs
domains/utility/src/bill-concepts-catalog/__tests__/bill-concepts-catalog.decisions.test.ts
decideColumnType regression coverage narrow
domains/utility/src/bill-concepts-catalog/__tests__/bill-concepts-catalog.decisions.test.ts
improvement1
Second idempotency check (line 195) is structurally dead code
scripts/backfill-cfdi-fiscal-concepts.ts:195