patzly / grocy-android

ERP beyond your fridge, now on your phone – An awesome companion app for grocy
https://patrickzedler.com/grocy/
GNU General Public License v3.0
830 stars 80 forks source link

Decimal places for display used for quantity unit conversion instead of input. #778

Closed Dreytac closed 9 months ago

Dreytac commented 10 months ago

This is somewhat related to #459 from last year.

I've started using the app again and noticed that when purchasing products, if the purchase unit is different to the stock unit, the price is not calculated correctly.

It seems the conversion between units is using the stock_decimal_places_prices_display setting instead of the stock_decimal_places_prices_input setting. This means that even though I can enter a price up-to X decimals on input, it will get converted to the display setting when being purchased.

For a specific example, if I set the input setting to 6 places and the display setting to 2 places, with a conversion between purchase and stock units of 3000 (3ltr purchase to 3000ml stock for instance) and a price of $4.50, it means it will be saved as $0.00 as the conversion is $0.0015 per stock unit. If I change the display setting to 6 places as well, it's saved correctly but, obviously, now all my prices are displayed with 6 decimal places. I hope that makes sense.

Entering the purchase via the website works as intended with the 6 input and 2 display settings.

Grocy: v4.0.3 App: v3.3.2

dominiczedler commented 9 months ago

You are right, there was a wrong line in the code. Thanks!