Răsfoiți Sursa

Fix problem with formatting of data for the graphs

Lee Morgan 6 ani în urmă
părinte
comite
a0ec5566ab
2 a modificat fișierele cu 2 adăugiri și 2 ștergeri
  1. 1 1
      views/dataPage/ingredient.js
  2. 1 1
      views/dataPage/recipe.js

+ 1 - 1
views/dataPage/ingredient.js

@@ -77,7 +77,7 @@ window.ingredientObj = {
             let transDate = new Date(transaction.date);
             let diff = Math.floor((Date.UTC(transDate.getFullYear(), transDate.getMonth(), transDate.getDate()) - Date.UTC(endDate.getFullYear(), endDate.getMonth(), endDate.getDate())) / (1000 * 60 * 60 * 24));
 
-            if(diff <= 0){
+            if(transDate > from && diff <= 0){
                 for(let recipe of transaction.recipes){
                     for(let merchRecipe of data.merchant.recipes){
                         if(merchRecipe._id === recipe.recipe){

+ 1 - 1
views/dataPage/recipe.js

@@ -77,7 +77,7 @@ window.recipeObj = {
             let transDate = new Date(transaction.date);
             let diff = Math.floor((Date.UTC(transDate.getFullYear(), transDate.getMonth(), transDate.getDate()) - Date.UTC(to.getFullYear(), to.getMonth(), to.getDate())) / (1000 * 60 * 60 * 24));
 
-            if(diff <= 0){
+            if(transDate > from && diff <= 0){
                 for(let recipe of transaction.recipes){
                     if(recipe.recipe === id){
                         dataList[dateRange - Math.abs(diff) - 1] += recipe.quantity;