Jump to content

[Résolu] Total des taxes différent si affichage HT ou TTC


Recommended Posts

Bonjour à toutes et à tous.
 
Après pas mal de recherches sur le forum et les changelogs de la 1.5, voici le problème que je rencontre depuis plusieurs jours maintenant sur ma boutique en 1.5.6.1.
 
Si je suis un client avec un groupe qui affiche les prix en TTC, tout est ok.
Si je suis un client avec un groupe qui affiche les prix en HT, le montant total des taxes est légèrement différent...
 
Exemple: 
En HT   -> Total taxes : 12,05.
En TTC -> Total taxes : 12,07.
 
Résultat, cela influe sur le prix final.
De plus, je pense que cela impact le retour boutique après paiement qui va afficher le message d'erreur du type "Erreur de paiement" : Attention 649,00 € payé au lieu de 649,86 €

Comment cela est possible ? Comment débugger ce problème?
 
Merci d'avance.
 
EDIT : Au dernier moment, le bon post...
 
Solution trouvée ici : https://www.prestashop.com/forums/topic/235504-tax-is-calculated-wrong-in-prestashop-it-has-to-be-not-just-me-but-everyone/?p=1160341
 
1- Dans votre classe/Cart.php.
2- Dans la fonction getOrderTotal(),
3- Dans le foreach foreach ($products as $product) // products refer to the cart details
4- Dans la condition if ($this->_taxCalculationMethod == PS_TAX_EXC)
5- Dans la condition, if ($with_taxes)
 
remplacer 

if ($with_taxes)
{
	$product_tax_rate = (float)Tax::getProductTaxRate((int)$product['id_product'], (int)$address_id, $virtual_context);
	$product_eco_tax_rate = Tax::getProductEcotaxRate((int)$address_id);

	$total_price = ($total_price - $total_ecotax) * (1 + $product_tax_rate / 100);
	$total_ecotax = $total_ecotax * (1 + $product_eco_tax_rate / 100);
	$total_price = Tools::ps_round($total_price + $total_ecotax, 2);
}

par

if ($with_taxes)
{
	$product_tax_rate = (float)Tax::getProductTaxRate((int)$product['id_product'], (int)$address_id, $virtual_context);
	$product_eco_tax_rate = Tax::getProductEcotaxRate((int)$address_id);   
	$total_price = Tools::ps_round(($price - $product['ecotax'])  * (1 + $product_tax_rate / 100),2);
	$total_price = $total_price * (int)$product['cart_quantity'];
}
Edited by arnaud1900 (see edit history)
Link to comment
Share on other sites

  • 3 months later...

Légère modification :

 

Toujours dans la même condition, changer : 

if ($with_taxes)
{
	[...code précédent]
	$total_price = $total_price * (int)$product['cart_quantity'];
}

pour :

if ($with_taxes)
{
	[...code précédent]
	$total_price = Tools::ps_round($total_price * (int)$product['cart_quantity'],2);
}

Edited by arnaud1900 (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...