GoverT:
Hello frank18,
You did adjust the Tax decimal places in Admim-store to 2?
No, changing the tax decimals only changes the padding in the display of the tax amount. Eg, you set the tax decimals to '0' then the customer is presented with say 10%, now set the tax decimals to '2' then the customer sees 10.00% on the invoice. You can test this by loading an existing invoice in admin, don't close the tab in your browser, then change the tax decimals from '2' to '0' or whatever. Next you reload the invoice in the browser and you see the padding change. But, it has no influence on the underlying code calculations.
I reverted back to my own suggestions as per post #14 but made one additional change in includes/classes/order.php (code starts around line 449):
$taxRates = zen_get_multiple_tax_rates($products[$i]['tax_class_id'], $taxCountryId, $taxZoneId);
$this->products[$index] = array('qty' => $products[$i]['quantity'],
'name' => $products[$i]['name'],
'model' => $products[$i]['model'],
'tax_groups'=>$taxRates,
'tax_description' => zen_get_tax_description($products[$i]['tax_class_id'], $taxCountryId, $taxZoneId),
'price' => $products[$i]['price'],
//'final_price' => zen_round($products[$i]['price'] + $_SESSION['cart']->attributes_price($products[$i]['id']), $decimals),
'final_price' => zen_round($products[$i]['price'] + $_SESSION['cart']->attributes_price($products[$i]['id']), 4), // changed to 4 decimals for rounding calcs -- frank18
'onetime_charges' => $_SESSION['cart']->attributes_price_onetime_charges($products[$i]['id'], $products[$i]['quantity']),
'weight' => $products[$i]['weight'],
'products_priced_by_attribute' => $products[$i]['products_priced_by_attribute'],
'product_is_free' => $products[$i]['product_is_free'],
'products_discount_type' => $products[$i]['products_discount_type'],
'products_discount_type_from' => $products[$i]['products_discount_type_from'],
'id' => $products[$i]['id'],
'rowClass' => $rowClass);
Next I did tests with
- a tax free product
- a product on sale (special price)
- a product with quantity discounts (attributes)
all with varying quantities in the cart
Every single scenario showed up correct in the cart, the checkout pages, the final order and in the invoice, there were no rounding errors at all no matter which scenario I chose.
I will leave it at that until someone can come up with a more elegant (and thoroughly tested) solution.
NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.