-
Notifications
You must be signed in to change notification settings - Fork 211
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 calculation of taxes when items are discounted #155
Merged
bcomnes
merged 6 commits into
netlify:master
from
mraerino:fix/calculation-discount-taxes
Nov 14, 2018
Merged
Fix calculation of taxes when items are discounted #155
bcomnes
merged 6 commits into
netlify:master
from
mraerino:fix/calculation-discount-taxes
Nov 14, 2018
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
mraerino
force-pushed
the
fix/calculation-discount-taxes
branch
from
November 2, 2018 16:58
4904fa7
to
55ab899
Compare
This was referenced Nov 2, 2018
mraerino
changed the title
Fix calculation of taxes when items are discounted
WIP: Fix calculation of taxes when items are discounted
Nov 9, 2018
mraerino
force-pushed
the
fix/calculation-discount-taxes
branch
from
November 13, 2018 13:41
a47ff3f
to
0be552d
Compare
Introduces the field "NetTotal" for orders and price items. This field represents the net amount of a single item or an order that taxes are calculated based on. While the "subtotal" amount is not discounted, the "NetTotal" is. This is especially important when prices are expected to include taxes. In these cases discounts are applied to the original price and then the net price is calculated. Since this fixes the behavior of the tax calculation for discounted orders this is where tests needed to change.
mraerino
force-pushed
the
fix/calculation-discount-taxes
branch
from
November 13, 2018 13:47
0be552d
to
cac1d86
Compare
mraerino
changed the title
WIP: Fix calculation of taxes when items are discounted
Fix calculation of taxes when items are discounted
Nov 13, 2018
@bcomnes this has been refined to not be a breaking change and is ready for review now 🙂 |
Fantastic thank you. |
bcomnes
approved these changes
Nov 14, 2018
Brilliant, thank you @mraerino |
@bcomnes nope. that was not part of my contract since it arrived later. it is only partly related as well |
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.
Fixes #129
- Summary
The current behavior of GoCommerce is to apply discounts after calculating taxes.
This is valid for neither VAT nor sales tax based systems because taxes need to be applied to the final net amount. See #129 for more info and examples.
This PR includes several refactors to make the change easier.
The central commit (11df6e0) will change the calculation of a single item to this procedure:
net_total
)total
by addingnet_total
+taxes
Introduces the field
NetTotal
for orders and price items.This field represents the net amount of a single item or an order that taxes are calculated based on. While the
SubTotal
amount is not discounted, theNetTotal
is.This is especially important when prices are expected to include taxes. In these cases discounts are applied to the original price and then the net price is calculated.
Notice: You can not calculate the net amount from the subtotal by subtracting the discount when prices include taxes. The discount will always be based on the original price while the behavior of the subtotal is not changed an will show the non-discounted net total. There are several possible improvements for that problem (e.g. adding a field "original price").
- Test plan
Several tests have been added or updated to reflect this altered calculation behavior.
Since this fixes the behavior of the tax calculation for discounted orders this is where tests needed to change.
- Description for the changelog
Fix calculation to apply discount before taxes
- A picture of a cute animal (not mandatory but encouraged)