Skip to content

Item identity scopes for EN 16931 (BT-155/156/157/158)#882

Draft
alvarolivie wants to merge 1 commit into
mainfrom
items-identities
Draft

Item identity scopes for EN 16931 (BT-155/156/157/158)#882
alvarolivie wants to merge 1 commit into
mainfrom
items-identities

Conversation

@alvarolivie

@alvarolivie alvarolivie commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Adds item identity scopes covering the EN 16931 item identification family.

Part of splitting the original combined item-details PR. Sibling PRs: item attributes (#859), and item base quantity & units (#881).

Changes

  • org: identity scopesorg.Identity.Scope gains four scopes for item identification, each documented inline with when to use it:
    • seller (BT-155) — the seller's own article number / SKU for the item.
    • buyer (BT-156) — the buyer's own catalogue code for the item.
    • legal (BT-157) — a registered-scheme identifier such as the GS1 GTIN (also used by parties for company registration numbers).
    • class (BT-158) — a classification-scheme category such as UNSPSC, CPV, or HS, rather than a unique identifier.
  • eu-en16931: identity rulesclass identities require the untdid-item-type extension (BT-158); items allow at most one legal identity (BT-157); legal item identities require iso-scheme-id (BR-64), enforced at the item level since party legal identities need no scheme.
  • data/catalogues/untdid — new untdid-item-type-version extension (BT-158-2).
  • Adds a GB example (examples/gb/invoice-item-identities.yaml) with all four item-identity scopes.

The buyer's item reference (BT-156) is now modelled as a buyer-scoped item identity rather than a Line.BuyerItemRef field — consistent with the UBL Item identification family (Sellers/Buyers/Standard/CommodityClassification).

Note

This branch regenerates data/rules/eu-en16931.json, which also drops the stale GOBL-EU-EN16931-TAX-COMBO-06 (BR-E-10) assertion. That Go rule was already removed in v0.501.0 but the generated data on main was never regenerated — a pre-existing drift fix, not a behaviour change here.

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.

@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.77%. Comparing base (595b77a) to head (d729816).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #882      +/-   ##
==========================================
+ Coverage   94.75%   94.77%   +0.01%     
==========================================
  Files         343      343              
  Lines       18815    18869      +54     
==========================================
+ Hits        17829    17883      +54     
  Misses        600      600              
  Partials      386      386              

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

@alvarolivie alvarolivie changed the title Item identities, scopes & buyer item reference (EN 16931 BT-156/157/158) Item identity scopes for EN 16931 (BT-155/156/157/158) Jun 30, 2026
@alvarolivie
alvarolivie force-pushed the items-identities branch 2 times, most recently from f029d9b to 6d95cfe Compare June 30, 2026 10:15
…ity rules

org.Identity gains four item-identification scopes mapping to the EN 16931
item identification family, each documented with when to use it:
- seller (BT-155): the seller's own article number / SKU
- buyer  (BT-156): the buyer's own catalogue code
- legal  (BT-157): a registered scheme identifier such as the GS1 GTIN
- class  (BT-158): a classification-scheme category (UNSPSC, CPV, HS)

Also:
- catalogues/untdid: new untdid-item-type-version extension (BT-158-2).
- eu-en16931: class identities require untdid-item-type (BT-158); items allow
  at most one legal identity (BT-157); legal identities require iso-scheme-id
  (BR-64), enforced at item level since party legal identities need no scheme.
- Regenerates eu-en16931 rules data, dropping the stale BR-E-10 assertion
  removed in Go in v0.501.0 (pre-existing data drift).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@alvarolivie
alvarolivie marked this pull request as ready for review June 30, 2026 10:39
Copilot AI review requested due to automatic review settings June 30, 2026 10:39

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

This PR expands org.Identity.Scope to cover the EN 16931 item identification family (BT-155/156/157/158) and adds EN 16931 addon validation to constrain item identities (including required extensions), alongside regenerated schemas/rules data and a GB example demonstrating usage.

Changes:

  • Add new identity scopes class, seller, and buyer (and clarify legal scope usage for items) in org.Identity, including validation + JSON Schema enum updates.
  • Add EN 16931 addon rules: (1) at most one legal identity per item, (2) legal item identities require iso-scheme-id, (3) class identities require untdid-item-type.
  • Add UNTDID extension key untdid-item-type-version and add example invoice exercising all four item identity scopes.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
org/identity.go Adds new identity scope constants, documents scope intent, and expands scope validation + JSON Schema enum.
org/identity_test.go Updates rule error assertion text and JSON Schema scope enum expectations.
addons/eu/en16931/en16931.go Registers new EN 16931 identity-level ruleset.
addons/eu/en16931/org.go Adds EN 16931 item identity constraints and class-scope extension requirement.
addons/eu/en16931/org_test.go Adds tests for new scope/extension requirements and item-level legal identity constraints.
addons/eu/en16931/org_internal_test.go Adds white-box tests for defensive guards in helper predicates.
catalogues/untdid/untdid.go Introduces untdid-item-type-version extension key constant.
data/rules/org.json Regenerates org rules JSON to reflect expanded identity scope set.
data/rules/eu-en16931.json Regenerates EN 16931 rules JSON to include new identity/item identity assertions and remove stale assertion.
data/schemas/org/identity.json Regenerates identity JSON Schema to include the new scope enum values.
examples/gb/invoice-item-identities.yaml Adds GB YAML example showing all four item identity scopes and required extensions.
examples/gb/out/invoice-item-identities.json Adds generated JSON output for the new GB item identities example.
CHANGELOG.md Documents the new scopes, EN 16931 identity rules, new UNTDID extension, and the regenerated-data drift fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@alvarolivie
alvarolivie requested a review from samlown June 30, 2026 10:48
@samlown
samlown marked this pull request as draft July 2, 2026 14:09
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