Skip to content

P0 — Modo dual de facturación (estándar / Verifactu demo) - #1

Merged
R0b3r7DEV merged 2 commits into
masterfrom
feat/p0-facturacion-dual
Jul 11, 2026
Merged

P0 — Modo dual de facturación (estándar / Verifactu demo)#1
R0b3r7DEV merged 2 commits into
masterfrom
feat/p0-facturacion-dual

Conversation

@R0b3r7DEV

Copy link
Copy Markdown
Owner

Primer PR del PLAN-v2 (aprobado). Implementa el P0: modo dual de facturación para que el piloto emita facturas reales por defecto.

Qué resuelve

Hasta ahora toda factura salía con el QR del host de pruebas de la AEAT y la leyenda «Verifactu», porque InvoiceService escribe siempre un registro y el PDF imprimía el QR cuando existía. Una factura real del piloto para su cliente saldría con un QR de preproducción.

Cambios

  • User.billingMode (standard por defecto / verifactu demo) + perfil fiscal del emisor (businessName, fiscalAddress) → factura ordinaria RD 1619/2012 completa. Migración con DEFAULT 'standard' (rellena filas existentes).
  • InvoicePdf: QR + leyenda solo en modo demo. /qr y /xml → 403 en modo estándar.
  • La cadena de hash vive en ambos modos. VerifactuHasher::fingerprint() no incluye el modo → cambiar de modo nunca rompe GET /api/invoices/verify sobre facturas preexistentes (test de regresión).
  • AccountController: GET/PUT /api/account/settings.
  • UI ES no técnica: selector de modo, formulario de emisor, aviso DEMO; el PDF siempre descargable.

Normativa (verificada contra el BOE)

Verifactu es opcional en 2026; autónomos obligados desde el 1-jul-2027 (RD-ley 15/2025). Factura ordinaria válida hoy (RD 1619/2012). Ver ADR 0004.

Verificación

  • Backend: 85 tests, 379 aserciones (verde). Incluye modo estándar sin artefactos, cadena intacta tras cambio de modo, /qr·/xml 403, gating del PDF.
  • Migración aplicada + doctrine:schema:validate en sync.
  • Frontend: build + 20 tests + lint limpio.

Docs

ADR 0004, guía 38, DEVLOG 048.

🤖 Generated with Claude Code

Plan incremental para el vertical de electricista + facturación de uso real:
P0 modo dual de facturación, P1 partes de trabajo, P2 mediciones en el CIE,
P3 PWA offline, P4 tarifas de material, P5 (solo diseño) verticales VE/FV.
Incluye avisos de la revisión del código (QR de pruebas en toda factura, falta
perfil fiscal del emisor), tabla de PRs, complejidad y deuda técnica anticipada.

Incremental roadmap for the electrician vertical + real-use invoicing: P0 dual
billing mode, P1 work orders, P2 CIE measurements, P3 offline PWA, P4 material
tariffs, P5 (design only) EV/PV verticals.
ES
--
Hasta ahora TODA factura salia con el QR del host de PRUEBAS de la AEAT y la
leyenda «Verifactu», porque InvoiceService escribe siempre un registro y el PDF
imprimia el QR cuando existia. Una factura real del piloto para su cliente
saldria con un QR de preproduccion. El modo dual lo arregla.

- User.billingMode por usuario ('standard' por defecto / 'verifactu' demo) +
  perfil fiscal del emisor (businessName, fiscalAddress; el NIF ya existia) para
  que una factura ordinaria RD 1619/2012 este completa. La migracion rellena las
  filas existentes a 'standard' (columna con DEFAULT, nunca NOT NULL sin default).
- InvoicePdf::build(..., bool $showVerifactu): el QR + leyenda solo en modo demo;
  el PDF estandar es una factura ordinaria con el perfil del emisor. Los
  endpoints /qr y /xml devuelven 403 en modo estandar.
- La cadena de hash vive en AMBOS modos. VerifactuHasher::fingerprint() NO
  incluye el modo, asi que cambiar de modo nunca reescribe una huella y
  GET /api/invoices/verify sigue en verde sobre facturas preexistentes. Hay un
  test de regresion que lo comprueba.
- AccountController: GET/PUT /api/account/settings (modo + perfil emisor).
- UI en espanol y no tecnica: selector de modo en Cuenta -> Facturacion; la
  pestana de facturas oculta QR/XML/cadena en estandar y muestra un aviso DEMO
  en Verifactu; el PDF siempre se puede descargar.
- Fecha de obligacion verificada contra el BOE: autonomos desde el 1-jul-2027
  (RD-ley 15/2025); opcional en 2026.

Tests: 85 (379 aserciones). Docs: ADR 0004, guia 38, DEVLOG 048.

EN
--
Until now EVERY invoice shipped with the AEAT TEST-host QR and a "Verifactu"
legend, because InvoiceService always writes a record and the PDF printed the QR
when one existed. A real invoice for the pilot's real client would carry a
pre-production QR. The dual mode fixes it.

- Per-user User.billingMode ('standard' default / 'verifactu' demo) + issuer
  fiscal profile (businessName, fiscalAddress) so a standard RD 1619/2012 invoice
  is complete. Migration backfills existing rows to 'standard'.
- InvoicePdf::build(..., bool $showVerifactu): QR + legend only in demo mode;
  /qr and /xml return 403 in standard mode.
- The hash chain runs in BOTH modes; the fingerprint does not include the mode,
  so switching mode never breaks GET /api/invoices/verify over pre-existing
  invoices (regression test asserts it).
- Account settings endpoints; Spanish non-technical UI; DEMO banner in Verifactu.
- Obligation date verified against the BOE: autonomos from 2027-07-01.

Tests: 85 (379 assertions). Docs: ADR 0004, guide 38, DEVLOG 048.
@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cuentia Ready Ready Preview, Comment Jul 11, 2026 10:11am

@R0b3r7DEV
R0b3r7DEV merged commit dee8011 into master Jul 11, 2026
5 checks passed
@R0b3r7DEV
R0b3r7DEV deleted the feat/p0-facturacion-dual branch July 11, 2026 10:15
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