VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: mblokdijk on July 23, 2024, 09:54:41 AM

Title: price calculation adds 1 cent each time, i cannot fix
Post by: mblokdijk on July 23, 2024, 09:54:41 AM
i have a selling price of 35 euro (including tax)
tax: 21%
i use the option calculate cost price
click save, and the eventual price is 35.01
i have no option to change. it taxes on the base price, which has 2 digits. the costprice has 4 digits. if it taxed on the costprice it would be fine.
how can i change this?
J4 and VM4
Title: Re: price calculation adds 1 cent each time, i cannot fix
Post by: mblokdijk on July 24, 2024, 19:14:47 PM
anyone?? how can this be an issue? really? its a basic feature....
Title: Re: price calculation adds 1 cent each time, i cannot fix
Post by: Jumbo! on July 25, 2024, 23:51:13 PM
Quote from: mblokdijk on July 23, 2024, 09:54:41 AMi have a selling price of 35 euro (including tax)
tax: 21%
i use the option calculate cost price
click save, and the eventual price is 35.01
i have no option to change. it taxes on the base price, which has 2 digits. the costprice has 4 digits. if it taxed on the costprice it would be fine.
how can i change this?
J4 and VM4

It seems to be functioning well in my tests. Watch the video I recorded during the test. You can find it here: https://www.youtube.com/watch?v=sofYXwsFV60.
Title: Re: price calculation adds 1 cent each time, i cannot fix
Post by: iWim on July 26, 2024, 13:45:23 PM
I can confirm both.

On an existing site (J5) the baseprice is limited to 2 decimals and rounded up.
While on a test site with a new installation of VM the baseprice has 5 decimals.

The existing site is an oldie, updated all the way from J1/VM1.
Title: Re: price calculation adds 1 cent each time, i cannot fix
Post by: mblokdijk on August 04, 2024, 20:06:30 PM
same here...
i have no option to change. it taxes on the base price, which has 2 digits. the costprice has 4 digits. if it taxed on the costprice it would be fine.
Title: Re: price calculation adds 1 cent each time, i cannot fix
Post by: mblokdijk on August 08, 2024, 15:27:58 PM
how to fix this issue??
Title: Re: price calculation adds 1 cent each time, i cannot fix
Post by: hazael on August 09, 2024, 10:53:56 AM
why are you one cent short? it's simple :)

product price in the admin panel before rounding:
0,333 + 0,333 + 0,333 = 0,999 ~ 1,00 EUR

product price in the frontapage after rounding 0,333 ~ 0,33 EUR
0,33 + 0,33 + 0,33  = 0,99 ~ 0,99 EUR

Therefore, try to add full prices to avoid these discrepancies
or...
display products without rounding in Euro cents  ;D
or...
wait another decade until Milbo solves this problem on his own  ;)

PS.
Do these 5 or 6 decimal places have any justification at all? I have never seen anyone in any store use such precision.
Currency rates are generally quoted with a maximum accuracy of 4 decimal places
Title: Re: price calculation adds 1 cent each time, i cannot fix
Post by: iWim on August 10, 2024, 11:04:41 AM
In the attachment you'l find a screenshot of what mblokdijk means...
Top (incorrect baseprice), bottom (expected baseprice)

The issue is that baseprice is rounded to 2 decimals instead of 5.

With 21% vat:
Currently: 28,93 * 0,21 = 6,0753 ~~> 28,93 + 6,0753 = 35,0053 = 35,01
Should be: 28,92562 * 0,21 = 6,07438 ~~> 28,92562 + 6,07438 = 35,00

I see the same on a shop I manage since VM1 (top).
The problem is I don't see it on a "messy" clean install (bottom).
Title: Re: price calculation adds 1 cent each time, i cannot fix
Post by: mblokdijk on August 21, 2024, 19:01:21 PM
somewhere the code gives 2 decimals. that should be changed...
Title: Re: price calculation adds 1 cent each time, i cannot fix
Post by: Milbo on August 31, 2024, 18:44:22 PM
There is a setting in vm config, where you can say if you round any numbers, or if you round just the final numbers, try the second mode.

Just consider, sell a screw for 1 cent with 20% VAT. So you sell it for 1.2 cent, so for 1 cent. But 100 screws are 1 Dollar/euro. So the tax is here 20 cent. The first mode whould have no tax, because any step is rounded, but the second one has 20 cent tax. But the invoice will look strange, because the single item has not tax.
Title: Re: price calculation adds 1 cent each time, i cannot fix
Post by: mblokdijk on September 02, 2024, 11:18:28 AM
thanks everyon. i have updated to the latest version and now it seems to work. i was on a J4 version from march.
Title: Re: price calculation adds 1 cent each time, i cannot fix
Post by: AH on September 03, 2024, 19:02:46 PM
Thank you for posting as solved