-
Notifications
You must be signed in to change notification settings - Fork 53
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
Total amount mismatch with external tax providers #614
Comments
Hmm, IIRC the exact reason why we recalculate the tax amounts is to prevent this type of thing from happening. But as you explained (and thanks for that!) there are edge cases we didn't take into account (like 6.25% tax rate for anything above amount USD n). Maybe it's best to wrap that calculation into a toggle and explain the scenarios in which a merchant would be using it or absolutely should turn it off? |
Maybe this would be an option yes, but maybe also worth investigating why the calculated tax amount from shopware is not used in the first place. I understand that it's for sure a tricky topic to satisfy all edge cases. But I think this can pop up more often in the future, if there are more and more international shops that use an external tax provider. |
I think there are multiple edge cases tied into this, from net price consumer groups, vouchers/discounts etc. https://github.com/mollie/Shopware6/blame/7127b7f50e00f69cf992482bcd3de863723c17d7/src/Service/MollieApi/PriceCalculator.php#L27 points to two particular cases - one with a classic rounding problem using vertical tax calculation, and one with promotions with mixed tax rates where we need to recalculate a fictional tax rate and amount. @boxblinkracer will have all the details I'm sure, and probably has an idea as well on how to proceed here. |
so i talked internally with @boxblinkracer the answer for the question why we do an extra calculation:
now back to the problem. i think it is not that hard if we just check the total amount and if it is set to 0.0 we can exclude the item from calculation. how ever this check also protects us that orders are not created with invalid data. is there a reliable way to find out that the case is valid if the tax rate is set but not the amount? i just need a way to verify somehow that the amount is valid because of tax exemption limits vs someone inserted wrong data into order. can you help me out there? |
@BlackScorp unfortunately I don't think that there is a reliable way to verify this. At least with the external tax provider we're using, they do not use the official TaxProvider-Interface (https://developer.shopware.com/docs/guides/plugins/plugins/checkout/cart/tax-provider.html) yet, but modify the tax using event subscribers. I don't know if by using the newish interface there would be a way to determine from the cart/order if the taxes were set externally. If it was, it would at least be clear, that 0.0 is valid in this case. If I were you, I'd rather research in this direction, because it's the fault of the Tax-Plugin if it is not using the official interface. But if there is also no way to determine validity using the interface, then I don't know either what to do without further looking into this. Maybe go with the suggestion from @fjbender and make the check configurable and turned on by default. |
@niklaswolf thanks iam going to checkout. but disabling the calculation is not an option, we have then add vouchers as own items and modify the refund manger. it is sadly no only a problem of disable/enable |
We have a US-shop, that needs to use an external tax provider service (in this case Avalara) because of the crazy complex tax rules in the US. There is a problem with Mollie and this external tax provider, but I think this is not only scoped to this specific provider, but more general.
We have for example this case: for the shipping costs, the external tax provider returns this:
This may seem strange on the first look, but is totally valid, because there are tax exemption limits that can come into play. So the general taxRate in this case is 6.25, but because of the tax exemption limit the amount is 0.0.
This is now where the trouble with the Mollie plugin starts, because the plugin calculates the taxAmount for every lineItem again (would be nice to know, why this is necessary in the first place).
See:
Shopware6/src/Service/MollieApi/Builder/MollieShippingLineItemBuilder.php
Line 52 in 7127b7f
and:
Shopware6/src/Service/MollieApi/PriceCalculator.php
Line 27 in 7127b7f
Because Mollie calculates the taxAmount again based on the taxRate, of course there is a mismatch which results in the following error during order creation:
Now the question is, how to solve this. Personally, I think the recalculation of the taxAmount in the Mollie plugin is not right, why not use the taxAmount present in the CalculatedTax-Object? But there may of course be good reasons unknown to me why this is necessary.
Nevertheless this will be a problem in the future for such cases, especially in the US and with external tax providers.
The text was updated successfully, but these errors were encountered: