Añadir fixtures de facturas anonimizadas (PDF/JPG/PNG) y casos de pipeline#52
Merged
Conversation
Add four synthetic, anonymized supplier-invoice fixtures modelled on real Canary-Islands invoices (fictitious company names and tax IDs, no real data): - F-2025-004 (PDF): professional services, IRPF 15% retention, VAT-exempt - F-2025-005 (PDF): legal services, 7% IGIC - F-2025-006 (PDF): logistics, mixed 7% IGIC + non-subject 'suplido' line - F-2025-007 (JPG + PNG): feed store, single line, 0% IGIC Each ships a recorded AI-response JSON under fixtures/responses and is wired into InvoicePipelineTest's data provider, so they run through the full normalize/validate/arithmetic/tax-breakdown/supplier-data assertions. Adds JPG and PNG sample formats alongside the existing PDF fixtures.
FacturaScripts Playground Preview
Try this PR in your browser This preview is generated automatically for the |
- The reportlab fixtures used the non-embedded Helvetica base-14 font, so the text was invisible when rasterized/viewed (only rules showed). Embed Bitstream Vera (bundled with reportlab) so the invoice text always renders. Regenerate F-2025-004/005/006 (PDF) and F-2025-007 (JPG+PNG). - Stabilize testResolveMimeType* : use deterministic plain-text content instead of random_bytes(), which finfo could detect as a concrete type (application/x-dosexec) and intermittently fail the extension fallback.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Añade más fixtures de facturas de proveedor para los tests, en varios formatos (PDF, JPG y PNG).
Qué incluye
Cuatro facturas sintéticas y anonimizadas, modeladas a partir de la estructura de facturas reales de Canarias pero con nombres de empresa y CIF/NIF ficticios (no contienen ningún dato real):
F-2025-004F-2025-005F-2025-006F-2025-007Cómo pasan por los tests
Cada fixture incluye su respuesta de IA grabada en
Test/fixtures/responses/*.jsony queda registrada en el data provider deInvoicePipelineTest, por lo que se ejecutan contra todas las comprobaciones del pipeline: normalización, validación, consistencia aritmética (subtotal + IVA − retención = total, suma de líneas = base, desglose de impuestos = cuota), formato de CIF/NIF, fechas y confianzas.Esto amplía la cobertura con casos antes no cubiertos (retención IRPF con exención de IVA, línea de suplido no sujeto, importe muy pequeño) y añade los formatos de imagen JPG y PNG junto a los PDF existentes.
Notas
testResolveMimeType…: usabarandom_bytes(), quefinfopodía detectar como un tipo concreto (p. ej.application/x-dosexec) y hacía fallar el fallback de extensión de forma intermitente; ahora usa contenido de texto determinista.Test/ya está marcado comoexport-ignore, así que estas fixtures no se incluyen en el ZIP de release.Verificado en CI (lint + suite PHPUnit) en PHP 8.1–8.5.