Skip to content

feat(billing): PDF generation EN16931 + Romanian law compliance #153

@mostlyvirtual

Description

@mostlyvirtual

Summary

The PDF generation for invoices and proformas (via ReportLab in pdf_generators.py) needs EN16931 and Romanian legal compliance upgrades. Currently it generates basic coordinate-based PDFs without embedded XML, full Romanian fields, or structured tax breakdowns.

Current State

The PDF generator (RomanianDocumentPDFGenerator in services/platform/apps/billing/pdf_generators.py) uses ReportLab with manual coordinate-based text placement. It includes basic company info, client info, items table, and totals.

Missing for EN16931 Compliance

  • PDF/A-3 format with embedded UBL XML — EN16931 requires the XML invoice to be embedded in the PDF for e-invoicing interoperability
  • Invoice series concept (serie + numar) — Romanian practice uses series prefix + sequential number, current system only has single "number" field
  • Seller registration number (J number / Nr. Reg. Com.) — required for Romanian B2B invoices
  • Seller bank details (IBAN, bank name) — commonly required on Romanian invoices
  • VAT breakdown per rate — show subtotals grouped by VAT rate (21%, 9%, 0%) when multiple rates exist
  • Amount in words (Romanian) — "una mie doua sute lei" — common practice on Romanian invoices
  • Customer full address — currently partial display
  • Customer tax ID (CUI/CIF) — not shown on PDF
  • Customer registration number — not shown on PDF
  • EN16931 line-level fields — period_start/end, domain_name, seller_item_id should appear on PDF line items
  • Payment terms — structured display beyond prose text
  • Discount/allowance — line-level and document-level discounts not shown

Missing for Romanian Law

  • Fiscal invoice disclaimer — partial, needs review for exact legal wording
  • Reverse charge notation — for intra-EU B2B transactions, "taxare inversa" must appear
  • Exchange rate — if invoice currency differs from RON, exchange rate must be shown per ANAF rules
  • Delegate info — for physical transport/delivery invoices (may not apply to hosting)

Technical Notes

  • Current implementation: services/platform/apps/billing/pdf_generators.py (ReportLab)
  • PDF views: services/platform/apps/billing/views.py (invoice_pdf ~line 1220, proforma_pdf ~line 1126)
  • Consider migrating to WeasyPrint or xhtml2pdf for HTML-based PDF templates (easier to maintain than coordinate-based ReportLab)
  • For PDF/A-3 with embedded XML, consider using pikepdf or pdfrw to attach the UBL XML after generation
  • EN16931 line-level fields (domain_name, seller_item_id, period) already exist on the models — just need to be rendered in PDF

Related

  • EN16931 field additions implemented in the codebase (domain_name, seller_item_id, period_start/end on InvoiceLine/ProformaLine)
  • XML builder (efactura/xml_builder.py) already generates compliant UBL XML — needs to be embedded in PDF

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions