Skip to content

Added lading support#5

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

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

Conversation

@Anidem1995
Copy link
Copy Markdown

@Anidem1995 Anidem1995 commented Mar 26, 2026

Summary by CodeRabbit

  • New Features

    • Added support for Bill of Lading (Carta Porte) models to handle transport/logistics invoice complements.
    • Invoice complement field now uses the "cartaPorte" key for Carta Porte data.
  • Chores

    • Updated package version to 4.0.372.

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

coderabbitai Bot commented Mar 27, 2026

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

💤 Files selected but had no reviewable changes (2)
  • examples/ejemplos-factura-carta-porte-referencias.py
  • examples/ejemplos-factura-carta-porte-valores.py
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bbea2ff2-3064-4e4d-a1b5-d58c3d8e6c05

📥 Commits

Reviewing files that changed from the base of the PR and between 685798b and 7ed8003.

📒 Files selected for processing (2)
  • examples/ejemplos-factura-carta-porte-referencias.py
  • examples/ejemplos-factura-carta-porte-valores.py

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a new Pydantic module modelling CFDI 4.0 Carta Porte (Bill of Lading) entities, re-exports those models at package and models package levels, updates InvoiceComplement to reference the new LadingComplement with alias "cartaPorte", and bumps the package version.

Changes

Cohort / File(s) Summary
Bill of Lading Models
fiscalapi/models/bill_of_lading_models.py
Added new module with ~20 Pydantic models (UbicacionDomicilio, Ubicacion, RegimenAduanero, DocumentoAduanero, GuiaIdentificacion, CantidadTransporta, DetalleMercancia, Mercancia, Remolque, Autotransporte, RemolqueCCP, ContenedorMaritimo, TransporteMaritimo, TransporteAereo, DerechoDePaso, CarroContenedor, Carro, TransporteFerroviario, ParteTransporte, TipoFigura, TipoFiguraDomicilio, LadingComplement). Fields use aliases, ConfigDict(populate_by_name=True), and decimal/date json encoders.
Package-Level Exports
fiscalapi/__init__.py, fiscalapi/models/__init__.py
Imported and added the Bill of Lading model names to __all__ to publicly expose them. Note: GuiaIdentificacion is imported in at least one init but was not added to __all__ in the diff.
Invoice Complement Integration
fiscalapi/models/fiscalapi_models.py
Removed local placeholder LadingComplement; imported LadingComplement from fiscalapi.models.bill_of_lading_models. Changed InvoiceComplement.lading alias from "lading" to "cartaPorte" (type remains Optional[LadingComplement]).
Version Bump
setup.py
Updated package version from "4.0.360" to "4.0.372".

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I nibble on aliases, fields in a row,

Ubicaciones hop where cartaporte go,
Remolques, mercancías, models align,
LadingComplement stitched, version bumped fine,
A rabbit’s small cheer for schema designs ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'Added lading support' directly and clearly describes the main change—adding support for Bill of Lading (Carta Porte) models and their public API exposure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 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

@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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
fiscalapi/__init__.py (1)

92-92: ⚠️ Potential issue | 🟡 Minor

Duplicate import: LadingComplement is already imported from bill_of_lading_models at line 45.

🧹 Proposed fix: Remove duplicate import
     PayrollDeduction,
     PayrollDisability,
     PayrollComplement,
-    LadingComplement,
     InvoiceComplement,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@fiscalapi/__init__.py` at line 92, Remove the duplicate import of
LadingComplement from bill_of_lading_models: locate the second occurrence of
"LadingComplement" in the import list (the one referenced in the diff) and
delete it so only the original import (already present around the earlier import
block) remains; ensure no other symbols or commas are accidentally removed when
editing the import list.
fiscalapi/models/__init__.py (1)

77-77: ⚠️ Potential issue | 🟡 Minor

Duplicate import: LadingComplement is already imported from bill_of_lading_models at line 32.

Since fiscalapi_models imports LadingComplement from bill_of_lading_models and re-exports it, this import is redundant.

🧹 Proposed fix: Remove duplicate import
     PayrollDeduction,
     PayrollDisability,
     PayrollComplement,
-    LadingComplement,
     InvoiceComplement,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@fiscalapi/models/__init__.py` at line 77, Remove the duplicate import of
LadingComplement (already imported from bill_of_lading_models earlier) by
deleting the redundant "LadingComplement" entry in the import/export list so
that LadingComplement is only imported/re-exported once; ensure the remaining
import from bill_of_lading_models (the original LadingComplement reference) is
kept and run tests/type checks to verify no other duplicate entries remain.
🧹 Nitpick comments (1)
fiscalapi/models/fiscalapi_models.py (1)

531-531: Consider consistency: LadingComplement extends BaseModel while sibling complements extend BaseDto.

All complement types in InvoiceComplement (LocalTaxesComplement, PaymentComplement, PayrollComplement) inherit from BaseDto, which provides id, created_at, and updated_at fields. LadingComplement extends BaseModel directly, creating a structural inconsistency.

If the Carta Porte API doesn't return those base fields, this is intentional and acceptable. Otherwise, align LadingComplement to extend BaseDto for consistency.

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

In `@fiscalapi/models/fiscalapi_models.py` at line 531, The LadingComplement type
currently extends BaseModel while its sibling complements used in
InvoiceComplement (e.g., LocalTaxesComplement, PaymentComplement,
PayrollComplement) extend BaseDto; update LadingComplement to inherit from
BaseDto instead of BaseModel so it includes the common id/created_at/updated_at
fields and matches the structure of other complements (change the class
signature for LadingComplement to extend BaseDto and adjust any imports/refs
accordingly), unless the Carta Porte API definitively does not return those base
fields — in that case add a clarifying comment explaining the intentional
omission.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@fiscalapi/__init__.py`:
- Line 196: The __all__ list in fiscalapi.__init__ contains a duplicate export
"LadingComplement"; remove the redundant "LadingComplement" entry so each public
symbol appears only once—update the __all__ definition where "LadingComplement"
is listed (ensure the remaining single occurrence stays) to eliminate the
duplicate export.

In `@fiscalapi/models/__init__.py`:
- Line 136: The __all__ list in fiscalapi.models contains a duplicated export
name "LadingComplement"; locate the __all__ definition in models/__init__.py and
remove the redundant "LadingComplement" entry so each exported symbol appears
only once (keep one "LadingComplement" and ensure the list remains syntactically
valid).

---

Outside diff comments:
In `@fiscalapi/__init__.py`:
- Line 92: Remove the duplicate import of LadingComplement from
bill_of_lading_models: locate the second occurrence of "LadingComplement" in the
import list (the one referenced in the diff) and delete it so only the original
import (already present around the earlier import block) remains; ensure no
other symbols or commas are accidentally removed when editing the import list.

In `@fiscalapi/models/__init__.py`:
- Line 77: Remove the duplicate import of LadingComplement (already imported
from bill_of_lading_models earlier) by deleting the redundant "LadingComplement"
entry in the import/export list so that LadingComplement is only
imported/re-exported once; ensure the remaining import from
bill_of_lading_models (the original LadingComplement reference) is kept and run
tests/type checks to verify no other duplicate entries remain.

---

Nitpick comments:
In `@fiscalapi/models/fiscalapi_models.py`:
- Line 531: The LadingComplement type currently extends BaseModel while its
sibling complements used in InvoiceComplement (e.g., LocalTaxesComplement,
PaymentComplement, PayrollComplement) extend BaseDto; update LadingComplement to
inherit from BaseDto instead of BaseModel so it includes the common
id/created_at/updated_at fields and matches the structure of other complements
(change the class signature for LadingComplement to extend BaseDto and adjust
any imports/refs accordingly), unless the Carta Porte API definitively does not
return those base fields — in that case add a clarifying comment explaining the
intentional omission.
🪄 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: 59d998d3-3e3a-4e77-bbd7-be5e3fec2675

📥 Commits

Reviewing files that changed from the base of the PR and between e6c53c5 and 376ff23.

📒 Files selected for processing (7)
  • examples/ejemplos-factura-carta-porte-referencias.py
  • examples/ejemplos-factura-carta-porte-valores.py
  • fiscalapi/__init__.py
  • fiscalapi/models/__init__.py
  • fiscalapi/models/bill_of_lading_models.py
  • fiscalapi/models/fiscalapi_models.py
  • setup.py

Comment thread fiscalapi/__init__.py
@@ -171,6 +195,27 @@
"PayrollComplement",
"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 | 🟡 Minor

Duplicate entry: "LadingComplement" appears twice in __all__ (lines 196 and 218).

🧹 Proposed fix: Remove duplicate from line 218
     "TipoFigura",
-    "LadingComplement",
     # Invoice models

Also applies to: 218-218

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

In `@fiscalapi/__init__.py` at line 196, The __all__ list in fiscalapi.__init__
contains a duplicate export "LadingComplement"; remove the redundant
"LadingComplement" entry so each public symbol appears only once—update the
__all__ definition where "LadingComplement" is listed (ensure the remaining
single occurrence stays) to eliminate the duplicate export.

"TransporteFerroviario",
"ParteTransporte",
"TipoFigura",
"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 | 🟡 Minor

Duplicate entry: "LadingComplement" appears twice in __all__ (lines 136 and 184).

Remove one of the duplicate entries.

🧹 Proposed fix: Remove duplicate from line 184
     "PayrollComplement",
-    "LadingComplement",
     "InvoiceComplement",

Also applies to: 184-184

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

In `@fiscalapi/models/__init__.py` at line 136, The __all__ list in
fiscalapi.models contains a duplicated export name "LadingComplement"; locate
the __all__ definition in models/__init__.py and remove the redundant
"LadingComplement" entry so each exported symbol appears only once (keep one
"LadingComplement" and ensure the list remains syntactically valid).

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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@fiscalapi/models/__init__.py`:
- Line 18: The __all__ export list is missing GuiaIdentificacion, causing
wildcard imports to omit this new model; update the module-level __all__ list(s)
to include "GuiaIdentificacion" (add the exact string to the existing tuple/list
alongside the other model names) so that GuiaIdentificacion is exported when
using from fiscalapi.models import *; ensure you add it in every __all__
occurrence where the other Carta Porte models are listed (the same block that
contains the other model names).
🪄 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: 33534b50-a2db-49f9-8dd4-42d518f54cdd

📥 Commits

Reviewing files that changed from the base of the PR and between 376ff23 and 685798b.

📒 Files selected for processing (4)
  • fiscalapi/__init__.py
  • fiscalapi/models/__init__.py
  • fiscalapi/models/bill_of_lading_models.py
  • fiscalapi/models/fiscalapi_models.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • fiscalapi/models/fiscalapi_models.py
  • fiscalapi/init.py
  • fiscalapi/models/bill_of_lading_models.py

RegimenAduanero,
Ubicacion,
DocumentoAduanero,
GuiaIdentificacion,
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 | 🟡 Minor

Add GuiaIdentificacion to __all__.

Line 18 imports GuiaIdentificacion, and fiscalapi/__init__.py also exposes it, but fiscalapi.models.__all__ omits it. This makes wildcard exports incomplete for the new Carta Porte model set.

Proposed fix
     "Ubicacion",
     "DocumentoAduanero",
+    "GuiaIdentificacion",
     "CantidadTransporta",

Also applies to: 118-139

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

In `@fiscalapi/models/__init__.py` at line 18, The __all__ export list is missing
GuiaIdentificacion, causing wildcard imports to omit this new model; update the
module-level __all__ list(s) to include "GuiaIdentificacion" (add the exact
string to the existing tuple/list alongside the other model names) so that
GuiaIdentificacion is exported when using from fiscalapi.models import *; ensure
you add it in every __all__ occurrence where the other Carta Porte models are
listed (the same block that contains the other model names).

Anidem1995 and others added 2 commits April 20, 2026 00:39
Co-authored-by: Copilot <copilot@github.com>
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.

1 participant