Add recipe ingredient notes to the corresponding shopping list item (closes #1397)

This commit is contained in:
Bernd Bestel 2021-07-06 20:19:50 +02:00
parent 1ead23cb87
commit 633b26bf7e
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
2 changed files with 8 additions and 3 deletions

View File

@ -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)

View File

@ -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();
}