|
|
@@ -600,7 +600,7 @@ class Merchant{
|
|
|
}]
|
|
|
*/
|
|
|
getIngredientsSold(from = 0, to = new Date()){
|
|
|
- if(from = 0){
|
|
|
+ if(from === 0){
|
|
|
from = this._ingredients[0].date;
|
|
|
}
|
|
|
|
|
|
@@ -615,6 +615,7 @@ class Merchant{
|
|
|
if(ingredientList[k].ingredient === recipes[i].recipe.ingredients[j].ingredient){
|
|
|
exists = true;
|
|
|
ingredientList[k].quantity += recipes[i].quantity * recipes[i].recipe.ingredients[j].quantity;
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -671,7 +672,7 @@ class Merchant{
|
|
|
}]
|
|
|
*/
|
|
|
getRecipesSold(from = 0, to = new Date()){
|
|
|
- if(from = 0){
|
|
|
+ if(from === 0){
|
|
|
from = this._transactions[0].date;
|
|
|
}
|
|
|
|
|
|
@@ -783,7 +784,9 @@ class Merchant{
|
|
|
|
|
|
getTransactionIndices(from, to){
|
|
|
let start, end;
|
|
|
- to.setDate(to.getDate() + 1);
|
|
|
+ console.log(from);
|
|
|
+ console.log(to);
|
|
|
+
|
|
|
|
|
|
for(let i = this._transactions.length - 1; i >= 0; i--){
|
|
|
if(this._transactions[i].date >= from){
|
|
|
@@ -803,10 +806,10 @@ class Merchant{
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- //these are switched due to the order of the transactions in the merchant
|
|
|
- return {start: end, end: start};
|
|
|
+ return {start: start, end: end};
|
|
|
}
|
|
|
|
|
|
+
|
|
|
isSanitaryString(str){
|
|
|
let disallowed = ["\\", "<", ">", "$", "{", "}", "(", ")"];
|
|
|
|
|
|
@@ -2643,7 +2646,20 @@ module.exports = newTransaction;
|
|
|
},{}],14:[function(require,module,exports){
|
|
|
let orderCalculator = {
|
|
|
display: function(){
|
|
|
- console.log("something");
|
|
|
+ let calculations = this.getDailyAverages();
|
|
|
+
|
|
|
+ // console.log(calculations);
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ getDailyAverages: function(){
|
|
|
+ let now = new Date();
|
|
|
+ let yesterday = new Date();
|
|
|
+ yesterday.setHours(0, 0, 0, 0);
|
|
|
+ let past = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 30);
|
|
|
+
|
|
|
+ let ingredients = merchant.getIngredientsSold(past, yesterday);
|
|
|
+ console.log(ingredients);
|
|
|
}
|
|
|
}
|
|
|
|