Skip to content
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

Issue-9231 include promotions into order taxes calculation #10116

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

sacha75
Copy link
Contributor

@sacha75 sacha75 commented Apr 27, 2020

See Issue 9231
This workaround will result into correct tax calculation at order level with order adjustments.

@squash-labs
Copy link

squash-labs bot commented Apr 27, 2020

Manage this branch in Squash

Test this branch here: https://sacha759231-taxes-not-includin-0zj6a.squash.io

@MatthewKennedy
Copy link
Contributor

MatthewKennedy commented Apr 29, 2020

Hi @sacha75,

I was looking at this by copying your code across into a version of Spree 4 I have locally, and I can't get the correct tax.

Can I just check the values I get with your results?

I added 2 items to cart, $100 each with a $50 whole order discount.
1st item is taxed at 20% (tax included in price)
second item not taxed.

I get tax at $16.67 when I go to checkout.

Expected tax of $12.50 ($100 USD item -$25 = $75 tax in price $12.50)

@sacha75
Copy link
Contributor Author

sacha75 commented Apr 29, 2020

Hi @sacha75,

I was looking at this by copying your code across into a version of Spree 4 I have locally, and I can't get the correct tax.

Can I just check the values I get with your results?

I added 2 items to cart, $100 each with a $50 whole order discount.
1st item is taxed at 20% (tax included in price)
second item not taxed.

I get tax at $16.67 when I go to checkout.

Expected tax of $12.50 ($100 USD item -$25 = $75 tax in price $12.50)

Hi @MatthewKennedy,

Thanks for your feedback, I had a wrong condition and I have commited an update.
On my local version of Spree 4.2.0 it now gives me correct result for your example.

I'm trying to get the test passed on my local version then on Circleci, I'll keep updating this PR until it works

@sacha75
Copy link
Contributor Author

sacha75 commented Apr 29, 2020

I changed it to work only with included_tax_total as calculation should be different for additional_tax_total.
I believe that business logic is the following: order level adjustment is intended to be with or without tax depending on items being with or without tax.
If Item A is $100 tax included, order discount of $10 is expected to be tax included. We expect to see at the end of the bill $90 and see the according tax amount (B2C logic)
If Item B is $100 with $10 of additional taxes, order discount of 10$ should apply to item net amount. We expect to see at the end of the bill $90, then the correct tax amount to add, then the final total (B2B logic)

Spree allows a mix of included and additional tax, in that case there is no way to calculate correctly the new tax. One option would be to add to order adjustment an information to know if user intended adjustment to apply it to the amount with or without tax.

On the other hand not fixing that issue results into incorrect tax calculation which is a problem for e-businesses.

Before going any further I would like to have the opinion of the Spree team

@MatthewKennedy
Copy link
Contributor

MatthewKennedy commented Apr 29, 2020

Hi @sacha75

Have you tried this extension?
https://github.com/MatthewKennedy/spree_fixed_amount_discount

The extension works for mixed cart of taxed and none taxed items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants