mirror of
https://github.com/grocy/grocy.git
synced 2025-04-28 17:23:56 +00:00
Fixed recipes_nestings_resolved recursive serving calculation (fixes #2361)
This commit is contained in:
parent
c8ccc0b529
commit
cc40344845
@ -30,10 +30,11 @@
|
||||
### Recipes
|
||||
|
||||
- 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)
|
||||
|
||||
### Meal plan
|
||||
|
||||
- xxx
|
||||
- Fixed that amounts/costs/calories were wrong for recipes which had at least 2 levels of "included recipes"
|
||||
|
||||
### Chores
|
||||
|
||||
|
26
migrations/0243.sql
Normal file
26
migrations/0243.sql
Normal file
@ -0,0 +1,26 @@
|
||||
DROP VIEW recipes_nestings_resolved;
|
||||
CREATE VIEW recipes_nestings_resolved
|
||||
AS
|
||||
WITH RECURSIVE r1(recipe_id, includes_recipe_id, includes_servings, level)
|
||||
AS (
|
||||
SELECT
|
||||
id AS recipe_id,
|
||||
id AS includes_recipe_id,
|
||||
1 AS includes_servings,
|
||||
0 AS level
|
||||
FROM recipes
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
rn.recipe_id,
|
||||
r1.includes_recipe_id,
|
||||
rn.servings * r1.includes_servings AS includes_servings,
|
||||
r1.level + 1 AS level
|
||||
FROM recipes_nestings rn, r1 r1
|
||||
WHERE rn.includes_recipe_id = r1.recipe_id
|
||||
)
|
||||
SELECT
|
||||
*,
|
||||
1 AS id -- Dummy, LessQL needs an id column
|
||||
FROM r1;
|
Loading…
x
Reference in New Issue
Block a user