Sylius: Cart and Checkout Shipping Total is Having a Tax Applied Two Times

Created on 23 Mar 2020  ·  6Comments  ·  Source: Sylius/Sylius

Sylius version affected: 1.6.X, 1.7.X, 1.8.0-DEV

Description

When shipping is set in the back-end with the tax option enabled on it, checkout and cart at the presentation side is having wrong calculation applied on it in the way that tax for shipping is applied twice.

Additional side-effects

  • PayPal payment is not working due the wrong item prices (calculated again at the PayPay's side)
    ** Message: "The totals of the cart item amounts do not match order amounts."

Steps to reproduce

  1. Create a zone and tax category
  2. Create a tax rule (e.g. 13% and apply to the zone and category - tax not included in the price must stay disabled)
  3. Create a shipping with the price (e.g. 10) and select the created tax
  4. Create a product with the same tax applied to it
  5. Login as a customer (address must match the zone or it should match the tax, generally)
  6. Add created product to the cart
  7. Investigate cart total and checkout total

Possible Solution
It seems that "getShippingTotal" method is applying unnecessary TAX adjustment.
Simple removal of the line "526" resolved this issue on my side.
https://github.com/Sylius/Sylius/blob/master/src/Sylius/Component/Core/Model/Order.php#L526

wrong_shipping_tax_calculation

Items total: 15.00
Estimated shipping cost: 11.30 (should be 10, since the shipping price is set to be 10)
Taxes total: 3.25 (correct for (15+10)0.13)
Order total: 28.25 (correct for: 15+10+((15+10)
0.13))

NOTE: I've tried fresh installation based on 1.8.0-DEV - same thing
Sylius_1 8 0-DEV

Potential Bug

All 6 comments

I think you have to set the parameter 'included_in_price' at true.

@nayluge for that scenario it probably works (I haven't tested it thoroughly) - But for scenario where tax is not included, it is not working correctly. Like I stated above, it further manifests through PayPal payment error, too. ^^^

I'm agree with you @vladimirdjuricic. I'm fighting with this too. When I applied a tax category (the same as my products) to my delivery method it will do this behaviour. And it will also make Paypal payment unvailable (it said than the amount of the cart is not good).

It's not a potential bug, but a real one haha

I found a solution to this problem.
You've to create two taxes categories then apply one for your products and one for your delivery method.
Result :
image

Hello! The problem is that we assume that each tax on the Order level is a shipment tax. It's definitely too optimistic 😄 We should figure out what is the best solution. I see 2 of them right now:

  • specific SHIPPING_TAX_ADJUSTMENT
  • TAX_ADJUSTMENT on the Shipment level

🚀

Let's move the conversation to #8950, to keep it in one place.

Was this page helpful?
0 / 5 - 0 ratings