Magento – How to fix rounding issues

rounding

Annoying issue about rounding. I think community knows it. When you use price including tax, discounts and so on you will get 0.01 price difference. I found a solution to rewrite core class with method round($price, 4) and thought it might help. It was working fine, but now I faced with it again. I have a condition for export base_total_invoiced == base_grand_total and this prices are 112.9230 != 112.9200 I can round them also. But it's a dirty fix.

Does anybody know good solution for it?

Best Answer

Not a direct fix to solve your problem, but this should be solved in the CE 1.8 release that is expexted at the end of this month,

From http://www.magentocommerce.com/knowledge-base/entry/ce-18-later-release-notes:

Rounding Error Fixes

The following issues relate to one-cent rounding errors in the web store or shopping cart:

  • Calculating taxes for bundled products with tiered pricing.
  • Calculating the price before customization for bundled products.
  • Calculating the grand total of items added to a cart in a different order.
  • Viewing an order when taxes are calculated after a discount using either row-based or unit price. Applying a discount to an order with a shipping address different than the billing address.
  • Calculating the grand total based on the order in which products are added to the shopping cart. Specifying that prices display in the web store excluding tax and setting a 20% tax rate (or discount rate) now calculates the grand total correctly. It is now possible to have grand totals in amounts like 6.99, 9.99, or 99.99—regardless of the currency units used in the web store.
  • Adding multiple items to a cart does not affect the accuracy with which taxation is calculated.
  • Subtotal (Incl. Tax) is now correct when catalog and shipping prices include tax. Both tax and discounts are applied after tax.
  • Prices displayed in the cart and on the catalog page are consistent and correct when catalog prices include tax, and when items in the catalog are set to display both including and excluding tax. (In the Admin Panel, click System > Configuration > SALES > Tax. In the right pane, expand Calculation Settings.)
  • Error in calculating the Grand Total Excl. Tax was resolved. This error occurred in a specific configuration: tax is applied to FPT, FPT is included in the subtotal, and the customer selects non-taxable flat rate shipping.