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

"wrong" VAT calculation on Mollie API results in declined order #63

Closed
hw-dwalter opened this issue Oct 7, 2020 · 2 comments
Closed

Comments

@hw-dwalter
Copy link

hw-dwalter commented Oct 7, 2020

We discovered the following issue with some orders:

> Could not create Mollie order, error: Error executing API call (422: Unprocessable Entity):
> Order line 3 is invalid. VAT amount is off.
> Expected VAT amount to be -€0.54 (-€3.95 × (16.00% / 116.00%)), got -€0.55.
> Field: lines.3.vatAmount.

This is the corresponding shopping cart in our shopware 6:
image

I have debugged the data sent to mollie API. This numbers are sent to mollie:
image

This means that Mollie calculates the VAT of the 5% discount from the unit price and not from the VAT Amount of the main article!

Here again the mathematics behind it:

  • Shopware
    • -€10.90 × (5.00% / 100.00%) = -€0.55
  • Molly
    • -€3.95 × (16.00% / 116.00%) = -€0.54

As a result, Mollie refuses this order. The order does not reach Mollie. It is not visible in the dashboard. In the shopware these orders are stored with the payment status "Open" and without Mollie Order ID.

The problem of different mathematics seems to be the "horizontal VAT" or "vertical VAT". calculation. More information about this here https://rolandtapken.de/blog/2008-08/mwst-berechnung-von-lexware-buero-easy (only german)

However, this is the only way to determine the sum of the individual VAT amounts. values is correct. So 10,90€ - 0,33€ -0,55€ = 10,02€

The error is therefore to be found in Mollie or the Shopware6 plugin from Mollie and probably not in the Shopware itself.

Temporarily I changed the math in shopware core in this file to get rid of this error:
https://github.com/shopware/platform/blob/master/src/Core/Checkout/Cart/Price/PercentagePriceCalculator.php#L46
But this will only help in case of percentage discounts and is far away from perfekt!

@boxblinkracer
Copy link
Collaborator

Hi guys

thank you very much for this

so first of all,...we do only maintain the Shopware 5 plugin. the shopware 6 is done by another agency
that means the issue would belong here: https://github.com/mollie/Shopware6

still i have some (good) news for you
we had that also in one of our shopware 6 shops.

the problem is indeed more related to shopware as it seems. because values store the full float, so instead of 23.12 it has 23.120000005 stored in the DB. that means the overall sum could then differ...

mollie has indeed a validation for this....here you can find the formular: https://docs.mollie.com/reference/v2/orders-api/create-order
just search for totalAmount of formula

so the vertical and horizontal configuration has to match of course...which is...yeah...it is like it is...
but even if they are the same, it can still differ

a fix we did in a customer project was, to do a live calculation in the mollie shopware 6 plugin. so we dont use the pre calculated sums from the database, but calculate it live with correct rounding...its not perfect but it worked...

i hope this helps you in the meanwhile

cheers
christian

Screenshot 2020-10-07 at 17 01 27

@boxblinkracer
Copy link
Collaborator

i told the mollie-shopware-6 guys about it and will close this ticket now here

feel free to contact us again if you need something :)

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

No branches or pull requests

2 participants