Browse Source

Remove xlsx file from uploads.
Bug fix: analytics page did not automatically update when a new transaction was created.

Lee Morgan 5 years ago
parent
commit
91e8414fd6

BIN
uploads/5f2caaab266e959f1ad46bc264d2dc7d


+ 5 - 37
views/dashboardPage/bundle.js

@@ -1621,43 +1621,8 @@ controller = {
         document.getElementById("mobileMenuSelector").onclick = ()=>{this.openMenu()};
     },
 
-    /*
-    Converts the price of unit back to the price per default unit
-    unitType = type of the unit (i.e. mass, volume)
-    unit = exact unit to convert to
-    price = price of the ingredient per unit in cents
-    */
-    reconvertPrice(unitType, unit, price){
-        if(unitType === "mass"){
-            switch(unit){
-                case "g": break;
-                case "kg": price *= 1000; break;
-                case "oz":  price *= 28.3495; break;
-                case "lb":  price *= 453.5924; break;
-            }
-        }else if(unitType === "volume"){
-            switch(unit){
-                case "ml": price /= 1000; break;
-                case "l": break;
-                case "tsp": price /= 202.8842; break;
-                case "tbsp": price /= 67.6278; break;
-                case "ozfl": price /= 33.8141; break;
-                case "cup": price /= 4.1667; break;
-                case "pt": price /= 2.1134; break;
-                case "qt": price /= 1.0567; break;
-                case "gal": price *= 3.7854; break;
-            }
-        }else if(unitType === "length"){
-            switch(unit){
-                case "mm": price /= 1000; break;
-                case "cm": price /= 100; break;
-                case "m": break;
-                case "in": price /= 39.3701; break;
-                case "ft": price /= 3.2808; break;
-            }
-        }
-
-        return price;
+    updateAnalytics: function(){
+        analytics.isPopulated = false;
     }
 }
 
@@ -2584,6 +2549,7 @@ let newTransaction = {
                     }else{
                         merchant.addTransaction(response);
 
+                        controller.updateAnalytics();
                         controller.openStrand("transactions", merchant.getTransactions());
                         controller.createBanner("TRANSACTION CREATED", "success");
                     }
@@ -2622,6 +2588,7 @@ let newTransaction = {
                         response.recipes[i].recipe = response.recipes[i].recipe._id;
                     }
                     merchant.addTransaction(response);
+                    controller.updateAnalytics();
 
                     controller.openStrand("transactions", merchant.transactions);
                     controller.createBanner("TRANSACTION SUCCESSFULLY CREATED.  INGREDIENTS UPDATED", "success");
@@ -2991,6 +2958,7 @@ let transactionDetails = {
                     controller.createBanner(response, "error");
                 }else{
                     merchant.removeTransaction(this.transaction);
+                    controller.updateAnalytics();
 
                     controller.openStrand("transactions", merchant.getTransactions());
                     controller.createBanner("TRANSACTION REMOVED", "success");

+ 2 - 37
views/dashboardPage/js/dashboard.js

@@ -315,43 +315,8 @@ controller = {
         document.getElementById("mobileMenuSelector").onclick = ()=>{this.openMenu()};
     },
 
-    /*
-    Converts the price of unit back to the price per default unit
-    unitType = type of the unit (i.e. mass, volume)
-    unit = exact unit to convert to
-    price = price of the ingredient per unit in cents
-    */
-    reconvertPrice(unitType, unit, price){
-        if(unitType === "mass"){
-            switch(unit){
-                case "g": break;
-                case "kg": price *= 1000; break;
-                case "oz":  price *= 28.3495; break;
-                case "lb":  price *= 453.5924; break;
-            }
-        }else if(unitType === "volume"){
-            switch(unit){
-                case "ml": price /= 1000; break;
-                case "l": break;
-                case "tsp": price /= 202.8842; break;
-                case "tbsp": price /= 67.6278; break;
-                case "ozfl": price /= 33.8141; break;
-                case "cup": price /= 4.1667; break;
-                case "pt": price /= 2.1134; break;
-                case "qt": price /= 1.0567; break;
-                case "gal": price *= 3.7854; break;
-            }
-        }else if(unitType === "length"){
-            switch(unit){
-                case "mm": price /= 1000; break;
-                case "cm": price /= 100; break;
-                case "m": break;
-                case "in": price /= 39.3701; break;
-                case "ft": price /= 3.2808; break;
-            }
-        }
-
-        return price;
+    updateAnalytics: function(){
+        analytics.isPopulated = false;
     }
 }
 

+ 2 - 0
views/dashboardPage/js/sidebars/newTransaction.js

@@ -75,6 +75,7 @@ let newTransaction = {
                     }else{
                         merchant.addTransaction(response);
 
+                        controller.updateAnalytics();
                         controller.openStrand("transactions", merchant.getTransactions());
                         controller.createBanner("TRANSACTION CREATED", "success");
                     }
@@ -113,6 +114,7 @@ let newTransaction = {
                         response.recipes[i].recipe = response.recipes[i].recipe._id;
                     }
                     merchant.addTransaction(response);
+                    controller.updateAnalytics();
 
                     controller.openStrand("transactions", merchant.transactions);
                     controller.createBanner("TRANSACTION SUCCESSFULLY CREATED.  INGREDIENTS UPDATED", "success");

+ 1 - 0
views/dashboardPage/js/sidebars/transactionDetails.js

@@ -59,6 +59,7 @@ let transactionDetails = {
                     controller.createBanner(response, "error");
                 }else{
                     merchant.removeTransaction(this.transaction);
+                    controller.updateAnalytics();
 
                     controller.openStrand("transactions", merchant.getTransactions());
                     controller.createBanner("TRANSACTION REMOVED", "success");