From a646f2c6bde512969448595fe7a92a20d3dcbd76 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Sun, 3 Jan 2021 22:40:33 +0100 Subject: [PATCH] Fixed included recipe missing amount resolving (references #1252) --- controllers/RecipesController.php | 4 +++- views/recipes.blade.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/controllers/RecipesController.php b/controllers/RecipesController.php index 86aae02f..d882aa82 100644 --- a/controllers/RecipesController.php +++ b/controllers/RecipesController.php @@ -115,7 +115,9 @@ class RecipesController extends BaseController { if ($id != $selectedRecipe->id) { - $pos->recipe_amount = $this->getDatabase()->recipes_pos_resolved()->where('recipe_id = :1 AND recipe_pos_id = :2 AND is_nested_recipe_pos = 1', $selectedRecipe->id, $pos->recipe_pos_id)->fetch()->recipe_amount; + $pos2 = $this->getDatabase()->recipes_pos_resolved()->where('recipe_id = :1 AND recipe_pos_id = :2 AND is_nested_recipe_pos = 1', $selectedRecipe->id, $pos->recipe_pos_id)->fetch(); + $pos->recipe_amount = $pos2->recipe_amount; + $pos->missing_amount = $pos2->recipe_amount; } } } diff --git a/views/recipes.blade.php b/views/recipes.blade.php index 90d0631e..48f04547 100644 --- a/views/recipes.blade.php +++ b/views/recipes.blade.php @@ -411,7 +411,7 @@ {{ $__n($selectedRecipePosition->recipe_amount, FindObjectInArrayByPropertyValue($quantityUnits, 'id', $selectedRecipePosition->qu_id)->name, FindObjectInArrayByPropertyValue($quantityUnits, 'id', $selectedRecipePosition->qu_id)->name_plural) }} {{ FindObjectInArrayByPropertyValue($products, 'id', $selectedRecipePosition->product_id)->name }} @if(GROCY_FEATURE_FLAG_STOCK) @if($selectedRecipePosition->need_fulfilled == 1)@elseif($selectedRecipePosition->need_fulfilled_with_shopping_list == 1)@else@endif - @if(FindObjectInArrayByPropertyValue($recipePositionsResolved, 'recipe_pos_id', $selectedRecipePosition->id)->need_fulfilled == 1) {{ $__t('Enough in stock') }} @else {{ $__t('Not enough in stock (not included in costs), %1$s missing, %2$s already on shopping list', round(FindObjectInArrayByPropertyValue($recipePositionsResolved, 'recipe_pos_id', $selectedRecipePosition->id)->missing_amount, 2), round(FindObjectInArrayByPropertyValue($recipePositionsResolved, 'recipe_pos_id', $selectedRecipePosition->id)->amount_on_shopping_list, 2)) }} @endif + @if(FindObjectInArrayByPropertyValue($recipePositionsResolved, 'recipe_pos_id', $selectedRecipePosition->id)->need_fulfilled == 1) {{ $__t('Enough in stock') }} @else {{ $__t('Not enough in stock (not included in costs), %1$s missing, %2$s already on shopping list', round($selectedRecipePosition->missing_amount, 2), round($selectedRecipePosition->amount_on_shopping_list, 2)) }} @endif @endif @if($selectedRecipePosition->need_fulfilled == 1 && GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) {{ $selectedRecipePosition->costs }} @endif {{ $selectedRecipePosition->calories }} {{ $__t('Calories') }}