News:

Looking for documentation? Take a look on our wiki

Main Menu

Rounded prices - how?

Started by lausianne, February 28, 2018, 16:13:36 PM

Previous topic - Next topic

lausianne

This has been discussed many times and I spent hours googling and trying all "solutions" I found, but got nowhere. So I hope someone here has a real solution to this seemingly basic problem:

I need all prices to appear rounded to a full number. No matter what currency or discounts. Always round.

Thank you!

lausianne

Oh, I got it, finally, and it was not so hard:

Configuration > Configuration > Currencies > [your currency]

Set decimals to 0
Add .00 to formats

lausianne

Still a problem with rounding, though:

Displayed:
Base price: 18.10
Total for 2 units: 36.10

But ... 18.10 x 2 = 36.20

There is no mathematical error, it just looks wrong, because the actual unit price is 18.05, rounded up in display.
The base price should therefore be displayed rounded to .05 instead of .1 - How?

Jörgen

Check under configuration-> prices, there You have settings for rounding of display or not.

regards

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

lausianne

#4
Hello Jörgen,

Thanks for coming in and trying to help. Yes, this is one of the many settings I changed back and forth. I wish it was that simple, but once I tried this setting, it made things worse. Now I tried again, and see no difference.

Another example:
Base price:€16.20
2 units => Total without tax: €32.30

If I display all decimals, I see that the calculations are correct. But I cannot show those numbers on the product page.

What I also found is that it is all good with the default currency, $. But switching to any other currency, I get these rounding issues.
Any idea? Thank you!

Regards,
Ralf

EDIT: What I think should happen, is that the total price is simply the base price as displayed multiplied by the number of units.
It would be slightly less correct, mathematically, if all discounts and exchange rates are taken into account, but who cares - as log as what is displayed makes sense.

Jörgen

Hello, i agree that the displayed values are the ones that should add up. It should work the same with all currencies, maybe the setting for the decimals for the currency under currencies could control this.
Regards
Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

lausianne

I wish it could. But it doesn't. Maybe something in the currency conversion needs to be changed. I saw Max Milbers name in there, maybe he would know.
It seems unlikely that I am the first one having this issue. But I wouldn't know what could be special about my shop.

lausianne

Definitely a bug, in my opinion:

Clean new install of Joomla 3.8.6, VM 3.2.12.9708

I deactivated all rules (tax, discount) and rounded to 1 decimal.

Screenshot: https://cl.ly/qV2e
... 12.50 x 10 = 124.50

"Round only display" on/off makes no difference.

Milbo

Quote from: lausianne on March 27, 2018, 15:28:44 PM
The base price should therefore be displayed rounded to .05 instead of .1 - How?

For that we have the "Rappenrundung" mode. Do all your changes in the vm config first. You can later adjust them per currency.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Milbo

Quote from: lausianne on March 27, 2018, 19:40:10 PM
Another example:
Base price:€16.20
2 units => Total without tax: €32.30

If I display all decimals, I see that the calculations are correct. But I cannot show those numbers on the product page.

Why you cannot show it on the product page?

Quote from: lausianne on March 27, 2018, 19:40:10 PM
What I also found is that it is all good with the default currency, $. But switching to any other currency, I get these rounding issues.
Any idea? Thank you!
As just written to your other comment. You have in VM most time a common and a specific setting. So go first to the vm config and change the options there.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Milbo

Quote from: lausianne on March 28, 2018, 19:39:38 PM
Definitely a bug, in my opinion:

Clean new install of Joomla 3.8.6, VM 3.2.12.9708

I deactivated all rules (tax, discount) and rounded to 1 decimal.

Screenshot: https://cl.ly/qV2e
... 12.50 x 10 = 124.50

looks like rounded to 2 decimals. And I have no clue about your other settings, which you are maybe not aware of.

Quote from: lausianne on March 28, 2018, 19:39:38 PM
"Round only display" on/off makes no difference.

It should solve your first case. Just think about the screw example. You buy 1000 screws for 1 cent each, plus vat. One screw would have in germany 0.19 cent vat => 0.0 Vat. But not 1000 screws. For this we have the "round only display", should be disabled for your case.

You need Rappenrounding activated and "round only display" disabled.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

lausianne

Hello Milbo,

Thanks for your comments.

>> ... 12.50 x 10 = 124.50
> looks like rounded to 2 decimals. And I have no clue about your other settings, which you are maybe not aware of.

This: >>"Clean new install of Joomla 3.8.6, VM 3.2.12.9708 / I deactivated all rules (tax, discount) and rounded to 1 decimal."

This is literally all I have done and set (as far as I remember, using default demo data). Single currency. I have (on my shop under development) tried all settings I could think of and that I have found mentioned in the forum and documentation, the results are always the same. "Rappenrundung", "Round on display" ... no difference. VAT is not relevant for the problem.

>> What I also found is that it is all good with the default currency

I was wrong about that. I only did not see the issue, because the prices in the default currency are already rounded to 1 decimal, so additional rounding makes no difference - unless you add discounts and/or VAT.

> Why you cannot show it on the product page?

Because it is wrong. 12.50 x 10 = 125.00, not 124.50. Customers don't care about the mathematics behind these numbers, they will just be confused. Most won't notice or won't care. But my client noticed and cares.
I have looked through the source code, but couldn't figure it out myself, unfortunately. I don't see why the total price cannot be calculated by rounded base price times number of units rather than however it is done currently.
If only the base price is affected by any modifications and rounded afterwards, the total will then always be correct automatically. Whatever is set in the backend, numbers should always add up in the frontend, IMHO.


Jörgen

Rounding to 1 decimal and showing 2 for display gives this side effect. Seems not to be rounded for the total sum.
Regards
Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

lausianne

#13
Thanks, Jörgen. What would I have to set how, to get it right?

I went back to the clean test shop. And now I discovered something completely new to me, my bad: I found that rounding digits can be set for each individual kind of price! (seen it a hundred times, never noticed) Wonderful. So I set everything to one digit (was -1 before).
Yet, for the result it again makes no difference: https://cl.ly/qeqB

Interestingly, the price is correct for "Product prices result", only for "Total" it's wrong. (I found this was a coincidence. With other prices this is also wrong.)

Unfortunately, in the official demo, the Configuration is not accessible and currency details cannot be changed. But I'd happily give access to my test site to anyone who wants to try.
Or if you have your own shop: set the price of a product to 12.45 and rounding to 1 decimal. Then buy 10 of them.

EDIT:
Just found this shop: https://demo.joomlapro.com/vmuikit-yootheme-horizon/
Switch currency to $, then buy 10 of any watch, go to cart. Wrong totals.





lausianne

I got into a brief exchange with an extension developer. Eventually he wrote this:

"I've tried it locally out of curiosity and it really seems to be a bug in VM to me. In my cart in VM, the total price is correct if I disable the "Round only display" option in VM, but the subtotal in each line is still incorrect.
Unfortunately, you'll probably need to wait for VM devs to fix it."

So I'm somewhat relieved it's not just me ...