Skip to content

[P3] Catálogos SUNAT cacheados (Cat 02 productos, 03 unidades, 06 docs, 51 operación) #19

@Railly

Description

@Railly

Context

Today the CLI hardcodes a small subset of SUNAT catalog values:

  • Cat 03 (Unidades): `NIU`, `ZZ` are common. Real catalog has ~700 entries (KGM, MTR, LTR, ...).
  • Cat 06 (Tipo doc identidad): 1, 4, 6, 7, 0 cover 99% of cases.
  • Cat 51 (Tipo operación): `0101` Venta interna hardcoded everywhere.
  • Cat 02 (Productos), Cat 09/10 (Tipo nota), Cat 20 (Motivo traslado) — partial coverage.

If a user passes an invalid `unidad`, SUNAT rejects with a cryptic 2xxx code instead of catching it client-side.

Scope

  1. Download SUNAT catalogs from official source (or vendor-in copies)
  2. `src/cpe/catalogos/` directory with one TS module per catalog
  3. `sunat schema cpe-catalogos` to introspect available codes
  4. Validation: warn (not error) on unrecognized codes — SUNAT may add new ones
  5. `cpe factura preview` includes a "catalog coverage report" if any field uses unknown codes

Source

  • Anexo VII de RS 117-2017/SUNAT: spreadsheets at sunat.gob.pe
  • Greenter has them as PHP constants (can port)

Success criteria

  • 90%+ of SUNAT validation errors caught client-side before submit
  • LIMITATIONS.md → "Catálogos SUNAT minimal" line removed

Why P3

Today's hardcoded subset works for typical case (factura PEN with NIU items). Edge cases bite SUNAT-side and the message is clear enough.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cpeCPE SOAP emission (factura/boleta/NC/ND/guia)enhancementNew feature or requestpriority:p3Nice-to-have, low priorityready-for-agentAFK agent should pick this up

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions