Skip to content

Comments

Agrega ejemplos para nómina y complemento de impuestos locales por re…#1

Open
Anidem1995 wants to merge 4 commits intomainfrom
Agregar-ejemplos-para-nómina-y-complemento-de-impuestos-locales-por-referencias

Hidden character warning

The head ref may contain hidden characters: "Agregar-ejemplos-para-n\u00f3mina-y-complemento-de-impuestos-locales-por-referencias"
Open

Agrega ejemplos para nómina y complemento de impuestos locales por re…#1
Anidem1995 wants to merge 4 commits intomainfrom
Agregar-ejemplos-para-nómina-y-complemento-de-impuestos-locales-por-referencias

Conversation

@Anidem1995
Copy link

@Anidem1995 Anidem1995 commented Feb 11, 2026

…ferencia. Actualiza package.json con nueva versión de SDK

Summary by CodeRabbit

  • New Features
    • Added four endpoints to create payroll and local-taxes invoices: by-values and by-references.
  • API Changes
    • Changed invoice/payment payload structure for payment complements — adjust request body format accordingly.
  • Documentation
    • Added Swagger documentation for the new invoice endpoints.
  • Chores
    • Updated fiscalapi dependency to ^4.0.360.

…ferencia. Actualiza package.json con nueva versión de SDK
@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

📝 Walkthrough

Walkthrough

Updated fiscalapi dependency version and added four new POST invoice endpoints plus controller actions to create payroll and local-taxes invoices (by values and by references); controllers build invoice payloads and call fiscalapi.invoices.create.

Changes

Cohort / File(s) Summary
Dependency Update
package.json
fiscalapi dependency bumped from ^4.0.0 to ^4.0.360.
Invoice Controller
src/controllers/invoiceController.ts
Added four exported controller functions: createPayrollComplementByValues, createLocalTaxesComplementByValues, createPayrollByReferences, createLocalTaxesInvoiceByReference. Each constructs invoice payloads (payroll or local-taxes complements, by values or by references) and invokes fiscalapi.invoices.create with try/catch and structured 200/500 responses.
Invoice Routes
src/routes/invoiceRoutes.ts
Registered four new POST routes with Swagger docs: /api/invoices/create/payroll/by-values, /api/invoices/create/payroll/by-references, /api/invoices/create/local-taxes/by-values, /api/invoices/create/local-taxes/by-reference, mapped to the corresponding controller exports.

Sequence Diagram(s)

sequenceDiagram
  participant Client as Client
  participant Server as Server\n(API Route → Controller)
  participant Fiscal as fiscalapi\n(External API)
  Client->>Server: POST /api/invoices/create/... (payroll/local-taxes payload)
  Server->>Server: Route -> Controller\nController builds invoice payload\n(includes payroll or localTaxes complement)
  Server->>Fiscal: fiscalapi.invoices.create(payload)
  Fiscal-->>Server: 200 OK / error
  Server-->>Client: 200 / 500 response
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I nibbled lines and tuned a string,
Four new routes to make invoices sing.
A version bump, payloads snug and bright,
fiscalapi hums through day and night.
Hop, hop — deploy takes flight! 🎉

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Merge Conflict Detection ⚠️ Warning ⚠️ Unable to check for merge conflicts: Invalid branch name format
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title references payroll and local taxes complement examples by reference, which aligns with the new controller methods and routes added for payroll and local taxes invoicing.
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
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch Agregar-ejemplos-para-nómina-y-complemento-de-impuestos-locales-por-referencias
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch Agregar-ejemplos-para-nómina-y-complemento-de-impuestos-locales-por-referencias
  • Create stacked PR with resolved conflicts
  • Post resolved changes as copyable diffs in a comment

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

Copy link

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

🤖 Fix all issues with AI agents
In `@package.json`:
- Line 41: Confirm that all usages of the old FiscalAPI invoices.create are
migrated to the unified POST /api/v4/invoices endpoint: search for calls to
invoices.create (and any wrapper functions like createInvoice,
InvoiceService.create, or apiClient.invoices.create) and update request URLs to
/api/v4/invoices; for invoice types "payment", "payroll", and "local-taxes"
update their request payloads to the new v4 schema (field names/structure per v4
docs), leaving income invoices and credit notes with only the endpoint URL
change; run and update unit/integration tests that exercise
InvoiceService/createInvoice and apiClient.invoices.create to validate the new
payload shapes and responses before releasing the package.json bump to fiscalapi
^4.0.360.

In `@src/controllers/invoiceController.ts`:
- Around line 1029-1155: The createPayrollByReferences handler builds
payrollInvoice but omits required payroll fields; add issuer.employerData and
recipient.employeeData (including employeeData.curp and
employeeData.satContractTypeId) to the payrollInvoice object before calling
fiscalapi.invoices.create(); update the payrollInvoice.issuer to include
employerData with the required employer identifiers and payroll settings, and
update payrollInvoice.recipient to include employeeData with curp and
satContractTypeId (and any other schema-required employee fields) so FiscalAPI
v4.0.360 validation succeeds.
- Around line 1158-1208: In createLocalTaxesInvoiceByReference update the
complement.localTaxes.taxes entries so taxRate and taxAmount are numeric types
(numbers/decimals) instead of strings; locate the tax objects inside the
localTaxes complement (in the createLocalTaxesInvoiceByReference function) and
change taxRate: "3.00"/"8.00" to taxRate: 3.00/8.00 and taxAmount:
"6.00"/"16.00" to taxAmount: 6.00/16.00 so the FiscalAPI v4.0.360 SDK accepts
the payload.

In `@src/routes/invoiceRoutes.ts`:
- Around line 480-507: The route path for the local-taxes endpoint is
inconsistent with other reference-based endpoints: change the POST path string
'/create/local-taxes/by-reference' to '/create/local-taxes/by-references' in the
router.post call and update the corresponding Swagger block comment above it so
both the documented path and the actual route match; locate the router.post that
registers createLocalTaxesInvoiceByReference and the Swagger comment block for
this endpoint and make the two use '/by-references' to align with
createPayrollByReferences.

@Anidem1995 Anidem1995 changed the title Agerga ejemplos para nómina y complemento de impuestos locales por re… Agrega ejemplos para nómina y complemento de impuestos locales por re… Feb 11, 2026
Copy link
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.

Amigo, los ejemplos existentes de complemento de pago y el readme requieren cambios, Hay discusiones pendientes con Rabbit, ninguna aplica? yo leí al menos una que sí, hiciste dev DevTesting? porque puedo asegurarte de que los ejemplos de complementos de pago no funcionarán después del update de sdk, levanta los ejemplos y verifica que lo que estás haciendo no solo funciona, si no que lo que existe no está roto.

Copy link
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.

Amigo, los ejemplos existentes de complemento de pago y el readme requieren cambios, Hay discusiones pendientes con Rabbit, ninguna aplica? yo leí al menos una que sí, hiciste dev DevTesting? porque puedo asegurarte de que los ejemplos de complementos de pago no funcionarán después del update de sdk, levanta los ejemplos y verifica que lo que estás haciendo no solo funciona, si no que lo que existe no está roto.

Copy link

@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

🤖 Fix all issues with AI agents
Verify each finding against the current code and only fix it if needed.


In `@src/routes/invoiceRoutes.ts`:
- Around line 233-245: The OpenAPI model LocalTax declares taxRate and taxAmount
as number but sample payloads in invoiceController.ts use string values like
"3.00"/"6.00", so standardize them: either change LocalTax.taxRate and
LocalTax.taxAmount types to string in the Swagger schema (LocalTax) to match the
samples, or update the sample payloads in invoiceController.ts (the sample
requests/fixtures around the invoice controller) to use numeric values (3.00,
6.00) and adjust any DTOs/validation that expect strings; update all occurrences
to keep schema, samples, and any validation/DTOs consistent (refer to LocalTax,
taxRate, taxAmount and the sample payloads in invoiceController.ts).

Comment on lines +233 to +245
* LocalTax:
* type: object
* properties:
* taxName:
* type: string
* description: Nombre del impuesto local
* taxRate:
* type: number
* description: Tasa del impuesto local (2 decimales)
* taxAmount:
* type: number
* description: Monto del impuesto local (2 decimales)
* taxFlagCode:
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Align LocalTax.taxRate/taxAmount types with sample payloads.
In src/controllers/invoiceController.ts (lines 1161–1289 and 1421–1471), the sample payloads use string values like "3.00" and "6.00", but the Swagger schema here declares number. This mismatch can mislead SDK users and validation tooling. Consider standardizing either the schema (string) or the sample payloads (numbers).

🔧 Possible doc fix (if strings are intended)
- *         taxRate:
- *           type: number
+ *         taxRate:
+ *           type: string
@@
- *         taxAmount:
- *           type: number
+ *         taxAmount:
+ *           type: string
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
* LocalTax:
* type: object
* properties:
* taxName:
* type: string
* description: Nombre del impuesto local
* taxRate:
* type: number
* description: Tasa del impuesto local (2 decimales)
* taxAmount:
* type: number
* description: Monto del impuesto local (2 decimales)
* taxFlagCode:
* LocalTax:
* type: object
* properties:
* taxName:
* type: string
* description: Nombre del impuesto local
* taxRate:
* type: string
* description: Tasa del impuesto local (2 decimales)
* taxAmount:
* type: string
* description: Monto del impuesto local (2 decimales)
* taxFlagCode:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/routes/invoiceRoutes.ts` around lines 233 - 245, The OpenAPI model
LocalTax declares taxRate and taxAmount as number but sample payloads in
invoiceController.ts use string values like "3.00"/"6.00", so standardize them:
either change LocalTax.taxRate and LocalTax.taxAmount types to string in the
Swagger schema (LocalTax) to match the samples, or update the sample payloads in
invoiceController.ts (the sample requests/fixtures around the invoice
controller) to use numeric values (3.00, 6.00) and adjust any DTOs/validation
that expect strings; update all occurrences to keep schema, samples, and any
validation/DTOs consistent (refer to LocalTax, taxRate, taxAmount and the sample
payloads in invoiceController.ts).

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