Skip to content

Allow item attributes to hold more than one value - #912

Merged
rilla merged 2 commits into
mainfrom
attribute-multiple-values
Aug 5, 2026
Merged

Allow item attributes to hold more than one value#912
rilla merged 2 commits into
mainfrom
attribute-multiple-values

Conversation

@alvarolivie

@alvarolivie alvarolivie commented Jul 29, 2026

Copy link
Copy Markdown
Contributor
  • org: rule GOBL-ORG-ATTRIBUTE-02 relaxed from exactly one of text, code, amount, or date to at least one, so an attribute can group related values under a single name. An attribute with no value at all is still invalid.
  • Doc comment and data/rules/org.json updated to match. The JSON schema is unchanged, as it only carries the first sentence of the type description.
  • Tests: the previous "multiple values" and "text and code" failure cases become valid, plus a case for an attribute holding both a text and a date.

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.

Copilot AI review requested due to automatic review settings July 29, 2026 11:22

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 relaxes validation for org.Attribute so a single attribute can contain multiple related values (e.g., reference text + reference date) under one label/key/type, enabling better round-tripping for formats like FatturaPA’s AltriDatiGestionali.

Changes:

  • Update GOBL-ORG-ATTRIBUTE-02 from “exactly one value” to “at least one value” across Go validation, rule JSON, and type comments.
  • Adjust tests so multi-value attributes are now valid and add coverage for a “text + date” (INTENTO-style) attribute.
  • Document the behavior change in CHANGELOG.md.

Reviewed changes

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

File Description
org/attribute.go Relaxes attribute value validation and updates inline documentation to reflect multi-value support.
org/attribute_test.go Updates validation tests to accept multiple value fields and adds a representative “text + date” case.
data/rules/org.json Regenerates rule GOBL-ORG-ATTRIBUTE-02 description and expression to match the new >= 1 requirement.
CHANGELOG.md Notes the behavioral change for org.Attribute in the Unreleased “Changed” section.

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

@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.92%. Comparing base (ee9c5a1) to head (b938329).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #912   +/-   ##
=======================================
  Coverage   94.92%   94.92%           
=======================================
  Files         325      325           
  Lines       17678    17678           
=======================================
  Hits        16780    16780           
  Misses        556      556           
  Partials      342      342           

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

An attribute required exactly one of the text, code, amount, or date
values. Some formats group related values under a single name, so the
rule now asks for at least one instead.

The case that prompted this is the FatturaPA AltriDatiGestionali block,
which may carry a reference number alongside the date it was issued:

  <AltriDatiGestionali>
    <TipoDato>INTENTO</TipoDato>
    <RiferimentoTesto>08060120341234567-000001</RiferimentoTesto>
    <RiferimentoData>2025-03-10</RiferimentoData>
  </AltriDatiGestionali>

With one value per attribute, the mapping either drops the date or
splits the block into two attributes that no longer look related.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 29, 2026 11:27
@alvarolivie
alvarolivie force-pushed the attribute-multiple-values branch from 64618f4 to cbcd6d6 Compare July 29, 2026 11:27
@alvarolivie
alvarolivie marked this pull request as draft July 29, 2026 11:27

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 review from rilla and samlown July 29, 2026 11:37
@alvarolivie
alvarolivie marked this pull request as ready for review July 29, 2026 11:46

@rilla rilla 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.

Nice!

@rilla
rilla merged commit 0a2c9ad into main Aug 5, 2026
4 checks passed
@rilla
rilla deleted the attribute-multiple-values branch August 5, 2026 08:01
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