diff --git a/changelog/62_UNRELEASED_xxxx-xx-xx.md b/changelog/62_UNRELEASED_xxxx-xx-xx.md index 0cf217ee..64ae1a73 100644 --- a/changelog/62_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/62_UNRELEASED_xxxx-xx-xx.md @@ -52,6 +52,7 @@ ### Recipe improvements/fixes - Recipe printing improvements (thanks @Ape) - Calories are now always displayed per single serving (on the recipe and meal plan page) +- The note of an ingredient will now also be added to the corresponding shopping list item when using "Put missing products on the shopping list" - Fixed that "Only check if any amount is in stock" (recipe ingredient option) didn't work for stock amounts < 1 - Fixed that when adding missing items to the shopping list, on the popup deselected items got also added - Fixed that the amount of self produced products with tare weight handling enabled was wrong ("Produces product" recipe option) diff --git a/services/RecipesService.php b/services/RecipesService.php index 4dd38496..249e7a42 100644 --- a/services/RecipesService.php +++ b/services/RecipesService.php @@ -15,7 +15,6 @@ class RecipesService extends BaseService public function AddNotFulfilledProductsToShoppingList($recipeId, $excludedProductIds = null) { $recipe = $this->getDataBase()->recipes($recipeId); - $recipePositions = $this->GetRecipesPosResolved(); foreach ($recipePositions as $recipePosition) @@ -23,7 +22,6 @@ class RecipesService extends BaseService if ($recipePosition->recipe_id == $recipeId && !in_array($recipePosition->product_id, $excludedProductIds)) { $product = $this->getDataBase()->products($recipePosition->product_id); - $toOrderAmount = round(($recipePosition->missing_amount - $recipePosition->amount_on_shopping_list), 2); if ($recipe->not_check_shoppinglist == 1) @@ -33,10 +31,16 @@ class RecipesService extends BaseService if ($toOrderAmount > 0) { + $note = $this->getLocalizationService()->__t('Added for recipe %s', $recipe->name); + if (!empty($recipePosition->note)) + { + $note .= "\n" . $recipePosition->note; + } + $shoppinglistRow = $this->getDataBase()->shopping_list()->createRow([ 'product_id' => $recipePosition->product_id, 'amount' => $toOrderAmount, - 'note' => $this->getLocalizationService()->__t('Added for recipe %s', $recipe->name) + 'note' => $note ]); $shoppinglistRow->save(); }