Use serving count in shopping list

This commit is contained in:
tourn
2020-11-20 15:22:58 +01:00
parent 1e800889e4
commit 6fd9cf0d8c
2 changed files with 9 additions and 3 deletions

View File

@@ -349,7 +349,12 @@
multiplier_cache() {
let cache = {}
this.shopping_list.recipes.forEach((r) => {
cache[r.id] = !(Number.isNaN(r.multiplier)) ? parseFloat(r.multiplier) : 1
let multiplier = r.servings;
if(!Number.isNaN(r.multiplier)){
multiplier = parseFloat(r.multiplier)
}
cache[r.id] = multiplier / r.servings;
})
return cache
},
@@ -621,7 +626,8 @@
"id": Math.random() * 1000,
"recipe": recipe.id,
"recipe_name": recipe.name,
"multiplier": multiplier
"multiplier": multiplier,
"servings": recipe.servings,
}
this.shopping_list.recipes.push(slr)