Incorrect line item VAT percentage
-
Hi,
we have identified the following issue in your code:
When the code calls $tax_rate = $this->get_item_tax_rate($order_item, $order); it ends up with the wrong value.
It seems the reason being down to rounding of incorrect values in the get_item_tax_rate() function. Specifically these two variables ending up with incorrect values:
$total_without_tax = $order->get_line_total($item, false, false);
$total_with_tax = $order->get_line_total($item, true, false);For an line item with a cost of 0,80€ and 24% tax rate, these will produce the values 0.645161 and 0.795161.
Then when doing the final calculation for $tax_rate = round(( $tax_total / $total_without_tax ) * 100); we get the incorrect tax rate of 23% and not 24%.
To reproduce the issue you can take these steps:
- Create a product with a total cost of 0,80€ and set its tax percentage to 24%.
- Create an order with the product and pay for the order and inspect the tax percentage of the line item in the Paytrail customer panel. It will show a VAT percentage of 23% and not 24% as it should.
If you need any further information, please let us know, thank you!
- The topic ‘Incorrect line item VAT percentage’ is closed to new replies.