Add CorrectionNormalizer callback to tax.CorrectionDefinition#815
Open
Add CorrectionNormalizer callback to tax.CorrectionDefinition#815
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #815 +/- ##
==========================================
+ Coverage 92.28% 92.40% +0.11%
==========================================
Files 370 370
Lines 23242 23295 +53
==========================================
+ Hits 21450 21525 +75
+ Misses 1357 1339 -18
+ Partials 435 431 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new correction-time normalization hook (CorrectionNormalizer) so addons/regimes can route/adjust tax extensions during Invoice.Correct() (instead of relying on Calculate()-time hacks), along with supporting utilities and migrations in affected addons.
Changes:
tax: introduceCorrectionNormalizer+CorrectionDefinition.Normalize, and chain normalizers when merging correction definitions.tax/bill: addExtensions.Clone()andInvoice.CorrectionOptionsValue()to support safe, correction-scoped normalization.- Addon migrations: implement
Normalizefor ARCA v4 and migrate Verifactu/SII to use the new correction hook; adjust tests + changelog accordingly.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
tax/extensions.go |
Adds Extensions.Clone() to allow safe copying of extension maps. |
tax/extensions_test.go |
Tests clone behavior (nil/empty/independent copy). |
tax/corrections.go |
Adds CorrectionNormalizer and CorrectionDefinition.Normalize; chains normalizers in Merge(). |
tax/corrections_test.go |
Expands unit tests for correction set lookup, merging, and normalizer chaining. |
bill/invoice.go |
Adds internal correctionOptions storage + CorrectionOptionsValue() accessor for normalizers. |
bill/invoice_correct.go |
Invokes correction normalizer during Correct(), sets preceding earlier, clones option extensions. |
bill/invoice_correct_test.go |
Adds invoice-level tests covering normalization and ensuring options aren’t leaked. |
addons/ar/arca/bill_invoice.go |
Implements ARCA correction normalizer to copy original tax extensions to preceding and route doc-type to invoice. |
addons/ar/arca/bill_invoice_test.go |
Updates correction definition assertions and adds correction-normalization behavior tests. |
addons/es/verifactu/bill.go |
Migrates doc-type routing to CorrectionNormalizer during Correct(). |
addons/es/verifactu/bill_test.go |
Adjusts expectations now that preceding extensions aren’t forcibly emptied by Calculate(). |
addons/es/sii/bill.go |
Migrates doc-type routing to CorrectionNormalizer during Correct(). |
addons/es/sii/bill_test.go |
Adjusts expectations now that preceding extensions aren’t forcibly emptied by Calculate(). |
data/addons/ar-arca-v4.json |
Removes explicit correction types from addon data (types still provided by the AR regime). |
CHANGELOG.md |
Documents the new hook, migrations, and extension cloning behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e18c178 to
92c9e2e
Compare
92c9e2e to
8027c7c
Compare
13 tasks
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.
the invoice and the preceding document reference during Correct().
Pre-Review Checklist
go generate .to ensure that the Schemas and Regime data are up to date.And if you are part of the org: