From f9c7c67dc7f6bec27112e41bc2d2ca86c4853e0b Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Fri, 17 Jan 2025 20:37:43 +0100 Subject: [PATCH] Indicate incomplete recipe costs information (closes #1941) --- changelog/77_UNRELEASED_xxxx-xx-xx.md | 1 + localization/strings.pot | 3 +++ migrations/0247.sql | 21 +++++++++++++++++++++ views/recipes.blade.php | 12 ++++++++++-- 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 migrations/0247.sql diff --git a/changelog/77_UNRELEASED_xxxx-xx-xx.md b/changelog/77_UNRELEASED_xxxx-xx-xx.md index 2ac36214..e85acb05 100644 --- a/changelog/77_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/77_UNRELEASED_xxxx-xx-xx.md @@ -39,6 +39,7 @@ - For in-stock ingredients, the amount actually in-stock is now displayed next to the hint "Enough in stock" - 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 +- When no price information is available for at least one ingredient, a red exclamation mark is now displayed next to the recipe total cost information - 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/localization/strings.pot b/localization/strings.pot index 697da863..34235b3c 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -2452,3 +2452,6 @@ msgstr "" msgid "By default the stock overview page lists all products which are currently in-stock or below their min. stock amount - when this is enabled, all (active) products are always shown" msgstr "" + +msgid "No price information is available for at least one ingredient" +msgstr "" diff --git a/migrations/0247.sql b/migrations/0247.sql new file mode 100644 index 00000000..0e5f011a --- /dev/null +++ b/migrations/0247.sql @@ -0,0 +1,21 @@ +DROP VIEW recipes_resolved; +CREATE VIEW recipes_resolved +AS +SELECT + 1 AS id, -- Dummy, LessQL needs an id column + r.id AS recipe_id, + IFNULL(MIN(rpr.need_fulfilled), 1) AS need_fulfilled, + IFNULL(MIN(rpr.need_fulfilled_with_shopping_list), 1) AS need_fulfilled_with_shopping_list, + IFNULL(rmpc.missing_products_count, 0) AS missing_products_count, + IFNULL(SUM(rpr.costs), 0) AS costs, + IFNULL(SUM(rpr.costs) / CASE WHEN IFNULL(r.desired_servings, 0) = 0 THEN 1 ELSE r.desired_servings END, 0) AS costs_per_serving, + IFNULL(SUM(rpr.calories), 0) AS calories, + IFNULL(SUM(rpr.due_score), 0) AS due_score, + GROUP_CONCAT(rpr.product_name) AS product_names_comma_separated, + CASE WHEN MIN(IFNULL(rpr.costs, 0)) = 0 THEN 1 ELSE 0 END AS prices_incomplete +FROM recipes r +LEFT JOIN recipes_pos_resolved rpr + ON r.id = rpr.recipe_id +LEFT JOIN recipes_missing_product_counts rmpc + ON r.id = rmpc.recipe_id +GROUP BY r.id; diff --git a/views/recipes.blade.php b/views/recipes.blade.php index 1050d7d2..9fa56cfd 100644 --- a/views/recipes.blade.php +++ b/views/recipes.blade.php @@ -385,7 +385,7 @@ data-recipe-name="{{ $recipe->name }}"> - @@ -424,7 +424,15 @@ data-trigger="hover click" title="{{ $__t('Based on the prices of the default consume rule (Opened first, then first due first, then first in first out) for in-stock ingredients and on the last price for missing ones') }}"> -

{{ $costs }}

+

+ {{ $costs }} + @if(FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $recipe->id)->prices_incomplete) + + @endif +

@endif