Brewtarget / brewtarget

Main brewtarget source code repository.
GNU General Public License v3.0
313 stars 134 forks source link

Yeast inventory unit locked to kg #407

Open MedicMomcilo opened 6 years ago

MedicMomcilo commented 6 years ago

When using "Amount is weight" for yeast, inventory units are locked to kilograms. This wouldn't be that big of an issue, but this field also doesn't support decimals making it unusable. Even manually specifying units (e.g. grams) is removed from the field and value is reset to 0.

This has been tested against develop branch.

Please let me know if I can provide more information.

jonte commented 6 years ago

Hi @MedicMomcilo,

I'm trying to replicate this to see if I could fix it, but I can't seem to replicate the issue.. Can you please provide a picture? Could you also describe your steps in detail (so I can replicate exactly your keystrokes/clicks)?

This is how it looks on my side in the yeast inventory. I created a new yeast, checked the "Amount is weight" checkbox, and set the weight to 10.5g.

screenshot from 2018-05-03 20-12-48

I am using e5bbacec3200918f55dadc168e41ea1fa8b45a83 (HEAD on develop right now)

MedicMomcilo commented 6 years ago

Hi @jonte

I am sorry, now that I re-read what I explained it really isn't clear. Specifically, I am talking about "Quanta in Inventory" field, not the "Default Amount" field.

Try setting some values there and you should quickly see what I'm getting at.

Let's say you have 50g of Yeast and you want to track its usage. You enter "50" in Quanta in Inventory, hit OK and it gets translated to 50 kg. Then you open it again and enter "50 g", hit OK and it gets reset to 0. So, next obvious step is "if I can't use grams, I'll use kilograms" and you enter "0.05", hit OK and it gets reset to 0. Your final try is to set it to "0.05 kg", hit OK and it still gets reset to 0.

In the end you give up and set it to 50 kg and keep in mind that it's kg, not g, and that you have to adjust it manually :slightly_smiling_face:

Also, due to another bug (#396), "Brew It!" doesn't deduct the ingredients at all. But that seems like a different story.

This bug, however, seems like easy to fix, but I may be mistaken (I'm not so much of a developer).

jonte commented 6 years ago

Hi,

Ah, now I see the issue. Thanks for explaining it. The way I am reading the "Quanta in inventory" field is "Number of packages in inventory", where a packet could be assumed to be either a dry yeast satchel or a liquid yeast vial (depending on whether this is a dry yeast or not).

I suppose this is not very useful at all when you're cultivating your own yeasts, in which case you may have non-standard amounts.

How are you using this field? Would it work for you to enter the number of packets you have in inventory instead (assuming you don't save partial packages)? For those cultivating their own yeast, I think the yeast inventory needs to be improved.. Maybe quanta could be expanded to weights, volumes and number of packets, in which case this may be related to #383.

MedicMomcilo commented 6 years ago

Hi @jonte

Unfortunately, it doesn't use packets as units as well. You can confirm this by trying to do a printout of inventory.

You would see that is's noted as 50 kg.

And, since inventory deducting isn't working, there is no actual way to do a test and confirm.

If it were using packets, workaround would be simple: define size of a packet as 1 unit (g, ml, ...) and just add as many to inventory as needed to match the total in inventory.

This field just needs to be exactly the same as all other inventory fields (which do support volume and weight).

matty0ung commented 3 years ago

I see this is still a problem. It certainly seems confusing in the code that for yeast we break the pattern of other "things that can be in inventory" and change "amount" to "quanta". I just never hear the word "quanta" in everyday speech, and I always have to stop and think "what are we getting at here"? (AIUI, there's some cleverness that quanta is the plural of quantum which means quantity or amount so maybe quanta means quantities or amounts, and maybe quantities are packets and amounts are weights or volumes, or something. But it always makes my head hurt.)

Should we either treat amounts of yeast the same as other ingredients (ie it can be weight or volume), or add some specific logic for dealing with packets?

mikfire commented 3 years ago

That was a long conversation I stayed out of. I see some of the original idea.

If one believes that an object in an object oriented language should represent a real physical object, there is a solid question of what does 1.192 packets of yeast mean?

Did you know that rocketman has a PhD in physics? I am willing to bet he did use quanta in everyday speech.

I've also mentioned I don't use the inventory system at all. If you can come up with a reasonable fix, go for it.

matty0ung commented 3 years ago

Ha, that makes sense rocketman is a physicist and therefore does not find quanta an unusual word! :smile:

I will have a think about this. You're right that, where things are countable rather than measurable (by weight or volume), it would be natural to use integers rather than arbitrary decimals. At the same time, I'm thinking about another issue where someone proposed something similar for Miscs so they could have number of oak spirals or cinnamon sticks etc, and then I don't know if you start thinking about halves and quarters of things. Maybe we'd store "number of" as decimal (well, double, but you know what I mean) and then have something else about what the smallest meaningful fraction is. But would be nice to do a generic solution.