Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Keep tests (including the large generator and validator fixtures) and GitHub
# workflows out of the Packagist/dist archive.
/tests/** export-ignore
/.github/** export-ignore
/phpunit.xml.dist export-ignore
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
vendor/
composer.lock
.phpunit.cache/
/build/
/tmp/
35 changes: 25 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
# Changelog

## Unreleased

- CLI: `vendor/bin/wsystem-einvoice` supports `create`, `--version`, `--help`, `--format`, `--json`, and clear input-error messages (no stack traces). `validate`, `parse` and `rules:update` are wired and will run when the validator module is present.
- Generator: `EInvoice`, `Builder` and `Generator::create()` auto-discover `Validator\Validator` when that class is autoloadable, so a generated PDF is only built when the XML is valid.
- PDF: credit notes show the title, the preceding invoice and no due date; document and line allowances/charges appear on the visual invoice; a default charge reason is no longer printed twice.
- Packagist description and README state that the default install is a core-subset pre-check; official EN 16931 / XRechnung rules need SaxonC or the W System validator/API.
- Generator: UBL 2.1 (EN 16931, XRechnung 3.0, Peppol BIS 3 structure), UN/CEFACT CII D16B (EN 16931, XRechnung 3.0), byte-identical to the W System API (439 parity fixtures + 4,700 fuzzed invoices).
- Generator: ZUGFeRD 2.3 / Factur-X 1.07 (EN 16931 and XRECHNUNG profiles) as PDF/A-3b, built on setasign/fpdf (MIT) with embedded fonts, XMP and sRGB output intent. Visual text uses Windows-1252; other characters are simplified in the visual PDF only, with a note in the result.
- CI: every generated fixture checked with the KoSIT validator, veraPDF and Mustang.
- Package skeleton: namespaces `Generator`, `Validator`, `Model`, `Pdf`; KoSIT XRechnung 3.0.2 rules (2026-08-31) bundled unmodified.
## 0.9.0-beta.1

First public beta of `wsystem/einvoice`.

### Validator

- Offline `validate()` for UBL, CII and ZUGFeRD / Factur-X / XRechnung PDF/A-3: XML Schema plus EN 16931 and XRechnung 3.0.2 business rules.
- Default engine is `php-core` (`conformance: "pre-check"`, `checked.EN16931: "core-subset"`): a pure-PHP pre-check over the bundled official rule files, not the official engine.
- Optional SaxonC-HE extension (`ext-saxonc`) is auto-detected and reported as `engine: "saxonc"`, `conformance: "official"`.
- Optional `HttpValidator` (`engine: "remote"`) sends the file to the W System validator or API. Opt-in only; the invoice leaves the machine.
- `Parser::parse()` for UBL, CII and hybrid PDFs. `wsystem-einvoice rules:update` checks the published manifest and verifies SHA-256 before unpacking a newer official pack.

### Generator

- UBL 2.1 (EN 16931, XRechnung 3.0, Peppol BIS 3 structure) and UN/CEFACT CII D16B, byte-identical to the W System API (439 parity fixtures plus fuzzed invoices).
- ZUGFeRD 2.3 / Factur-X 1.07 (EN 16931 and XRECHNUNG profiles) as PDF/A-3b, built on setasign/fpdf (MIT). Credit notes and allowances/charges are in the XML and on the visual invoice.
- `EInvoice`, `Builder` and `Generator::create()` auto-use the validator when present; a PDF is only built when the XML is valid. Results include `engine` and `conformance`.

### CLI and packaging

- `vendor/bin/wsystem-einvoice` supports `create`, `validate`, `parse`, `rules:update`, `--version`, `--help`, `--format` and `--json`. Validate output uses the same engine and conformance labels as the PHP API.
- Composer `suggest` names `ext-saxonc`. `composer.lock` is committed and resolved for PHP 8.1 (PHPUnit 10.5) so the 8.1–8.4 CI matrix can install it. `tests/` (and the large fixtures), `.github/` and `phpunit.xml.dist` are `export-ignore`.
- README and the Packagist description state that the default install is a php-core pre-check; official EN 16931 / XRechnung rules need SaxonC or the W System validator/API. Peppol BIS 3 rules are not included.

CI checks generated files with the official KoSIT validator, veraPDF (PDF/A-3b) and Mustang.
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,35 @@ file_put_contents('invoice.xml', $r['xml']);

For `zugferd`, `factur-x` and `zugferd-xrechnung`, `$r['pdf']` holds a PDF/A-3b file with the CII XML embedded (`factur-x.xml` / `xrechnung.xml`). Credit notes (`type_code` `381`, plus a preceding invoice) and allowances or charges on the lines or the document are included in both the XML and the visual PDF.

`$r['engine']` is `php-core` (default), `saxonc`, or `remote`. `$r['conformance']` is `pre-check` or `official`.

## Command line

```bash
vendor/bin/wsystem-einvoice --version
vendor/bin/wsystem-einvoice create examples/invoice.json invoice.xml
vendor/bin/wsystem-einvoice create --format zugferd examples/invoice.json invoice.pdf
vendor/bin/wsystem-einvoice validate invoice.xml
vendor/bin/wsystem-einvoice parse invoice.xml
```

On the default install, `validate` prints a line like:

```text
valid [php-core] EN 16931 + XRechnung 3.0.2: pre-check by the W System pure-PHP engine over the bundled KoSIT/CEN rule files (...), not the official engine
```

`validate` (and `parse`) are provided by the validator module in this package. They are not in the current pre-release build; `create` works now. Once the module is merged, `validate` runs XML Schema and a pure-PHP pre-check of the core rules by default (see below).
With the SaxonC-HE extension loaded, that becomes `valid [saxonc] … official KoSIT/CEN schematron …`. `--json` prints the same fields as the PHP API (`engine`, `conformance`, `checked`, `errors`).

## Which rules run where

| Mode | XML Schema | EN 16931 rules | XRechnung 3.0.2 rules |
|---|---|---|---|
| Default (pure PHP) | yes | core subset (pre-check) | core subset (pre-check) |
| With the optional SaxonC extension | yes | complete official CEN rule set | complete official KoSIT rule set |
| With the W System validator (self-hosted) or the W System API | yes | complete | complete |
| Engine | How it's enabled | XML Schema | EN 16931 / XRechnung 3.0.2 business rules | Labels in every result |
|---|---|---|---|---|
| `php-core` (default) | nothing to install | yes | pre-check only: a pure-PHP engine runs the bundled official rule files; it is not the official engine | `engine: "php-core"`, `conformance: "pre-check"`, `checked.EN16931: "core-subset"` |
| `saxonc` | optional SaxonC-HE PHP extension (`ext-saxonc`), auto-detected | yes | official KoSIT/CEN schematron (bundled, unmodified) | `engine: "saxonc"`, `conformance: "official"` |
| `remote` | `HttpValidator` (opt-in; the file is sent to the W System validator or API) | yes | official | `engine: "remote"`, `conformance: "official"` |

Out of the box, validation runs XML Schema validation and a pure-PHP pre-check of the core EN 16931 and XRechnung rules. For the complete official rule sets, install the optional SaxonC extension or point the validator at the W System validator or API. Peppol BIS 3 rules are not included.
Out of the box, validation runs XML Schema validation and a pure-PHP pre-check (`php-core`) of the EN 16931 and XRechnung rules. A valid result in this mode is a pre-check, not a conformance check. For the complete official rule sets, install the optional SaxonC-HE extension (`ext-saxonc`) or point the validator at the W System validator or API (`remote`). Peppol BIS 3 rules are not included.

Every file the generator produces is tested in CI with the official KoSIT validator, veraPDF (PDF/A-3b) and the Mustang ZUGFeRD validator.

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"phpunit/phpunit": "^10.5 || ^11.0"
},
"suggest": {
"ext-saxon": "SaxonC-HE PHP extension: runs the official EN 16931 / XRechnung schematron (XSLT 2.0) in-process, identical to KoSIT",
"ext-saxonc": "SaxonC-HE PHP extension (php -m: saxonc): runs the official EN 16931 / XRechnung schematron (XSLT 2.0) in-process",
"wsystem/wsystem-php": "Hosted W System API client: VIES VAT checks, Peppol routing, sending"
},
"autoload": {
Expand Down
Loading
Loading