Skip to content

Added lading support#5

Open
Anidem1995 wants to merge 1 commit intomainfrom
feat/AddLadingSupport
Open

Added lading support#5
Anidem1995 wants to merge 1 commit 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) data models, enabling users to handle transport and logistics invoice complements.
  • 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

📝 Walkthrough

Walkthrough

This PR introduces comprehensive Pydantic data models for CFDI 4.0 "Carta Porte" (Bill of Lading) functionality through a new module, exposes these models via package-level imports, updates the InvoiceComplement to reference the correct alias, and increments the package version.

Changes

Cohort / File(s) Summary
Bill of Lading Models
fiscalapi/models/bill_of_lading_models.py
New module defining 20 Pydantic BaseModel classes representing Carta Porte transport complement entities, with field aliases mapping snake_case names to camelCase, decimal serialization for numeric fields, and required/optional field configuration.
Package-Level Exports
fiscalapi/__init__.py, fiscalapi/models/__init__.py
Added imports and __all__ exports for all 20 Bill of Lading model classes across both init files to expose them at package and subpackage boundaries.
Invoice Complement Integration
fiscalapi/models/fiscalapi_models.py
Replaced placeholder LadingComplement class with import from new module; updated InvoiceComplement.lading field alias from "lading" to "cartaPorte".
Version Bump
setup.py
Updated version constant from "4.0.360" to "4.0.372".

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A new Carta Porte hops into place,
With models defined at a steady pace,
Remolques and transporte take flight,
Twenty-fold imports—all bundled just right!
From aliases mapped to decimals true,
The Bill of Lading dreams now come through!

🚥 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 pull request title 'Added lading support' directly and clearly describes the main change: adding support for Bill of Lading (Carta Porte) models and their export throughout the package.
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 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

@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

@@ -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).

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