I have an issue with the shipping tax calculation. I add the shipping cost without tax, and everything is calculated OK in the cart/checkout page. Also, in back office, the order is displayed correctly (cost/taxes are calculated OK).
The problem happens when you change the order status to Complete and the invoice is sent by email - it will automatically change the shipping cost and the total cost - it adds 0.01 (Note: if you manually generate the invoice before changing the order status to Complete, the invoice is generated OK - taxes/costs are OK in both invoice and back office).
Below are some screenshots with the current settings and the results:
Now, when you change the order status to Complete, it will send the invoice by email and will change the taxes/costs:
And this is how the amounts are displayed in the invoice:
The shipping cost is 15 with tax included, so I have to configure it to 12.6050 (without tax) in order be calculated correctly: 15 lei.
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.
From accounting perspective, the shipping cost without tax should be 12.61 lei, and the shipping tax should be 2.39 lei (total shipping cost with tax included = 15 lei)
Using WooCommerce 3.0.5 and WooCommerce PDF Invoices & Packing Slips (tried with other invoicing plugins, and the issue is the same).
Do you have any ideas what should I do to use 2 decimals and keep the shipping cost to 15 lei (tax included)?
Thank you for your help.
I have an issue with the shipping tax calculation. I add the shipping cost without tax, and everything is calculated OK in the cart/checkout page. Also, in back office, the order is displayed correctly (cost/taxes are calculated OK).
The problem happens when you change the order status to Complete and the invoice is sent by email - it will automatically change the shipping cost and the total cost - it adds 0.01 (Note: if you manually generate the invoice before changing the order status to Complete, the invoice is generated OK - taxes/costs are OK in both invoice and back office).
Below are some screenshots with the current settings and the results:
Now, when you change the order status to Complete, it will send the invoice by email and will change the taxes/costs:
And this is how the amounts are displayed in the invoice:
The shipping cost is 15 with tax included, so I have to configure it to 12.6050 (without tax) in order be calculated correctly: 15 lei.
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.
From accounting perspective, the shipping cost without tax should be 12.61 lei, and the shipping tax should be 2.39 lei (total shipping cost with tax included = 15 lei)
Using WooCommerce 3.0.5 and WooCommerce PDF Invoices & Packing Slips (tried with other invoicing plugins, and the issue is the same).
Do you have any ideas what should I do to use 2 decimals and keep the shipping cost to 15 lei (tax included)?
Thank you for your help.
Share Improve this question asked May 26, 2017 at 18:35 Nicu ZecheruNicu Zecheru 551 silver badge5 bronze badges2 Answers
Reset to default 2 +50This 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
.
This problem occurs because woocommerce tax rate upto 4 decimal point. I use this code to fix this woocommerce problem. Use snippet plugin to add this.
// Round price for .99 .01 decimals
add_filter( 'raw_woocommerce_price', function ( $price ) {
$decimals = round( $price - floor( $price ), 2 );
return ( $decimals == 0.01 || $decimals == 0.99 ) ? round( $price ) : $price;
} );