Skip to content

Add the EN 16931 rules BR-37, BR-7 and BR-CO-04, and drop BR-CO-25 - #1040

Open
miguelalvarezd wants to merge 9 commits into
mainfrom
en16931-charge-taxes
Open

miguelalvarezd wants to merge 9 commits into
mainfrom
en16931-charge-taxes

Conversation

@miguelalvarezd

@miguelalvarezd miguelalvarezd commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

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 with GOBL-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-06 and -07 (payment details and terms when an amount is due) and GOBL-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

  • Opened this PR as a draft
  • Read the CONTRIBUTING.md guide.
  • Performed a self-review of my code.
  • Added thorough tests with at least 90% code coverage.
  • Modified or created example GOBL documents to show my changes in use, if appropriate.
  • Added links to the source of the changes in tax regimes or addons, either structured or in the comments.
  • Run go generate . to ensure that the Schemas and Regime data are up to date.
  • Reviewed and fixed all linter warnings.
  • Been obsessive with pointer nil checks to avoid panics.
  • Added a file to changes/unreleased with an overview of my changes, as described in changes/README.md.
  • Marked this PR as ready for review.

And if you are part of the org:

  • Requested a review from Copilot and fixed or dismissed (with a reason) all the feedback raised.
  • Requested a review from @samlown.

🤖 Generated with Claude Code

miguelalvarezd and others added 3 commits November 16, 2026 16:39
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>
Copilot AI lite review requested due to automatic review settings November 17, 2026 16:16
@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.93%. Comparing base (0487f2f) to head (ac3a867).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread addons/eu/en16931/bill_test.go Resolved
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>
Copilot AI lite review requested due to automatic review settings November 17, 2026 16:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The BR-37 validation, corrected rule metadata, updated tests, and documentation are included, with no active review issues indicated.

No open issues 🎉

1 resolved since last review

Review effort: Lite

miguelalvarezd and others added 4 commits November 18, 2026 14:23
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>
Copilot AI lite review requested due to automatic review settings November 18, 2026 19:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread data/schemas/org/address.json Resolved
Comment thread org/address.go Resolved
@miguelalvarezd
miguelalvarezd removed this pull request from stack #1041 November 18, 2026 19:48
@miguelalvarezd miguelalvarezd changed the title Require taxes on document-level charges under EN 16931 (BR-37) Add the EN 16931 rules BR-37, BR-7 and BR-CO-04, and drop BR-CO-25 Nov 18, 2026
@miguelalvarezd
miguelalvarezd changed the base branch from address-street-third to main November 18, 2026 19:49
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings November 19, 2026 15:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants