|
|
@@ -50,7 +50,18 @@ window.homeObj = {
|
|
|
}
|
|
|
|
|
|
//Populate number of recipes sold
|
|
|
- this.populateRecipesObject(recipes);
|
|
|
+ for(let transaction of data.transactions){
|
|
|
+ for(let recipe of transaction.recipes){
|
|
|
+ for(let newRecipe of recipes){
|
|
|
+ if(recipe.recipe === newRecipe.id){
|
|
|
+ newRecipe.quantity += recipe.quantity;
|
|
|
+ this.recipeTotal += recipe.quantity;
|
|
|
+ this.revenueTotal += (newRecipe.price * recipe.quantity);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
//Populate amount of ingredients sold
|
|
|
for(let recipe of recipes){
|
|
|
@@ -135,35 +146,5 @@ window.homeObj = {
|
|
|
//Populate totals
|
|
|
document.querySelector("#revenueTotal").innerText = `$${this.revenueTotal.toFixed(2)}`;
|
|
|
document.querySelector("#soldTotal").innerText = this.recipeTotal;
|
|
|
- },
|
|
|
-
|
|
|
- populateRecipesObject: function(recipes){
|
|
|
- if(data.merchant.pos === "clover"){
|
|
|
- for(let transaction of data.transactions){
|
|
|
- for(let transactionRecipe of transaction.recipes){
|
|
|
- for(let recipeCounter of recipes){
|
|
|
- if(transactionRecipe === recipeCounter.id){
|
|
|
- recipeCounter.quantity++;
|
|
|
- this.recipeTotal++;
|
|
|
- this.revenueTotal += recipeCounter.price;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }else{
|
|
|
- for(let transaction of data.transactions){
|
|
|
- for(let recipe of transaction.recipes){
|
|
|
- for(let newRecipe of recipes){
|
|
|
- if(recipe.recipe === newRecipe.id){
|
|
|
- newRecipe.quantity += recipe.quantity;
|
|
|
- this.recipeTotal += recipe.quantity;
|
|
|
- this.revenueTotal += (newRecipe.price * recipe.quantity);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
}
|