Skip to content

Added lading support#5

Open
Anidem1995 wants to merge 8 commits intomainfrom
feat/AddLadingSupport
Open

Added lading support#5
Anidem1995 wants to merge 8 commits intomainfrom
feat/AddLadingSupport

Conversation

@Anidem1995
Copy link
Copy Markdown

@Anidem1995 Anidem1995 commented Mar 21, 2026

Summary by CodeRabbit

  • New Features

    • Full lading (shipping manifest) support: comprehensive typed models for customs, addresses, locations, merchandise, documentation, transport modes (road, sea, air, rail), vehicles/containers, parties and transport parts. Complement now requires core transport and weight IDs, plus locations and merchandise, with many optional transport/customs fields.
  • Chores

    • Released version 4.0.372.

@Anidem1995 Anidem1995 requested a review from mendozagit March 21, 2026 23:22
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 21, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a typed Carta Porte (lading) model in src/models/invoice.ts (replacing the LadingComplement placeholder) with many new lading-related interfaces, updates src/index.ts to re-export those types, and bumps the package version in package.json from 4.0.360 to 4.0.372.

Changes

Cohort / File(s) Summary
Package Configuration
package.json
Bumped version from 4.0.360 to 4.0.372.
Export Declarations
src/index.ts
Added re-exports from ./models/invoice for new lading types, including LadingCustomsRegime, LadingLocationAddress, LadingFigureAddress, LadingLocation, LadingMerchandiseDetail, LadingCustomsDocument, LadingGuideIdentification, LadingQuantityTransported, LadingMerchandise, LadingTrailer, LadingAutoTransport, LadingSeaTrailerCCP, LadingSeaContainer, LadingSeaTransport, LadingAirTransport, LadingRailContainer (alias of LadingContainerCar), LadingRailcar (alias of LadingCar), LadingRailRightOfWay, LadingRailTransport, LadingTransportPart, LadingFigure.
Model Implementation
src/models/invoice.ts
Replaced LadingComplement placeholder with a comprehensive typed schema and added many export interface definitions modelling customs regimes, addresses, locations, merchandise details, customs documents, guide IDs, quantities transported, auto/sea/air/rail transport (containers, trailers, cars, rights-of-way), transport parts and figures. LadingComplement now requires transpInternacId, unidadPesoId, ubicaciones, mercancias; numerous other fields are optional.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐇 I hopped through types and fields today,

I stacked the crates and mapped the way,
From trailers, ships, to rails that hum,
The schema sings — a thorough drum,
I twitch my nose and bounce away.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Added lading support' directly and accurately summarizes the main change: introducing comprehensive lading (carta porte) support by expanding type exports and implementing a full LadingComplement schema.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/AddLadingSupport

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@mendozagit mendozagit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Encontre muchas discrepancias entre los modelos del SDK y el contrato público de la API. Por favor utiliza como referencia la API publica (CartaPorteComplementRequest.cs en el backend) y sus clases anidadas para validar campo por campo o directamente reescribir los modelos equivalentes. Los problemas principales son: propiedades que la API expone pero el SDK no tiene (~20 en mercancias, 5 de seguros en autotransporte, guias de identificacion completas), campos marcados como opcionales en el SDK cuando la API los exige como obligatorios (8 en transporte maritimo, 4 en aereo, 3 en ferroviario, entre otros), campos marcados como obligatorios en el SDK cuando la API los tiene como opcionales (totalDistRec, pesoNetoTotal), y 5 campos en el SDK que no existen en la API (configMaritimaId, numCertITC, nombreEmbarCargador, nombreAgente en maritimo y rfcTransportista en aereo). Ademas los nombres de los campos del SDK no coinciden con los nombres que usa el backend. Esto agrega una carga cognitiva alta cuando se realiza trazabilidad entre el SDK y la API publica, o cuando toca debuggear por que un campo no llega como se esperaba. Te sugiero que uses los mismos nombres de propiedades que tiene CartaPorteComplementRequest.cs y sus clases relacionadas, manteniendo tipos de datos equivalentes y la misma obligatoriedad.

Otro comentario es que Falta interface LadingGuiaIdentificacion, no lo agregue en el código porque no existe tal código.

La API expone guiasIdentificacion como lista en Mercancia con 3 campos: numeroGuiaIdentificacion, descripGuiaIdentificacion, pesoGuiaIdentificacion. Crea la interface LadingGuiaIdentificacion con esos
campos, agrega la propiedad guiasIdentificacion en LadingMerchandise y exportala en index.ts.

Revise superficialmente el de Java y veo los mismos issues. Por favor haz ajustes en todo y avísame cuando esté listo para Code review por favor.

Comment thread src/models/invoice.ts
/**
* Mercancía en carta porte
*/
export interface LadingMerchandise {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Faltan propiedades en LadingMerchandise que la API sí expone. Revisa este contrato en la API: CartaPorteMercanciaRequest

Las siguientes propiedades existen en el backend pero no en el SDK:

  • claveSTCCId
  • unidad
  • dimensiones
  • cveMaterialPeligrosoId
  • embalajeId
  • descripEmbalaje
  • sectorCOFEPRISId
  • nombreIngredienteActivo
  • nomQuimico
  • permisoImportacion
  • folioImpoVUCEM
  • numCAS
  • razonSocialEmpImp
  • numRegSanPlagCOFEPRIS
  • datosFabricante
  • datosFormulador
  • datosMaquilador
  • usoAutorizado
  • uuidComercioExt

Agregar todas estas propiedades opcionales a LadingMerchandise.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
src/index.ts (1)

87-88: Public alias casing inconsistency: LadingRailcar vs LadingRailContainer.

The two rail-related aliases use different compound-word casing on the public API surface. For consistency with LadingRailContainer, consider LadingRailCar. Also note that the original names LadingContainerCar/LadingCar are not re-exported, so once published consumers can only import the aliased names — confirm that's intentional (no code path outside the package needs the original names).

♻️ Proposed casing alignment
-  LadingContainerCar as LadingRailContainer,
-  LadingCar as LadingRailcar,
+  LadingContainerCar as LadingRailContainer,
+  LadingCar as LadingRailCar,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/index.ts` around lines 87 - 88, Public API aliases have inconsistent
compound-word casing: `LadingContainerCar` -> exported as `LadingRailContainer`
but `LadingCar` -> exported as `LadingRailcar`; align them by renaming the alias
`LadingRailcar` to `LadingRailCar` so both use consistent CamelCase; update the
export statement that maps `LadingCar as LadingRailcar` to `LadingCar as
LadingRailCar` and verify no internal or external code relies on the old alias
name (adjust any imports accordingly).
src/models/invoice.ts (1)

469-534: LadingLocationAddress and LadingFigureAddress are structurally identical.

Both interfaces declare the same 10 fields with the same optionality and the same required set (estadoId, paisId, codigoPostalId). This is a DRY violation — consider collapsing them into a single shared LadingAddress (or keeping both names as aliases) so future schema changes only need to be applied in one place.

♻️ Proposed dedup via a shared base type
 /**
- * Domicilio de una ubicación en carta porte (CartaPorteUbicacionDomicilioRequest)
+ * Domicilio base para carta porte (ubicaciones y figuras).
  */
-export interface LadingLocationAddress {
+export interface LadingAddress {
   /** Calle */
   calle?: string;
   // ...
   /** Código postal. Catálogo SAT c_CodigoPostal */
   codigoPostalId: string;
 }

-/**
- * Domicilio de una figura de transporte en carta porte (CartaPorteTiposFiguraDomicilioRequest)
- */
-export interface LadingFigureAddress {
-  // ...duplicate fields...
-}
+/** Alias semánticos para mantener la intención del contrato */
+export type LadingLocationAddress = LadingAddress;
+export type LadingFigureAddress = LadingAddress;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/models/invoice.ts` around lines 469 - 534, LadingLocationAddress and
LadingFigureAddress are identical duplicates; consolidate them by creating a
single exported interface (e.g., LadingAddress) that contains the shared fields
(calle, numeroExterior, numeroInterior, coloniaId, localidadId, referencia,
municipioId, estadoId, paisId, codigoPostalId) and then replace both
LadingLocationAddress and LadingFigureAddress with type aliases to that
interface (or export the single name and update usages to reference
LadingAddress) so future schema changes are applied in one place; update any
imports/usages of LadingLocationAddress and LadingFigureAddress to use the new
LadingAddress or aliases.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/index.ts`:
- Around line 87-88: Public API aliases have inconsistent compound-word casing:
`LadingContainerCar` -> exported as `LadingRailContainer` but `LadingCar` ->
exported as `LadingRailcar`; align them by renaming the alias `LadingRailcar` to
`LadingRailCar` so both use consistent CamelCase; update the export statement
that maps `LadingCar as LadingRailcar` to `LadingCar as LadingRailCar` and
verify no internal or external code relies on the old alias name (adjust any
imports accordingly).

In `@src/models/invoice.ts`:
- Around line 469-534: LadingLocationAddress and LadingFigureAddress are
identical duplicates; consolidate them by creating a single exported interface
(e.g., LadingAddress) that contains the shared fields (calle, numeroExterior,
numeroInterior, coloniaId, localidadId, referencia, municipioId, estadoId,
paisId, codigoPostalId) and then replace both LadingLocationAddress and
LadingFigureAddress with type aliases to that interface (or export the single
name and update usages to reference LadingAddress) so future schema changes are
applied in one place; update any imports/usages of LadingLocationAddress and
LadingFigureAddress to use the new LadingAddress or aliases.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 015aeca9-1b6c-417a-af4f-2327e87935c2

📥 Commits

Reviewing files that changed from the base of the PR and between 288254e and 2945a3a.

📒 Files selected for processing (2)
  • src/index.ts
  • src/models/invoice.ts

Anidem1995 and others added 2 commits April 19, 2026 19:29
Co-authored-by: Copilot <copilot@github.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/models/invoice.ts (2)

539-578: Tighten tipoUbicacion to a string-literal union.

tipoUbicacion is a closed SAT enum (Origen / Destino). Typing it as a literal union gives consumers autocompletion and catches typos at compile time, which aligns with the strict TS posture in this repo.

♻️ Suggested refactor
-  /** Tipo de ubicación (Origen / Destino) */
-  tipoUbicacion: string;
+  /** Tipo de ubicación (Origen / Destino) */
+  tipoUbicacion: 'Origen' | 'Destino';

As per coding guidelines: "Enable strict TypeScript mode with checks: noImplicitAny, strictNullChecks, noImplicitReturns, noUnusedParameters".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/models/invoice.ts` around lines 539 - 578, The tipoUbicacion field on the
LadingLocation interface should be narrowed from string to the string-literal
union 'Origen' | 'Destino' to provide autocomplete and catch typos; update the
LadingLocation declaration to use tipoUbicacion: 'Origen' | 'Destino' and then
adjust any call sites, parsers, validators, deserializers or tests that
construct LadingLocation objects (or accept raw strings) to either produce one
of those two literals or perform explicit validation/normalization so the code
compiles under strict TypeScript.

651-777: Both materialPeligrosoId and cveMaterialPeligrosoId are correctly present; consider clarifying JSDoc comments to distinguish their roles.

All 19 previously flagged properties are present. Usage across all examples confirms the intended distinction: materialPeligrosoId serves as a flag/indicator (consistently set to 'No' in examples), while cveMaterialPeligrosoId is the catalog clave value. Improve clarity by distinguishing these roles more explicitly in the JSDoc comments—for example, specify that materialPeligrosoId is an inline indicator/flag and cveMaterialPeligrosoId is the corresponding SAT c_MaterialPeligroso catalog code when applicable.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/models/invoice.ts` around lines 651 - 777, Update the JSDoc for the
LadingMerchandise interface to clearly distinguish the two related fields:
change the comment for materialPeligrosoId to state it is an inline
indicator/flag (e.g., "Indica si es material peligroso (flag/inline, e.g.,
'Sí'/'No')") and change the comment for cveMaterialPeligrosoId to state it is
the SAT catalog clave (e.g., "Clave del catálogo SAT c_MaterialPeligroso — usar
cuando materialPeligrosoId indicates a hazardous material"). Ensure these edits
are made on the LadingMerchandise interface fields materialPeligrosoId and
cveMaterialPeligrosoId so their intended roles are explicit.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/models/invoice.ts`:
- Line 107: The public API renamed Complement.lading to Complement.cartaPorte
which breaks existing consumers; add a backwards-compatible deprecation alias or
document the break: either add a deprecated getter/optional property named
lading on the Complement type/class that forwards to cartaPorte (and mark it
with a deprecation comment/ts-expect-deprecation) so existing code compiles, and
update the exported types (e.g., LadingComplement) in index.ts to re-export the
alias, OR add a prominent "Breaking changes" entry in README/CHANGELOG
describing the rename (Complement.lading → Complement.cartaPorte) and include
migration guidance and timeline for removal.

---

Nitpick comments:
In `@src/models/invoice.ts`:
- Around line 539-578: The tipoUbicacion field on the LadingLocation interface
should be narrowed from string to the string-literal union 'Origen' | 'Destino'
to provide autocomplete and catch typos; update the LadingLocation declaration
to use tipoUbicacion: 'Origen' | 'Destino' and then adjust any call sites,
parsers, validators, deserializers or tests that construct LadingLocation
objects (or accept raw strings) to either produce one of those two literals or
perform explicit validation/normalization so the code compiles under strict
TypeScript.
- Around line 651-777: Update the JSDoc for the LadingMerchandise interface to
clearly distinguish the two related fields: change the comment for
materialPeligrosoId to state it is an inline indicator/flag (e.g., "Indica si es
material peligroso (flag/inline, e.g., 'Sí'/'No')") and change the comment for
cveMaterialPeligrosoId to state it is the SAT catalog clave (e.g., "Clave del
catálogo SAT c_MaterialPeligroso — usar cuando materialPeligrosoId indicates a
hazardous material"). Ensure these edits are made on the LadingMerchandise
interface fields materialPeligrosoId and cveMaterialPeligrosoId so their
intended roles are explicit.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 11046e96-cbd0-4c90-be86-89fe38e3dd76

📥 Commits

Reviewing files that changed from the base of the PR and between 2945a3a and 56e6e0f.

📒 Files selected for processing (3)
  • examples/ejemplos-carta-porte-referencias.ts
  • examples/ejemplos-carta-porte-valores.ts
  • src/models/invoice.ts

Comment thread src/models/invoice.ts

/** Complemento de carta porte */
lading?: LadingComplement;
cartaPorte?: LadingComplement;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check whether any other source/tests still reference the old `lading` field on Complement,
# and whether CHANGELOG/README mention this rename.
rg -nP '\bcomplement\s*\.\s*lading\b' --type=ts -C2
rg -nP '\blading\?\s*:\s*LadingComplement\b' --type=ts -C2
fd -i 'changelog|readme' -t f -d 3 --exec rg -nP -H 'cartaPorte|lading' {} \;

Repository: FiscalAPI/fiscalapi-node

Length of output: 50


🏁 Script executed:

#!/bin/bash
# Confirm the actual code at line 107 and surrounding context
echo "=== Line 107 context in src/models/invoice.ts ==="
sed -n '100,115p' src/models/invoice.ts

# Check for CHANGELOG and README files
echo -e "\n=== CHANGELOG/README files ==="
find . -type f \( -iname 'changelog*' -o -iname 'readme*' \) -not -path './node_modules/*' | head -10

# Check index.ts exports for Complement and LadingComplement
echo -e "\n=== Checking index.ts for exports ==="
fd -i 'index.ts' -t f | xargs rg -nP 'Complement|LadingComplement' -A1 -B1 | head -50

Repository: FiscalAPI/fiscalapi-node

Length of output: 1011


🏁 Script executed:

#!/bin/bash
# Check README.md for breaking changes section and migration info
echo "=== README.md content (checking for breaking changes) ==="
cat README.md | head -100

# Also check if there are any comments/history in invoice.ts about the rename
echo -e "\n=== Checking invoice.ts for comments about lading/cartaPorte ==="
rg -nP 'lading|cartaPorte' src/models/invoice.ts -B2 -A2 | head -30

Repository: FiscalAPI/fiscalapi-node

Length of output: 4510


Breaking rename: Complement.ladingComplement.cartaPorte requires migration path or release documentation.

This is a breaking change for SDK consumers already using complement.lading. The public API exports Complement and LadingComplement (index.ts), so any consumer code will encounter compilation errors.

No deprecation alias is present and no breaking changes section exists in README or CHANGELOG. Implement one of the following:

  • Add a deprecated alias (backward compatible) to give consumers a migration window, or
  • Document this breaking change prominently in CHANGELOG and README under a "Breaking changes" section for this release.
Example: Transitional deprecation alias
   /** Complemento de carta porte */
   cartaPorte?: LadingComplement;
+
+  /**
+   * `@deprecated` Use `cartaPorte` instead. Will be removed in a future release.
+   */
+  lading?: LadingComplement;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/models/invoice.ts` at line 107, The public API renamed Complement.lading
to Complement.cartaPorte which breaks existing consumers; add a
backwards-compatible deprecation alias or document the break: either add a
deprecated getter/optional property named lading on the Complement type/class
that forwards to cartaPorte (and mark it with a deprecation
comment/ts-expect-deprecation) so existing code compiles, and update the
exported types (e.g., LadingComplement) in index.ts to re-export the alias, OR
add a prominent "Breaking changes" entry in README/CHANGELOG describing the
rename (Complement.lading → Complement.cartaPorte) and include migration
guidance and timeline for removal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants