Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Nested recipe on meal plean: Wrong calories/prices/consume amount #2361

Open
berrnd opened this issue Oct 23, 2023 · 5 comments
Open

Bug: Nested recipe on meal plean: Wrong calories/prices/consume amount #2361

berrnd opened this issue Oct 23, 2023 · 5 comments
Labels
Milestone

Comments

@berrnd
Copy link
Member

berrnd commented Oct 23, 2023

Originally reported at https://www.reddit.com/r/grocy/comments/17eujf8

Demo instance: https://test-6yannembxwfbehixjot1v8.demo-prerelease.grocy.info/mealplan?start=2023-10-22

Recipe/ingredients hierarchy:

  • Recipe "Ham sandwich" (Base servings = 1)
    • Ingredient "ham" 25 Grams
    • Included recipe "sandwich" (Base servings = 1, 1 serving per base serving of parent)
      • Ingredient "Toast" 2 Tins
      • Ingredient "Tomato" 0.25 Pieces

So when consuming 1 serving of "Ham sandwich" the expectation is that this products will be consumed:

  • 25 Grams "ham"
  • 2 Tins "Toast"
  • 0.25 Pieces "Tomato"

=> ✅ That's the case, regardless of if consuming from the /recipes or /mealplan page.

When consuming 2 servings of "Ham sandwich" the expectation is that this products this will be consumed:

  • 50 Grams "ham"
  • 4 Tins "Toast"
  • 0.5 Pieces "Tomato"

=> ✅ That works when consuming from the /recipes page.

=> ❌ When consuming from the /mealplan page the amount of the nested recipe ("sandwich") ingredients are related to 1 serving only (and this then also affects calories and price calculations).

@berrnd berrnd added the bug label Oct 23, 2023
@berrnd berrnd added this to the vNEXT milestone Oct 23, 2023
@puckettgw

This comment was marked as off-topic.

@berrnd

This comment was marked as off-topic.

@puckettgw
Copy link

puckettgw commented Nov 16, 2023

Thanks, I think I found where the logic error is (although I don't have it in code yet)

Basically, if a recipe is created with an item before a QU conversion is in place, it will not properly update that recipe when the QU conversion is added, unless the offending ingredient is removed and re-added to the recipe. So I removed bacon from the recipe in my example, re-added it, and now it's calculating properly.

@berrnd
Copy link
Member Author

berrnd commented Nov 16, 2023

if a recipe is created with an item before a QU conversion is in place, it will not properly update that recipe when the QU conversion is added

Still needs a reproducible example and I doubt it, QU conversions (and everything else) are of course always taken / calculated "live", nothing is saved at recipe level based on the state of that point in time when the recipe or an ingredient was created/added (would make not that much sense).

@berrnd berrnd modified the milestones: v4.1.0, vNEXT Feb 8, 2024
@berrnd berrnd modified the milestones: v4.2.0, vNEXT Mar 15, 2024
@Mulvdev
Copy link

Mulvdev commented Apr 11, 2024

Sorry, I did not have time to test more. I found that if you add another layer to the nested recipe, only the first two layers are in the calculations in the Meal plan. For that, I added Ham Cheese Sandwich, which is the recipe for Ham Sandwich (which is the recipe for Sandwich + the ingredient Ham) + the ingredient Cheese. In the recipe overview, the calculations are correct, but in the Meal plan, only the ingredients from layers 1. and 2. are in the calculations; the "sandwich" part is missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants