sbordun Posted December 29, 2011 Share Posted December 29, 2011 PaymentModule.php The PDF invoice shows wrong Tax=>Tax calculated for only ONE product in the Cart instead of sum of products. Recommended changes for validateOrder() function: 1)use intval() for the rate 2) sum up tax += instead of = CODE CHANGES: 1. original code: if (!$nTax++) $storeAllTaxes[$res->id]['amount'] = ($price * (1 + ($res->rate * 0.01))) - $price; else{ $priceTmp = $price_wt / (1 + ($res->rate * 0.01)); $storeAllTaxes[$res->id]['amount'] = $price_wt - $priceTmp; } 1. fixed code: if (!$nTax++) $storeAllTaxes[$res->id]['amount'] += ($price * (intval($res->rate) * 0.01))* $quantityInStock; else{ $priceTmp = $price_wt / (1 + (intval($res->rate) * 0.01)); $storeAllTaxes[$res->id]['amount'] += ($price_wt - $priceTmp)* $quantityInStock; } 2. original code: if (!$nTax++) $storeAllTaxes[$res->id]['amount'] += ($shippingCostTaxExcl * (1 + ($res->rate * 0.01))) - $shippingCostTaxExcl; else{ $priceTmp = $order->total_shipping / (1 + ($res->rate * 0.01)); $storeAllTaxes[$res->id]['amount'] += $order->total_shipping - $priceTmp; } 2. fixed code: if (!$nTax++) $storeAllTaxes[$res->id]['amount'] += $shippingCostTaxExcl * (intval($res->rate) * 0.01); else{ $priceTmp = $order->total_shipping / (1 + (intval($res->rate) * 0.01)); $storeAllTaxes[$res->id]['amount'] += $order->total_shipping - $priceTmp; } 3. original code: Db::getInstance()->Execute(' INSERT INTO '.DB_PREFIX.'order_tax (id_order, tax_name, tax_rate, amount) VALUES ('.(int)$order->id.', \''.pSQL($t['name']).'\', '.(float)($t['rate']).', '.(float)$t['amount'].')'); 3. fixed code: Db::getInstance()->Execute(' INSERT INTO '.DB_PREFIX.'order_tax (id_order, tax_name, tax_rate, amount) VALUES ('.(int)$order->id.', \''.pSQL($t['name']).'\', \''.(float)($t['rate']).'\', '.(float)Tools::ps_round($t['amount'],2).')'); Link to comment Share on other sites More sharing options...
R Santos Posted January 25, 2013 Share Posted January 25, 2013 Hello there, Is this calculation came ok for you? On mine is 2 pences difference? using V 1.4.8.2 Let me know if you got the solution? Thank you Link to comment Share on other sites More sharing options...
g0nzo Posted May 12, 2013 Share Posted May 12, 2013 In 1.4.7.3 it's not a rounding issue - its an actual logic issue when calculating provincial tax. There are 2 different if/else blocks that deal with the $nTax variable. I removed both blocks and only use the calculation under the original if() statement to properly calculate taxes on products/shipping in Canada/US. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now