From d05038e31194c0ca18747b1d66b36abf78697dd8 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Thu, 8 Jun 2023 22:15:33 +0200 Subject: [PATCH] Exclude products with hide_on_stock_overview enabled in current stock info on /stockoverview (fixes #2250) --- changelog/70_UNRELEASED_xxxx.xx.xx.md | 1 + public/viewjs/stockoverview.js | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/changelog/70_UNRELEASED_xxxx.xx.xx.md b/changelog/70_UNRELEASED_xxxx.xx.xx.md index c1c91547..458eb4dc 100644 --- a/changelog/70_UNRELEASED_xxxx.xx.xx.md +++ b/changelog/70_UNRELEASED_xxxx.xx.xx.md @@ -43,6 +43,7 @@ - Fixed that the consumed amount was wrong, when consuming multiple substituted subproducts at once and when multiple/different conversion factors were involved - Fixed that for a product's average price, only currently in-stock items were considered, not already consumed ones - Fixed that when copying a product, some fields (like "Default consume location" or "Disable own stock) weren't copied along +- Fixed that the total product count on the stock overview page also included products with "Never show on stock overview" enabled ### Shopping list diff --git a/public/viewjs/stockoverview.js b/public/viewjs/stockoverview.js index fb7159b4..a740f467 100755 --- a/public/viewjs/stockoverview.js +++ b/public/viewjs/stockoverview.js @@ -236,7 +236,7 @@ function RefreshStatistics() { if (!Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) { - $("#info-current-stock").text(__n(result.length, '%s Product', '%s Products')); + $("#info-current-stock").text(__n(result.filter(x => !BoolVal(x.product.hide_on_stock_overview)).length, '%s Product', '%s Products')); } else { @@ -245,7 +245,8 @@ function RefreshStatistics() { valueSum += element.value; }); - $("#info-current-stock").text(__n(result.length, '%s Product', '%s Products') + ", " + __t('%s total value', valueSum.toLocaleString(undefined, { style: "currency", currency: Grocy.Currency }))); + + $("#info-current-stock").text(__n(result.filter(x => !BoolVal(x.product.hide_on_stock_overview)).length, '%s Product', '%s Products') + ", " + __t('%s total value', valueSum.toLocaleString(undefined, { style: "currency", currency: Grocy.Currency }))); } }, function(xhr)