Skip to content

Fix inclusive Since comparison for historical tax rates#750

Merged
samlown merged 1 commit intoinvopop:mainfrom
rilla:fix-rate-since-comparison
Mar 3, 2026
Merged

Fix inclusive Since comparison for historical tax rates#750
samlown merged 1 commit intoinvopop:mainfrom
rilla:fix-rate-since-comparison

Conversation

@rilla
Copy link
Copy Markdown
Contributor

@rilla rilla commented Mar 2, 2026

Context

While adding tests for historical rates in the FI regime implemented in #748, I realized that RateDef.Value() used Since.Before(date) (strictly less than) to match historical rates, so an invoice issued on the exact Since date would get the previous rate instead.

Existing regimes with historical rates (DE, CO, ES) define Since as the actual effective date (e.g., Since: 2017-01-01 meaning "from January 1st onwards"). The previous comparison silently shifted that by one day.

Changes

  • Use !Since.After(date) to make Since an inclusive lower bound.
  • Add unit tests for RateDef.Value() covering boundary, nil, and no-match cases

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.

@rilla rilla force-pushed the fix-rate-since-comparison branch from 8df24ff to 876ccd7 Compare March 2, 2026 12:51
@rilla rilla force-pushed the fix-rate-since-comparison branch from 876ccd7 to 8c16a2e Compare March 2, 2026 12:54
@rilla rilla marked this pull request as ready for review March 2, 2026 12:55
@rilla rilla mentioned this pull request Mar 2, 2026
13 tasks
Copy link
Copy Markdown
Collaborator

@samlown samlown left a comment

Choose a reason for hiding this comment

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

Very nice catch. Clearly, we've never had a VAT rate chance since launching GOBL! Thanks!

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.05%. Comparing base (926130f) to head (8c16a2e).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #750   +/-   ##
=======================================
  Coverage   93.05%   93.05%           
=======================================
  Files         333      333           
  Lines       17785    17785           
=======================================
  Hits        16549    16549           
  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.

@samlown samlown merged commit 54ba861 into invopop:main Mar 3, 2026
4 checks passed
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