Indicate incomplete recipe costs information (closes #1941)

This commit is contained in:
Bernd Bestel 2025-01-17 20:37:43 +01:00
parent c05181aa53
commit f9c7c67dc7
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
4 changed files with 35 additions and 2 deletions

View File

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

View File

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

21
migrations/0247.sql Normal file
View File

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

View File

@ -385,7 +385,7 @@
data-recipe-name="{{ $recipe->name }}">
<i class="fa-solid fa-cart-plus"></i>
</a>
<a class=" btnrecipe-fullscreen hide-when-embedded"
<a class=" btn recipe-fullscreen hide-when-embedded"
href="#"
data-toggle="tooltip"
title="{{ $__t('Expand to fullscreen') }}">
@ -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') }}"></i>
</label>
<h3 class="locale-number locale-number-currency pt-0">{{ $costs }}</h3>
<h3>
<span class="locale-number locale-number-currency pt-0">{{ $costs }}</span>
@if(FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $recipe->id)->prices_incomplete)
<i class="fa-solid fa-exclamation text-danger"
data-toggle="tooltip"
data-trigger="hover click"
title="{{ $__t('No price information is available for at least one ingredient') }}"></i>
@endif
</h3>
</div>
@endif