|
@@ -24,6 +24,10 @@ class RecipeIngredient{
|
|
|
getQuantityDisplay(){
|
|
getQuantityDisplay(){
|
|
|
return `${this._quantity.toFixed(2)} ${this._unit.toUpperCase()}`;
|
|
return `${this._quantity.toFixed(2)} ${this._unit.toUpperCase()}`;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ getQuantityAsBase(){
|
|
|
|
|
+ return this._quantity * this._baseUnitMultiplier;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -34,6 +38,8 @@ price = price of recipe in cents
|
|
|
ingredients = [{
|
|
ingredients = [{
|
|
|
ingredient: Ingredient Object,
|
|
ingredient: Ingredient Object,
|
|
|
quantity: quantity of the ingredient within the recipe (stored as base unit, i.e grams)
|
|
quantity: quantity of the ingredient within the recipe (stored as base unit, i.e grams)
|
|
|
|
|
+ unit: String
|
|
|
|
|
+ baseUnitmultiplier: Number
|
|
|
}]
|
|
}]
|
|
|
parent = merchant that it belongs to
|
|
parent = merchant that it belongs to
|
|
|
*/
|
|
*/
|
|
@@ -47,6 +53,7 @@ class Recipe{
|
|
|
this._hidden = hidden;
|
|
this._hidden = hidden;
|
|
|
this._ingredients = [];
|
|
this._ingredients = [];
|
|
|
this._ingredientTotals = {};
|
|
this._ingredientTotals = {};
|
|
|
|
|
+ this._ingredientTotalsBase = {};
|
|
|
|
|
|
|
|
for(let i = 0; i < ingredients.length; i++){
|
|
for(let i = 0; i < ingredients.length; i++){
|
|
|
const ingredient = parent.getIngredient(ingredients[i].ingredient);
|
|
const ingredient = parent.getIngredient(ingredients[i].ingredient);
|
|
@@ -117,6 +124,10 @@ class Recipe{
|
|
|
return (this._ingredientTotals[id] === undefined) ? 0 : this._ingredientTotals[id];
|
|
return (this._ingredientTotals[id] === undefined) ? 0 : this._ingredientTotals[id];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ getIngredientTotalBase(id){
|
|
|
|
|
+ return (this._ingredientTotalsBase[i] === undefined) ? 0 : this._ingredientTotals[id];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
addIngredient(ingredient, quantity, unit, baseUnitMultiplier){
|
|
addIngredient(ingredient, quantity, unit, baseUnitMultiplier){
|
|
|
let recipeIngredient = new RecipeIngredient(ingredient, quantity, unit, baseUnitMultiplier);
|
|
let recipeIngredient = new RecipeIngredient(ingredient, quantity, unit, baseUnitMultiplier);
|
|
|
this._ingredients.push(recipeIngredient);
|
|
this._ingredients.push(recipeIngredient);
|
|
@@ -142,6 +153,12 @@ class Recipe{
|
|
|
}else{
|
|
}else{
|
|
|
this._ingredientTotals[ingredient.id] += multiplier;
|
|
this._ingredientTotals[ingredient.id] += multiplier;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if(this._ingredientTotalsBase[ingredient.id] === undefined){
|
|
|
|
|
+ this._ingredientTotalsBase[ingredient.id] = multiplier * this._baseUnitMultiplier;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ this._ingredientTotalsBase[ingredient.id] += multiplier * this._baseUnitMultiplier;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
for(let i = 0; i < this._ingredients.length; i++){
|
|
for(let i = 0; i < this._ingredients.length; i++){
|