Download the PHP package youniwemi/digital-invoice without Composer
On this page you can find all versions of the php package youniwemi/digital-invoice. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download youniwemi/digital-invoice
More information about youniwemi/digital-invoice
Files in youniwemi/digital-invoice
Package digital-invoice
Short Description Digital Invoice is an easy wrapper around easybill/zugferd-php, josemmo/einvoicing and atgp/factur-x that will allow you generate Factur-x and UBL (Peppol, Cius...) invoices in a very easy way.
License MIT
Informations about the package digital-invoice
Digital Invoice
Digital Invoice offers a unified interface for generating and reading e-invoices across all major formats. It wraps easybill/zugferd-php, josemmo/einvoicing, and atgp/factur-x into a single, consistent API.
Supported Formats
| Format | Profiles | Generate | Read |
|---|---|---|---|
| Factur-X / ZUGFeRD 2.x | MINIMUM, BASIC_WL, BASIC, EN16931, EXTENDED |
✓ | ✓ |
| ZUGFeRD 1.0 | CONFORT, BASIC, EXTENDED |
✓ | ✓ |
| XRechnung | — | ✓ | ✓ |
| UBL | Peppol, NLCIUS, CIUS-RO, CIUS-IT, CIUS-ES-FACE, CIUS-AT-NAT, CIUS-AT-GOV, Malaysia |
✓ | ✓ |
Installation
Requires PHP 8.3+ (easybill/zugferd-php 6).
Upgrading to 0.4
- PHP 8.3 or later is required.
- easybill/zugferd-php 6 replaces the
Youniwemi/zugferd-phpfork: the Factur-X models moved fromEasybill\ZUGFeRD211\ModeltoEasybill\ZUGFeRD2\Model. Only code using$invoice->xmlGenerator->invoicedirectly is affected. - Use
addAllowance()for discounts, negative prices are rejected by EN16931 (BR-27) and the French rules (BR-FR-DEC-03).
Generating an invoice
For UBL:
French e-invoicing (CTC reform)
The French rules (BR-FR, XP Z12-012) require a billing mode, electronic addresses and the legal notes:
In UBL, note subject codes are written as a #PMT#… prefix.
Credit notes
Pass a credit note type code (381, 396, 261…) and reference the credited invoice (BG-3, required by BR-FR-CO-05). Amounts stay positive; UBL output switches to a <CreditNote> document.
When read back, InvoiceData::isCreditNote() and InvoiceData::$precedingInvoices expose them.
Discounts
Add a document level allowance (BG-20) instead of a negative line, prices must stay positive (BR-27, BR-FR-DEC-03). The amount is deducted from the VAT basis of the given rate. Supported by Factur-X (BASIC WL and above) and UBL.
Supporting documents
Attach a supporting document (BG-24), e.g. a delivery note. It is embedded in the XML (base64) and, for PDF output, also attached to the PDF (AFRelationship /Supplement), visible in the attachment pane of Acrobat or Firefox. Supported by Factur-X (EN16931 and EXTENDED) and UBL.
The mime code must be one of AttachmentMimeCode (BR-CL-24): pdf, png, jpeg, csv, xlsx or ods, any other value throws an exception. The id is required, and so are the filename and the mime code when contents are given.
In France, BT-123 must be one of AttachmentDescription (BR-FR-17): BON_LIVRAISON, BON_COMMANDE, DOCUMENT_ANNEXE, RIB, PJA, BORDEREAU_SUIVI, BORDEREAU_SUIVI_VALIDATION, ETAT_ACOMPTE, FACTURE_PAIEMENT_DIRECT, RECAPITULATIF_COTRAITANCE, FEUILLE_DE_STYLE or LISIBLE (readable copy of the invoice, once at most). It is not checked, as it is free text outside France.
Some readers (macOS Preview, Chrome) do not show PDF attachments. To make PDF documents readable everywhere, append their pages after the invoice:
A PDF the free FPDI parser can not read (e.g. PDF 1.5+ with a compressed xref) is silently not appended, the document is still embedded in the XML. Appended pages are copied as is, a document that is not PDF/A may break the PDF/A-3 conformance of the invoice.
Reading an invoice
InvoiceReader auto-detects the format (CII/FacturX, ZUGFeRD 1.0, UBL) and returns a normalised InvoiceData object.
InvoiceData structure
TaxBreakdownData
PartyData
Rendering an invoice to HTML
InvoiceRenderer turns any parsed InvoiceData into a self-contained HTML fragment with inlined CSS. It supports custom templates, custom CSS, and three UI languages out of the box.
The default template (src/templates/invoice.html.php) and stylesheet (src/templates/invoice.css) can be replaced entirely. The template receives these variables:
| Variable | Type | Description |
|---|---|---|
$invoice |
InvoiceData |
The parsed invoice |
$cur |
string |
Currency code |
$labels |
array |
Translated UI strings |
$esc |
Closure |
fn(?string): string — HTML-safe output |
$fmt |
Closure |
fn(?float, string): string — formatted amount |
$date |
Closure |
fn(?\DateTime): string — formatted date |
$schemeLabel |
Closure |
fn(string): string — human label for ISO 6523 / tax scheme |
$formatLabel |
Closure |
fn(string): string — human label for invoice format/profile |
Interactive viewer
viewer.php provides a browser-based upload-and-preview page: upload any invoice file on the left, see the rendered HTML on the right, supporting documents can be downloaded. No files are stored server-side.
Key Features
- Read & Generate — round-trip support for all formats
- Tax breakdown — per-rate base amount, VAT amount, and category code from any parser
- HTML rendering — self-contained fragment with inlined CSS, i18n (EN/FR/DE), format badge, SIRET/VAT labels
- Identifier support — SIRET, SIREN, DUNS, LEI, VAT, and 60+ ISO 6523 codes
- Multi-currency — including MYR for Malaysian e-invoices
- Secure by default — DOCTYPE guard, LIBXML_NONET, upload MIME validation, XSS-safe renderer
Testing
Generated Factur-X and UBL invoices are also validated with the official FNFE artefacts: Factur-X / EN16931 profile rules, and French BR-FR rules for the French CTC profiles (Factur-X BASIC-WL, EN16931, EXTENDED and test/FrenchRulesTest.php). The rules are XSLT 2.0 and run with Saxon-HE, so Java is required. Download them once, these checks are skipped otherwise:
Development Status
Active development — API may change between minor versions.
Collaboration and contributions are welcome. Open an issue or PR for specific use cases or format requests.
Contributors
- @yassiNebeL — UBL format support via josemmo/einvoicing
Credits
- easybill/zugferd-php — Factur-X, XRechnung, ZUGFeRD generation and reading
- josemmo/einvoicing — UBL invoice generation and reading
- atgp/factur-x — PDF embedding/extraction for Factur-X
- Tiime-Software/EN-16931 — Structured data types for e-invoicing
All versions of digital-invoice with dependencies
easybill/zugferd-php Version ^6.0
atgp/factur-x Version ^1.0
milo/schematron Version dev-master
josemmo/einvoicing Version dev-master
jms/serializer Version ^3.30