-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: adjust tax precise amount when issuing credit notes (#2643)
## 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): ``` Invoice 001 charge01 = 68_33 charge 02 = 68_33 charge03 = 57_50 charge04 = 85_00 ``` if we apply 20% taxes on the sum of charges, we get: ``` (68_33 + 68_33 + 57_50 + 85_00) * 1.2 = 334_99,2 ``` 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: ``` CN01 = 68_33 * 1.2 = 8199.6 => 82_00 CN02 = 57_50 * 1.2 = 69_00 CN03 = 85_00 * 1.2 = 102_00 CN04 = 68_33 * 1.2 = 8199.6 = 82_00 ``` 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 correct ## Description 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 note `CN04 = 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
- Loading branch information
1 parent
c6a8738
commit 41d4a71
Showing
9 changed files
with
681 additions
and
25 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Oops, something went wrong.