Skip to content

refactor: extract shared Luhn check digit and party tax ID helpers#773

Open
pablocaeg wants to merge 1 commit intoinvopop:mainfrom
pablocaeg:refactor/shared-helpers
Open

refactor: extract shared Luhn check digit and party tax ID helpers#773
pablocaeg wants to merge 1 commit intoinvopop:mainfrom
pablocaeg:refactor/shared-helpers

Conversation

@pablocaeg
Copy link
Copy Markdown

Noticed duplicate helper functions while reading through the regimes:

  • computeLuhnCheckDigit was identical in regimes/fr and regimes/it (both had a TODO asking for this). Added luhn.CheckDigit() to the existing pkg/luhn package and replaced both.

  • hasTaxIDCode / partyHasTaxIDCode was duplicated across regimes/be, regimes/de, regimes/dk, regimes/fr, regimes/nl, bill, and addons/it/sdi. Added Party.HasTaxIDCode() to org.Party and replaced all seven.

Pre-Review Checklist

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

Add luhn.CheckDigit() to pkg/luhn, replacing identical
computeLuhnCheckDigit implementations in the FR and IT regimes.
The existing pkg/luhn package already provided Check() for validation
but lacked the complementary check digit computation.

Add Party.HasTaxIDCode() method to org.Party, replacing identical
hasTaxIDCode/partyHasTaxIDCode helpers duplicated across the BE, DE,
DK, FR, NL regimes, the bill package, and the IT SDI addon.
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.04%. Comparing base (b6ed0ec) to head (2d4d0f7).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #773      +/-   ##
==========================================
- Coverage   93.05%   93.04%   -0.02%     
==========================================
  Files         333      333              
  Lines       17796    17770      -26     
==========================================
- Hits        16560    16534      -26     
  Misses        870      870              
  Partials      366      366              

☔ View full report in Codecov by Sentry.
📢 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.

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.

1 participant