-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: adjust tax precise amount when issuing credit notes #2643
Merged
Conversation
This file contains 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
annvelents
changed the title
wip adjusting tax precise amount
Fix: adjust tax precise amount when issuing credit notes
Oct 4, 2024
annvelents
force-pushed
the
fix-rounding-adjustment-on-cn
branch
from
October 4, 2024 12:32
3026866
to
2507dad
Compare
ancorcruz
approved these changes
Oct 8, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
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.
Context
We have this issue that when we issue Invoice, we apply tax on sum of items,
but when we issue a credit note, we apply tax on each item separately.
as result, some values can be rounded in deffirent direction which result in not matching sum.
Example that our client had (all values are amount_cents):
if we apply 20% taxes on the sum of charges, we get:
but because it is in cents, when issuing the invoice, the value is rounded to
334_99
Next, when we create credit notes for this invoice, and we create a separate CN per each item:
Sum of these credit notes is
335_00
which is more than the invoice total, and we fail vthe validation, despite the fees amount is correctDescription
To help this situation, we can operate adjustments that were made when credit notes are issued.
So when we're creating CN1-3, we simply create credit notes.
when we create CN4, we are subtracting all rounding adjustments that were made for all credit notes for this invoice. in our case, we will need to subtract
0.4
cents from precise taxes amount, and then for the last credit noteCN04 = 68_33 * 1.2 = 8199.6 -0.4 = 8199.2 => 8199
and the values are matching
also removed validation on credit_note_item total amount, as it tries to predict taxes, but they are adjusted further in the credit note creation service