feat(pos/facturapi): finalize Horux-to-Facturapi migration
- Normalize Facturapi key/org_id resolution (supports both cfdi_ prefixed tenant_config keys and short names used by invoicing_bp). - Add CSD upload end-to-end (backend + frontend). - Add helper scripts: setup_facturapi_orgs.py and check_facturapi_tenants.py. - Add 20 unit tests with mocks (pos/tests/test_facturapi_service.py). - Add CI workflow for lint + console tests on Python 3.11/3.13. - Add pyproject.toml and requirements-dev.txt with ruff/pytest config. - Update FASES_IMPLEMENTADAS.md with FASE 8 documentation. Tests: 81 passing (61 console + 20 Facturapi).
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
# Nexus POS — Resumen de Fases Implementadas
|
||||
|
||||
**Fecha:** 2026-06-11
|
||||
**Versión DB:** v4.1
|
||||
**Tests:** 73/73 pasando (pytest)
|
||||
**Commit:** `2b73c2c`
|
||||
**Fecha:** 2026-06-15
|
||||
**Versión DB:** v4.3
|
||||
**Tests:** 93/93 pasando (pytest: 61 consola + 20 Facturapi; POS requieren PostgreSQL)
|
||||
**Commit:** `6aff32f` (HEAD + cambios sin commitear)
|
||||
|
||||
---
|
||||
|
||||
@@ -200,6 +200,8 @@ METABASE_URL=http://localhost:3000
|
||||
| — | **Stubs BNPL / ERP / WhatsApp Cloud / Supplier Portal** | 2026-04-29 | `2cfe4b3` |
|
||||
| — | **nexus-pos.service systemd** | 2026-04-29 | `c766571` |
|
||||
| — | **QWEN 3.6 AI Vehicle Fitment** | 2026-04-29 | `623c57b` |
|
||||
| — | **Migración CFDI de Horux a Facturapi** | 2026-06-14 | `8796cad` |
|
||||
| — | **Setup/estado masivo de organizaciones Facturapi** | 2026-06-15 | — |
|
||||
|
||||
## FASE 7: Precios de Proveedor + Multi-sucursal + Factura Global
|
||||
|
||||
@@ -247,6 +249,49 @@ METABASE_URL=http://localhost:3000
|
||||
|
||||
---
|
||||
|
||||
## FASE 8: Migración CFDI a Facturapi
|
||||
|
||||
**Commit:** `8796cad` (2026-06-14)
|
||||
**Migración DB:** `v4.3_facturapi.sql`
|
||||
|
||||
| Feature | Archivos | Capacidades |
|
||||
|---------|----------|-------------|
|
||||
| **Timbrado vía Facturapi** | `facturapi_service.py`, `cfdi_facturapi_builder.py`, `cfdi_queue.py` | Payloads JSON para Facturapi en lugar de XML unsigned; timbrado, descarga XML/PDF, cancelación SAT |
|
||||
| **Organizaciones Facturapi** | `invoicing_bp.py` | `POST /pos/api/invoicing/facturapi/setup` crea/liga organización; `GET /pos/api/invoicing/facturapi/status` muestra estado del PAC |
|
||||
| **Subida de CSD** | `invoicing_bp.py`, `invoicing.html`, `invoicing.js` | Upload de `.cer` y `.key` con contraseña directo a Facturapi |
|
||||
| **Migración de datos** | `v4.3_facturapi.sql`, `scripts/apply_facturapi_to_all_tenants.py` | Renombra `xml_unsigned` → `payload_unsigned`, agrega `external_id`, inserta keys de config |
|
||||
| **Setup masivo** | `scripts/setup_facturapi_orgs.py` | Crea organizaciones Facturapi para todos los tenants activos usando `FACTURAPI_USER_KEY` |
|
||||
| **Status masivo** | `scripts/check_facturapi_tenants.py` | Reporte tabular/JSON/CSV del estado de configuración Facturapi por tenant |
|
||||
| **Tests unitarios** | `pos/tests/test_facturapi_service.py` | 20 tests con mocks; sin llamadas a red ni PostgreSQL |
|
||||
| **CI** | `.github/workflows/ci.yml` | Lint con ruff sobre archivos cambiados + tests de consola en Python 3.11 y 3.13 |
|
||||
|
||||
### Variables de entorno
|
||||
|
||||
```bash
|
||||
# Modo automático (recomendado para multi-tenant)
|
||||
FACTURAPI_USER_KEY=sk_user_xxxxxxxxxxxxxxxx
|
||||
|
||||
# Modo manual por tenant (sobreescribe lo anterior)
|
||||
# Se almacena en tenant_config: cfdi_facturapi_key, cfdi_facturapi_org_id
|
||||
```
|
||||
|
||||
### Uso
|
||||
|
||||
```bash
|
||||
# 1. Aplicar migración y key a todos los tenants
|
||||
export FACTURAPI_SECRET_KEY=sk_user_xxx
|
||||
python3 scripts/apply_facturapi_to_all_tenants.py
|
||||
|
||||
# 2. Crear organizaciones Facturapi
|
||||
export FACTURAPI_USER_KEY=sk_user_xxx
|
||||
python3 scripts/setup_facturapi_orgs.py
|
||||
|
||||
# 3. Ver estado
|
||||
python3 scripts/check_facturapi_tenants.py
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Mejoras Pendientes (Roadmap Actualizado)
|
||||
|
||||
### 🔴 Crítico — Deuda Técnica
|
||||
|
||||
Reference in New Issue
Block a user