Fix inclusive Since comparison for historical tax rates#749
Closed
rilla wants to merge 1 commit intoinvopop:mainfrom
Closed
Fix inclusive Since comparison for historical tax rates#749rilla wants to merge 1 commit intoinvopop:mainfrom
rilla wants to merge 1 commit intoinvopop:mainfrom
Conversation
RateDef.Value() used a strictly-less-than comparison (Since.Before(date)) which meant a rate with Since: 2017-01-01 would only apply from January 2nd. Every regime except Finland wrote Since dates as the actual effective date, assuming inclusive semantics. Fix the comparison to use !Since.After(date), making Since dates inclusive lower bounds. Also correct Germany's historical rate data, which had several errors independent of the boundary bug: - Standard rate in 1993 was 15%, not 16% (16% started April 1998) - The 2007 increase to 19% took effect January 1, not July 1 - COVID temporary reduction (16%/5%) ended December 31 2020, not December 31 2021 — restoration to 19%/7% was January 1 2021 - Reduced rate was 7% since 1983, not 5% since 1993 - Removed redundant 2007 entry for reduced rate (no change occurred) Add boundary date tests for both Germany and Colombia that verify the correct rate is applied on, before, and after each transition.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
While adding tests for historical rates in the FI regime implemented in #748, I realized that
RateDef.Value()usedSince.Before(date)(strictly less than) to match historical rates, so an invoice issued on the exactSincedate would get the previous rate instead.Existing regimes with historical rates (DE, CO, ES) define
Sinceas the actual effective date (e.g.,Since: 2017-01-01meaning "from January 1st onwards"). The previous comparison silently shifted that by one day.Changes
!Since.After(date)to makeSincean inclusive lower bound.RateDef.Value()covering boundary, nil, and no-match casesPre-Review Checklist
go generate .to ensure that the Schemas and Regime data are up to date.And if you are part of the org: