diff --git a/changelog/77_UNRELEASED_xxxx-xx-xx.md b/changelog/77_UNRELEASED_xxxx-xx-xx.md index 5d6ed7f3..0a5dd6a4 100644 --- a/changelog/77_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/77_UNRELEASED_xxxx-xx-xx.md @@ -30,6 +30,7 @@ ### Recipes +- Optimized that when adding missing recipe ingredients with the option "Only check if any amount is in stock" enabled to the shopping list and when no corresponding unit conversion exists, the amount/unit is now taken "as is" (as defined in the recipe ingredient) into the created shopping list item - Fixed that calories/costs of recipe ingredients were wrong when the ingredient option "Only check if any amount is in stock" was set and the on the ingredient used quantity unit was different from the product's QU stock - Fixed that multi-nested recipes (at least 3 levels of "included recipes") resulted in wrong amounts/costs/calories calculated for the ingredients orginating in those nested recipes (also affected the meal plan) diff --git a/services/RecipesService.php b/services/RecipesService.php index 230d6d9b..4e2b36c4 100644 --- a/services/RecipesService.php +++ b/services/RecipesService.php @@ -27,6 +27,7 @@ class RecipesService extends BaseService { $product = $this->getDataBase()->products($recipePosition->product_id); $toOrderAmount = round(($recipePosition->missing_amount - $recipePosition->amount_on_shopping_list), 2); + $quId = $product->qu_id_stock; if ($recipe->not_check_shoppinglist == 1) { @@ -43,6 +44,11 @@ class RecipesService extends BaseService { $toOrderAmount = $toOrderAmount * $conversion->factor; } + else + { + $quId = $recipePosition->qu_id; + $toOrderAmount = $recipePosition->missing_amount; + } } if ($toOrderAmount > 0) @@ -56,6 +62,7 @@ class RecipesService extends BaseService $shoppinglistRow = $this->getDataBase()->shopping_list()->createRow([ 'product_id' => $recipePosition->product_id, 'amount' => $toOrderAmount, + 'qu_id' => $quId, 'note' => $note ]); $shoppinglistRow->save();