News:

Looking for documentation? Take a look on our wiki

Main Menu

Decimals used for calculation - rounding

Started by JacoboPS, April 07, 2016, 14:36:33 PM

Previous topic - Next topic

JacoboPS

Hello everyone,

(How many decimals uses VM for totals, subtotals, tax... calculation?)

I sell many small items, with decimals, and I need to force VM to use 3 decimals for calculation, not 2 (for calculation, I show only 2 decimals, but I need the system internally to use 3 for the price rounding).

Example:

If someone buys 4 units, calculation should be:

2,45 x 10% = 0,245 €
2,45 x 10% = 0,245 €
2,45 x 10% = 0,245 €
2,45 x 10% = 0,245 €

            VAT = 0,98 €

And now it is:

2,45 x 10% = 0,25 €
2,45 x 10% = 0,25 €
2,45 x 10% = 0,25 €
2,45 x 10% = 0,25 €

            VAT = 1 €

So I need to force VM to use 3 decimals on calculation or to make the rounding on the total.

Thank you very much for any help,
Learning, pulling hair out, learning...

ClaudioRomeo

Configuration -> Configuration -> Pricing -> Rounding Digits
I'm the author of the VirtueMart 3 Reference Guide
https://www.virtuemartmatters.com

JacoboPS

Thank you ClaudioRomeo. I saw that but I am not sure how to use that.

In all those fields I have "-1". What number should I enter on those fields to "use" -not to show- three or four decimals.

(I am aware of this thread:  http://forum.virtuemart.net/index.php?topic=108809.msg367089#msg367089)
Learning, pulling hair out, learning...

ClaudioRomeo

OK, JacoboPS...
I didn't know the discussion you referred to, and now I'm scared as well.
Moreover, I didn't know the difference (if any) between showing and using decimals.
If you put 3 in the box, VirtueMart show three decimals, and I thought it also used three decimals for calculation.
What if you put 3 or 4 in the decimals boxes? Can you run some tests and let us know?
I'm the author of the VirtueMart 3 Reference Guide
https://www.virtuemartmatters.com

Studio 42

Hi,
showing > how much to display
using >how much to round on calculation.

ClaudioRomeo

Thank you, Studio 42.
But my question was is the difference in a practical way.
If I set 3 decimals for viewing, how many decimals does VirtueMart use for calculating prices?
Is there a difference between the number of decimals set and the number of decimals actually used by VirtueMart?
I'm the author of the VirtueMart 3 Reference Guide
https://www.virtuemartmatters.com

Studio 42

The displayed price do not change the calculation(as i know).

ClaudioRomeo

If you are right, JacoboPS is then in trouble.  :(
How can he set the decimals used for calculation?
I'm the author of the VirtueMart 3 Reference Guide
https://www.virtuemartmatters.com

Studio 42

No, it's right what he said.
If you round to 2 digit, all is calculated wiht 2 digits.
Quote from: JacoboPS on April 07, 2016, 14:36:33 PM
So I need to force VM to use 3 decimals on calculation or to make the rounding on the total.

If you round display :
0.245 displayed  0.25 but internally 0.245 is used for calculation.
so on rounding calculation to 3 digit : 0.245 + 0.245  + 0.245  + 0.245  = 0.980 displayed 0.98 because display is set to 2 digits
If you round to 2 digit :0.25 + 0.25 + 0.25 + 0.25 = 1.00

So i think, he don't have not understand how it work, but the calculation and display is right ;)

Some need 4 or 5 digit but need to round display and total, because they sold Gold, but on pay you cannot accept mostly only 2 digits.
So, the choice is to loose  or win some little money or have exact display but trouble the customer.

Best for me is to use 2 digits for all. So you have no trouble, but of course you have then some rounding problem(but this is the case for real shops to)

JacoboPS

Don't move!!! I got it!!!!

On the Virtuemart -> configuration -> Pricing there is a check option "Round only display", with an information really interesting and clarifying...

"We advice to use this option. The rounding is only done on the display, the results are more accurate."

So, that simple, that obvious....  :-[ :-[

Thank you very much anyway, Studio 42 and ClaudioRomeo.
Learning, pulling hair out, learning...