Skip to content

en16931: validate party identity scope cardinality - #899

Merged
alvarolivie merged 7 commits into
mainfrom
fr-ctc-cdv-enforcement
Jul 15, 2026
Merged

en16931: validate party identity scope cardinality#899
alvarolivie merged 7 commits into
mainfrom
fr-ctc-cdv-enforcement

Conversation

@alvarolivie

@alvarolivie alvarolivie commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds two validation rules to the EN 16931 addon's org.Party identities, mirroring the standard's single-valued registration identifiers:

  • At most one identity may carry the legal scope — the legal registration identifier (BT-30 seller / BT-47 buyer).
  • At most one identity may carry the tax scope — the VAT identifier (BT-31 seller / BT-48 buyer).

Both rules share a small orgIdentitiesScopeCount helper. A party carrying zero such identities stays valid; only duplicates are rejected. go generate . regenerated data/rules/eu-en16931.json with 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

  • 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.
  • Updated the CHANGELOG.md with an overview of my changes.
  • 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.

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>
Copilot AI review requested due to automatic review settings July 15, 2026 08:16

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.

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” legal scoped identity and “at most one” tax scoped identity on org.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>
Copilot AI review requested due to automatic review settings July 15, 2026 08:23

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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@alvarolivie
alvarolivie requested a review from samlown July 15, 2026 08:27
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>
Copilot AI review requested due to automatic review settings July 15, 2026 08:28

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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

alvarolivie and others added 2 commits July 15, 2026 08:31
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 15, 2026 08:32
@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.78%. Comparing base (8b0bc06) to head (2a4567b).
⚠️ Report is 10 commits behind head on main.

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.
📢 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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

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>
Copilot AI review requested due to automatic review settings July 15, 2026 08:45

@samlown samlown left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Quick check on the boolean responses required.

Comment thread addons/eu/en16931/org.go Outdated

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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread addons/eu/en16931/org_scope_test.go Outdated
…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>
Copilot AI review requested due to automatic review settings July 15, 2026 08:52

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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@alvarolivie
alvarolivie merged commit c96d507 into main Jul 15, 2026
5 checks passed
@alvarolivie
alvarolivie deleted the fr-ctc-cdv-enforcement branch July 15, 2026 09:12
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.

3 participants