en16931: validate party identity scope cardinality - #899
Conversation
Add rules on org.Party identities enforcing at most one identity with the legal scope (BT-30/BT-47) and at most one with the tax scope (BT-31/BT-48), sharing a small scope-count helper. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds EN 16931 validation to ensure org.Party.Identities does not contain duplicate registration identifiers for the standard’s single-valued party identifiers (legal registration and VAT/tax), aligning with BT-30/47 and BT-31/48 cardinality.
Changes:
- Add EN 16931 validation rules enforcing “at most one”
legalscoped identity and “at most one”taxscoped identity onorg.Party.Identities. - Introduce a small helper to count identities by scope and reuse it across both validations.
- Add unit tests covering allowed vs. duplicate scope cases, and document the behavior in the changelog.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| CHANGELOG.md | Documents the new EN 16931 party identity scope cardinality validation. |
| addons/eu/en16931/org.go | Adds the two scope cardinality assertions and a shared helper for counting scoped identities. |
| addons/eu/en16931/org_test.go | Adds tests verifying both legal-scope and tax-scope “at most one” enforcement. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The new party identity scope rules tighten validation on an existing addon, so they belong under Changed rather than Added. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
# Conflicts: # CHANGELOG.md
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #899 +/- ##
==========================================
+ Coverage 94.76% 94.78% +0.01%
==========================================
Files 318 319 +1
Lines 17269 17360 +91
==========================================
+ Hits 16365 16454 +89
- Misses 559 560 +1
- Partials 345 346 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Add an internal test exercising the non-slice defensive guards and the nil-entry skip in the identity scope-count helpers, restoring the package above the 90% coverage threshold. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
samlown
left a comment
There was a problem hiding this comment.
Quick check on the boolean responses required.
…l test Rewrite the scope-cardinality helpers as single short-circuit expressions so an incorrectly-typed value returns false (per review), matching the existing orgInbox* validators. This also removes the standalone guard branch, so the existing external rules.Validate tests give full coverage and the internal-package test file is no longer needed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Summary
Adds two validation rules to the EN 16931 addon's
org.Partyidentities, mirroring the standard's single-valued registration identifiers:legalscope — the legal registration identifier (BT-30 seller / BT-47 buyer).taxscope — the VAT identifier (BT-31 seller / BT-48 buyer).Both rules share a small
orgIdentitiesScopeCounthelper. A party carrying zero such identities stays valid; only duplicates are rejected.go generate .regenerateddata/rules/eu-en16931.jsonwith the two new fault codes. Validation-only change — no normalization/schema output shift, and the examples suite passes unchanged, so no example document needed updating.Pre-Review Checklist
go generate .to ensure that the Schemas and Regime data are up to date.And if you are part of the org: