30 lines
1.6 KiB
Markdown
30 lines
1.6 KiB
Markdown
# Plan 2B-2: FIEL + Facturapi per Contribuyente — Implementation Plan
|
|
|
|
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task.
|
|
|
|
**Goal:** FIEL y Facturapi se resuelven por contribuyente (tabla tenant BD) en vez de por tenant (BD central). Los servicios existentes NO se modifican (siguen para Horux360 classic); se crean servicios NUEVOS paralelos para el flujo despachos.
|
|
|
|
**Architecture:** Nuevos servicios `contribuyente-fiel.service.ts` y `contribuyente-facturapi.service.ts` que operan sobre tablas `fiel_contribuyente` y `facturapi_orgs` en la BD tenant (via pool.query, no Prisma). Nuevos endpoints bajo `/api/contribuyentes/:id/fiel` y `/api/contribuyentes/:id/facturapi`. El endpoint `emitir()` se adapta para resolver org desde `facturapi_orgs` cuando se pasa `contribuyenteId`.
|
|
|
|
---
|
|
|
|
## Tasks
|
|
|
|
### Task 1: Contribuyente FIEL service
|
|
|
|
Create `apps/api/src/services/contribuyente-fiel.service.ts` — funciones que operan sobre tabla `fiel_contribuyente` en BD tenant.
|
|
|
|
### Task 2: Contribuyente Facturapi service
|
|
|
|
Create `apps/api/src/services/contribuyente-facturapi.service.ts` — funciones que operan sobre tabla `facturapi_orgs` en BD tenant.
|
|
|
|
### Task 3: Controller + routes
|
|
|
|
Create controller + routes para exponer FIEL upload/status y Facturapi org/CSD per contribuyente.
|
|
|
|
### Task 4: Wire emitir() para resolver org por contribuyente
|
|
|
|
Modify `emitir()` en facturacion.controller.ts para que si `contribuyenteId` está presente, resuelva la org Facturapi desde `facturapi_orgs` en vez de `Tenant.facturapiOrgId`.
|
|
|
|
### Task 5: Validation
|