From fe92caaed40b834c0fa75dcb9e85fcb7ce5ff5b0 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Thu, 9 Jun 2022 22:14:00 +0200 Subject: [PATCH] Fixed price history chart data parsing (fixes #1914) --- changelog/68_UNRELEASED_xxxx-xx-xx.md | 1 + public/viewjs/components/productcard.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/changelog/68_UNRELEASED_xxxx-xx-xx.md b/changelog/68_UNRELEASED_xxxx-xx-xx.md index f11bf768..edffb1ca 100644 --- a/changelog/68_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/68_UNRELEASED_xxxx-xx-xx.md @@ -14,6 +14,7 @@ - The stock setting "Decimal places allowed for prices" has been split into separate settings for input and displaying prices (the existing setting will be set for both new options on migration, so no changed behavior when not configured) - Optimized that when the plural form(s) of a quantity unit is/are not provided, the singular form is used to display plural amounts - Fixed "Automatically add products that are below their defined min. stock amount to the shopping list" (stock setting) was only done when consuming products, not when opening them +- Fixed that the price history chart (product card) showed the price on a wrong date when having multiple purchases on the same date from different stores ### Shopping list diff --git a/public/viewjs/components/productcard.js b/public/viewjs/components/productcard.js index f09a4df3..913e931d 100644 --- a/public/viewjs/components/productcard.js +++ b/public/viewjs/components/productcard.js @@ -151,7 +151,7 @@ Grocy.Components.ProductCard.Refresh = function(productId) datasets[key] = [] } chart.labels.push(moment(dataPoint.date).toDate()); - datasets[key].push(Number.parseFloat(dataPoint.price) * Number.parseFloat(productDetails.product.qu_factor_purchase_to_stock)); + datasets[key].push({ x: moment(dataPoint.date).toDate(), y: Number.parseFloat(dataPoint.price) * Number.parseFloat(productDetails.product.qu_factor_purchase_to_stock) }); }); Object.keys(datasets).forEach((key) => @@ -163,6 +163,7 @@ Grocy.Components.ProductCard.Refresh = function(productId) label: key, }); }); + Grocy.Components.ProductCard.PriceHistoryChart.update(); } else