Jump to content

ecotax rounding bug


vraagdtc

Recommended Posts

EDIT: version 1.6.1.10

 

Hello,
 
I found something that seems like a bug to me.
I have a product with an ecotax of 10.
So I enter in the backoffice: 10.
In the database, this ecotax is inserted without VAT, so 8.264463.
The VAT is 21%.
But when I look at the product in the frontoffice, it says the ecotax is 9.99.
I looked in the PHP code myself and found this:

 

$ecotax_tax_amount = Tools::ps_round($this->product->ecotax, 2);
if (Product::$_taxCalculationMethod == PS_TAX_INC && (int)Configuration::get('PS_TAX')) {
$ecotax_tax_amount = Tools::ps_round($ecotax_tax_amount * (1 + $ecotax_rate / 100), 2);
}

 

So, first the ecotax gets rounded, then multiplied with the VAT, and then rounded again?

That's what happens then:

8.264463 rounded = 8.26

Adding VAT: 8.26 * 1.21 = 9.9946 (so it rounds at 9.99)

While, I think, it should do:

8.264463 * 1.21 = 10,00000023 (so it rounds at 10)

 

So, something like this:

 

if (Product::$_taxCalculationMethod == PS_TAX_INC && (int)Configuration::get('PS_TAX')) {
$ecotax_tax_amount = Tools::ps_round($this->product->ecotax * (1 + $ecotax_rate / 100), 2);
}

else {

$ecotax_tax_amount = Tools::ps_round($this->product->ecotax, 2);

}

 

Or am I wrong?

Edited by vraagdtc (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...