WooCommerce shipping tax

This isn’t really a wordpress issue, but I’m going to answer it since I think the nature of the issue is not understanding that the code behind what is seen as an error in the outcome, is doing precisely what would make sense if the values entered were needed to create a total rather than reconstruct one. Simply put, it’s a rounding issue, and it happens because the code is expecting (forcing) real-world values at certain stages of its calculations.

The Issue

When rounding numbers that were derived from a calculation, like in your case:

[ Gross / (tax rate +1) = pre tax], the results can be unexpected.

12.605042016806723 x 1.19 versus 12.6050 x 1.19 versus 12.60 x 1.19 versus 12.61 x 1.19, especially if the resulting value will be rounded again.

I think the issue is related with the number of decimals used –
WooCommerce is set to 2 decimals. If I change the WooCommerce setting
to use 4 decimals, it is OK, but the amounts look awful and are very
confusing for customers.

I think you’re right. And the real issue is that the resulting value of shipping + (shipping x tax rate) will also be rounded to two decimals.

119% of 12.6050 = 14.99995 (rounded to two decimals: 15.00)

119% of 12.61 (which would be the rounded value if system is using two decimals) = 15.0059 (rounded to two decimals: 15.01)

I don’t know all the plugin settings you mentioned, but perhaps the

Round tax at subtotal level

option you’re showing is rounding the shipping price to 12.61 before that tax calculation (aka, at subtotal). Regardless, there’s a simple fix:

Solution:

Since you’re trying to make it total 15.00, rather than accurately reflect shipping + shipping tax, drop everything after the second decimal place on shipping cost so it is 12.60 rather than 12.6050 or 12.605042016806723 😉

12.60 x 1.19 = 14.994, which will round to 15.00.