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
879 stars 85 forks source link

App uses wrong unit type and/or amount when scanning a product #721

Closed SirFlobo closed 1 year ago

SirFlobo commented 1 year ago

I've tested the bug on both the play store version and the nightly build and it was present in both.

My setup is the following:

Quantity units

  1. Pack (default type from install)
  2. Piece (default type from install)
  3. Custom

Products

Product name Buy unit Stock unit Ratio buy -> stock
Bread Pack Piece 16
Soda Piece Custom 42[^1]

[^1]: When initially setting up this product using the grocy app the ratio was set as 1:1 and was later changed in the grocy web ui.

The issue/ bug

In the table below I've written down the behaviour for buying/consuming products using manual entry of the name and using the barcode scanner. I've marked in bold which cells don't correspond to my expected result.

product type method selected unit selected amoun expected unit
bread buy manual Pack empty Pacl
bread buy scan Pack 16 Pack
bread consume manual Piece 1 Piece
bread consume scan Pack 16 Piece
soda buy manual Piece empty Piece
soda buy scan Piece 1 Piece
soda consume manual Custom 1 Custom
soda consume scan Piece 1 Custom

Software

Play Store: V3.2.1 Nightly version: Grocy-Android-master-20230613.apk Grocy version: 3.3.2 (Docker)

dominiczedler commented 1 year ago

Thanks for the detailed report, I will look into it!

SirFlobo commented 1 year ago

Hi, It looks like the app is behaving as intended and I just didn't realise. I was using barcode buddy to add the products to my grocy server and it seems with the settings I was using it would add the buy unit and the conversion rate as quantity to the barcode. So when the app read the barcode it saw those values and used them, as should happen.

I didn't realise this since this is my first time using grocy and barcode buddy.

When I add a barcode with no unit and no quantity, the app behaves as I expect. The buy unit when buying and the stock unit when consuming.

What I did notice though is that when I add a new product using grocy android, it adds the buy unit to the barcode. This causes the barcode to always use the buy unit when scanning it, even when consuming. I'm not sure if this is the intended behaviour, since it messes up the internal unit selection. Alternatively make it a setting which can enabled or disabled.

Should I make a seperate issue for this or should I just rename this issue?

Anyway, sorry for reporting wrongly reporting a bug. 😔

dominiczedler commented 1 year ago

Oh okay, thanks for your reply. :) Don't worry.

Regarding your question: I just tested it with the server and the barcode unit is always chosen (purchase and consume). But this makes sense I think: You for example buy a pack of eggs with the barcode for "pack" and if you scan it in the consume mode, you also want to consume the whole "pack"... The single eggs are another unit.

I think this is intended behavior. You can ask the community on Reddit or if you think this should be improved you can create an issue in the grocy server repo (but search for existing issues first).