Skip to main content
added 1755 characters in body
Source Link
Rajeev K Tomy
  • 17.3k
  • 6
  • 63
  • 103

According to this, we can conclude that, as quantity increases, if we are not adopting this method, it will produce a large difference between rounded value and actual value. But if we use this method, it will make our rounded value as close as possible with the actual value.

Magento by default rounds to two decimal places. This is the method that responsible for two decimal places rounding

Location :app/code/core/Mage/Core/Model/Store.php
public function roundPrice($price)
{
    return round($price, 2);
}

If we set it to 4 or something, we can further increase the accuracy of rounding.

Note : This is my openion and overview. It may or may not be true. However it seems accurate and logical for me.

Note : This is my openion and overview. It may or may not be true. However it seems accurate and logical for me.

According to this, we can conclude that, as quantity increases, if we are not adopting this method, it will produce a large difference between rounded value and actual value. But if we use this method, it will make our rounded value as close as possible with the actual value.

Magento by default rounds to two decimal places. This is the method that responsible for two decimal places rounding

Location :app/code/core/Mage/Core/Model/Store.php
public function roundPrice($price)
{
    return round($price, 2);
}

If we set it to 4 or something, we can further increase the accuracy of rounding.

Note : This is my openion and overview. It may or may not be true. However it seems accurate and logical for me.

added 1755 characters in body
Source Link
Rajeev K Tomy
  • 17.3k
  • 6
  • 63
  • 103

Now let us assume magento is using _deltaRound() method and this function actually rounds product price to two decimal. Along with that it will keep a delta value, which is in fact the difference between actual price and rounded price, will use for calculating rounded price later. Here enter image description hereenter image description here

That means _deltaRound() method actually make tax price rounding more accurate to the actrualactual tax pricing. As you stated this method returns different round value depends upon the delta value. This delta value actually makes tax rounding more accurate.

Now let us assume magento is using _deltaRound() method and this function actually rounds product price to two decimal. Along with that it will keep a delta value, which is in fact the difference between actual price and rounded price, will use for calculating rounded price later. Here enter image description here

That means _deltaRound() method actually make tax price rounding more accurate to the actrual tax pricing. As you stated this method returns different round value depends upon the delta value. This delta value actually makes tax rounding more accurate.

Now let us assume magento is using _deltaRound() method and this function actually rounds product price to two decimal. Along with that it will keep a delta value, which is in fact the difference between actual price and rounded price, will use for calculating rounded price later. Here enter image description here

That means _deltaRound() method actually make tax price rounding more accurate to the actual tax pricing. As you stated this method returns different round value depends upon the delta value. This delta value actually makes tax rounding more accurate.

added 1755 characters in body
Source Link
Rajeev K Tomy
  • 17.3k
  • 6
  • 63
  • 103

EDIT

Let us analyse the use of this function by applying it into a real time example. Suppose I have a product in cart which is taxable. The quantity that I am going to purchase be, 5. After applying tax, the prdouct has a price $10.5356. So this is my situation

CART
-------
   Product A
       - Price (including tax) - 10.5356
       - Quantity              - 5
       - Tax Rule  - Apply tax for each product. Then calculate the total price according to the quantity purchased.

So now let us calculate the real price that is going to produce in this situation. It will be

  Total =  10.5356 x 5 = 52.678

Now let us assume, magento does not using _deltaRound() method. It just rounds product price upto two decimal places and then calculates total price. In this case, product price will get rounded to 10.54 and hence total price would be

  Total = 10.54 x 5 = 52.7

Now let us assume magento is using _deltaRound() method and this function actually rounds product price to two decimal. Along with that it will keep a delta value, which is in fact the difference between actual price and rounded price, will use for calculating rounded price later. Here enter image description here

  Total =  10.54+10.53+10.54+10.53+10.54 = 52.68

That means _deltaRound() method actually make tax price rounding more accurate to the actrual tax pricing. As you stated this method returns different round value depends upon the delta value. This delta value actually makes tax rounding more accurate.

Note : This is my openion and overview. It may or may not be true. However it seems accurate and logical for me.

Thanks.

EDIT

Let us analyse the use of this function by applying it into a real time example. Suppose I have a product in cart which is taxable. The quantity that I am going to purchase be, 5. After applying tax, the prdouct has a price $10.5356. So this is my situation

CART
-------
   Product A
       - Price (including tax) - 10.5356
       - Quantity              - 5
       - Tax Rule  - Apply tax for each product. Then calculate the total price according to the quantity purchased.

So now let us calculate the real price that is going to produce in this situation. It will be

  Total =  10.5356 x 5 = 52.678

Now let us assume, magento does not using _deltaRound() method. It just rounds product price upto two decimal places and then calculates total price. In this case, product price will get rounded to 10.54 and hence total price would be

  Total = 10.54 x 5 = 52.7

Now let us assume magento is using _deltaRound() method and this function actually rounds product price to two decimal. Along with that it will keep a delta value, which is in fact the difference between actual price and rounded price, will use for calculating rounded price later. Here enter image description here

  Total =  10.54+10.53+10.54+10.53+10.54 = 52.68

That means _deltaRound() method actually make tax price rounding more accurate to the actrual tax pricing. As you stated this method returns different round value depends upon the delta value. This delta value actually makes tax rounding more accurate.

Note : This is my openion and overview. It may or may not be true. However it seems accurate and logical for me.

Thanks.

Source Link
Rajeev K Tomy
  • 17.3k
  • 6
  • 63
  • 103
Loading