Repository navigation
Add the EN 16931 rules BR-37, BR-7 and BR-CO-04, and drop BR-CO-25 - #1040
miguelalvarezd wants to merge 9 commits into
Conversation
EN 16931 addresses have three lines (BT-162, BT-163, BT-164, BT-165), but org.Address only had street and street_extra, so the third was lost in conversion. street_third holds it, with Address.LineThree() to read it as LineOne() and LineTwo() do. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Document-level charges must have taxes under EN 16931, as discounts already must (BR-32). The charge and line discount reason rules now cite BR-38 and BR-42. Split out of the PINT AE regime PR, as it affects every EN 16931 document. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1040 +/- ##
=======================================
Coverage 96.93% 96.93%
=======================================
Files 336 336
Lines 15422 15412 -10
=======================================
- Hits 14949 14940 -9
+ Misses 472 471 -1
Partials 1 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
An active moderate finding remains because the test can pass when validation incorrectly rejects the charge, so it does not verify the intended valid behavior.
1 open issue
What changed in this PR
Updates the EU EN 16931 addon to enforce BR-37 for document-level charges and corrects related EN 16931 rule references.
Changes:
- Requires taxes on document-level charges with fault code
GOBL-EU-EN16931-BILL-CHARGE-02. - Corrects charge and line-discount reason references to BR-38 and BR-42.
- Adds validation coverage and documents the breaking behavior.
| File | Description |
|---|---|
| data/rules/eu-en16931.json | Updates generated EN 16931 rule descriptions and adds the BR-37 charge-tax requirement. |
| changes/unreleased/en16931-charge-taxes.md | Documents the breaking document-charge tax requirement and corrected rule references. |
| addons/eu/en16931/bill.go | Implements BR-37 validation for document-level charges and updates the related rule references. |
| addons/eu/en16931/bill_test.go | Updates charge fixtures and adds tests covering taxed and untaxed document-level charges. |
Review effort: Lite
The discount tests have no equivalent, and it only checked the error text when there was an error. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The third address line is no longer part of this stack: the BR-37 work does not need it, so this branch must not depend on the street_third PR. This reverts the street_third field, LineThree, its schema, tests and changelog entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BR-CO-25 (payment due date or terms when an amount is due) is no longer in the EN 16931 validation artefacts since version 1.3.16, for both UBL and CII. Remove the invoice rules that required payment details and terms when an amount is due, and the payment terms rule that required due dates or notes, which only existed for BR-CO-25. The remaining rule codes are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
EN 16931 requires the buyer name (BT-44) whenever there is a buyer. Core GOBL only asks for the customer name when the customer has a tax ID, so a customer without a name passed validation and produced a document the EN 16931 schematron rejects. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each EN 16931 invoice line must have an invoiced item VAT category (BT-151). The addon gives every tax combo a UNTDID tax category, so a line has one as soon as it has taxes. Lines without taxes passed validation and produced lines with no VAT category. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The change contains two unresolved critical regressions that remove the EN 16931 third address line from both the public schema and address model, breaking BT-162–BT-165 compatibility with stacked change #1039.
2 open issues
Review effort: Lite
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed because the charge validation can accept a non-VAT-only tax set even though the target EN 16931 rule requires a VAT category, leaving a compatibility gap not covered by the published review.
No open issues 🎉
2 resolved since last review
Review effort: Lite


Split out of invopop/gobl#1033, as it changes every EN 16931 document and not only UAE ones. Each rule is one the EN 16931 validation artefacts check, so these documents already fail when sent as UBL or CII; GOBL now rejects them first.
eu-en16931-v2017: breaking: document-level charges must have taxes (BR-37), as discounts already must (BR-32). Charges without taxes now fail withGOBL-EU-EN16931-BILL-CHARGE-02. Informative charges fail too: core GOBL forbids taxes on them, and EN 16931 has no way to express a charge that doesn't count towards the totals, so in UBL or CII it would break BR-37 and BR-CO-12.eu-en16931-v2017: breaking: an invoice with a customer must have the customer's name (BR-7),GOBL-EU-EN16931-BILL-INVOICE-09. Core GOBL only requires it when the customer has a tax ID.eu-en16931-v2017: breaking: every line must have taxes (BR-CO-04, the invoiced item VAT category),GOBL-EU-EN16931-BILL-INVOICE-10. It asks for taxes, not specifically VAT, so Canary Islands (IGIC) and Ceuta and Melilla (IPSI) lines, with their own categories, still pass.eu-en16931-v2017: BR-CO-25 is gone:GOBL-EU-EN16931-BILL-INVOICE-06and-07(payment details and terms when an amount is due) andGOBL-EU-EN16931-PAY-TERMS-01(due dates or notes), which only existed for it. BR-CO-25 is in the EN 16931 validation artefacts up to 1.3.15 and absent from 1.3.16 and 1.3.17, in both UBL and CII (ConnectingEurope/eInvoicing-EN16931). The other rule codes are unchanged.eu-en16931-v2017: the charge and line discount reason rules cite BR-38 and BR-42, not BR-36 (charge amount) and BR-41 (line allowance amount). Fault codes are unchanged.Peppol PINT has the same rules (BR-37 as
aligned-ibrp-037), which is why they came up in the PINT AE work (invopop/gobl.peppol#8).Depends on
Nothing: based on
main. invopop/gobl#1033 is based on this PR.Part of MAP-11.
Pre-Review Checklist
go generate .to ensure that the Schemas and Regime data are up to date.changes/unreleasedwith an overview of my changes, as described inchanges/README.md.And if you are part of the org:
@samlown.🤖 Generated with Claude Code