Quellcode durchsuchen

New transactions now fetched from square on log in.
Ingredient quantities automatically updating from new transactions.

Lee Morgan vor 5 Jahren
Ursprung
Commit
ba06952671
2 geänderte Dateien mit 7 neuen und 6 gelöschten Zeilen
  1. 0 2
      controllers/helper.js
  2. 7 4
      controllers/renderer.js

+ 0 - 2
controllers/helper.js

@@ -85,8 +85,6 @@ module.exports = {
                     }
                 }
 
-                merchant.lastUpdatedTime = new Date();
-
                 return transactions;
             })
             .catch((err)=>{

+ 7 - 4
controllers/renderer.js

@@ -64,11 +64,14 @@ module.exports = {
                         latest = new Date(transactions[0].date);
                     }
 
-                    let newRecipes = {};
                     if(latest !== null){
-                        newRecipes = await helper.getSquareData(res.locals.merchant, latest);
-                        newRecipes = newRecipes.concat(transactions);                        
-                        transactions = newRecipes;
+                        let newOrders = await helper.getSquareData(res.locals.merchant, latest);
+                        for(let i = 0; i < newOrders.length; i++){
+                           for(let j = 0; j < newOrders[i].recipes.length; j++){
+                               newOrders[i].recipes[j].recipe = newOrders[i].recipes[j].recipe._id;
+                           }
+                        }
+                        transactions = newOrders.concat(transactions);
                     }
                 }