supergeorg / Grocy-SwiftUI

A client for Grocy for macOS and iOS, written with SwiftUI
GNU General Public License v3.0
181 stars 18 forks source link

Stock Quantity/ Factoring Issue #147

Open JMillwood-92 opened 1 year ago

JMillwood-92 commented 1 year ago

I have noticed that the Purchase stock factoring works exactly as expected, but that the stock factoring for Consume and Transfer within the app are not following the expected behaviour.

As an example, I have Bread as a product, with; Quantity Unit Stock: Slice Default Quantity Unit Purchase: Loaf

And, a factor purchase to stock quantity of: 16. Which shows in the app as "1 Loaf purchased will be converted to 16 slices in stock"

Purchasing shows this conversion correctly: image

(*Although, it's not possible to purchase in slices (drop-down greyed out)).

But, Consume and Transfer also multiply slices by the factor purchase stock quantity: image

Obviously I'm trying to consume 1 slices as selected. Loaf isn't an option on the dropdown so can't check if this would change the behaviour.

Is this likely to be something I've setup wrong?, or is this a bug?

I am planning to download the source code for the iOS app at some point and see if I can work out the issue myself, but thought here might be a good starting place, before I wade too far in.

supergeorg commented 1 year ago

Well, I tried to reproduce it.

With the demo server and the newest app version, I purchased a load of bread, consisting of 16 slices. A selection of a single slice was also possible. image

Then I tried to consume a single slice, this also worked correctly. image

So I would try to spot this error in an incorrect conversion. Mine looks like this: image

Are you using the newest 2.7.2 app and 3.3.2 server? I can't reproduce this issue.

JMillwood-92 commented 1 year ago

Hi, thanks for your reply.

Yes I can confirm I am using server version 3.3.2 and app version 2.7.2. Server is running on HomeAssistant via Ingress.

How strange, I am unfortunately still seeing this behaviour, I've even created my slice, loaf and bread products again, and added a conversion unit to the loaf and slice entries rather than just defining the default purchase unit.

But then I also see behaviour where the default purchase location isn't automatically populated from the product or the barcodes setting.

I've tried this on the demo server too and the same behaviour presents.

I have however discovered that despite the descriptor telling me it will subtract 16 slices it actually only reduces the stock quantity by the number of slices entered on both the demo and the live servers.

I'll try deleting the iOS app and re-downloading.

Thanks for your work on the app soo far, the integration of OpenFood facts alone makes Grocy so much more usable!

MAXimized490 commented 1 year ago

I am experiencing this issue as well but the behavior is also present on my consume screen. Reinstalling the app does not fix this issue. Grocy 3.3.2 App 2.7.2 Device iPhone 6S

belgianrubs commented 1 year ago

Hi @supergeorg, first of all: thank you for this awesome app! I'm having the same error as @JMillwood-92 has. I'm not sure, but I think you're trying to reproduce this error by going into Master Data > Quantity Units, right? Because that's not how I am doing my conversions currently. I'm going to Master Data > Products, click the product > Quantity units and than select the Quantity unit stock and set it in this case to "Slice", Default quantity unit purchase to "Bread". Next I'm going into Amounts and change the "Factor purchase to stock quantity unit" to how many Slices a Bread corresponds. This way I am able to reproduce the issue, hope this helps!

JMillwood-92 commented 1 year ago

This is still an issue, for me too, and I started looking at it, however I have abandoned looking to fix it due to the planned changes to Grocy.

So from my understanding the factor stock to purchase functionality will be removed in a near future update to Grocy if not gone already, and the unit conversion functionality is the recommended replacement to use in the absence of this feature.

I'm therefore working on changing my stock entries to reflect this.

I haven't checked the app to see if the issue persists with this new way of working yet.

belgianrubs commented 1 year ago

@JMillwood-92 Oh, I wasn't aware of that. Could you be able to link where you've read that? Thank you in advance!

JMillwood-92 commented 1 year ago

Yeah no worries.

It's on the change log at https://grocy.info/changelog and it's listed under the "Preview version (not yet released)" drop down.

Bullet point 2 on the changes to "Stock".

image