From 2e5581351a6548f334e9cb1e728240f4196e2f83 Mon Sep 17 00:00:00 2001 From: Du Peng Date: Mon, 27 Jan 2025 10:48:33 +0100 Subject: [PATCH] (bug) unable to update product low stock alert --- CHANGELOG.md | 2 ++ app/services/product_service.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f0087128..d13299a68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Next release +- Fix a bug: unable to update product low stock alert + ## v6.3.37 2025 January 22 - updated rails to 7.0.8.7 diff --git a/app/services/product_service.rb b/app/services/product_service.rb index deb8a1a29..a48f00cab 100644 --- a/app/services/product_service.rb +++ b/app/services/product_service.rb @@ -195,7 +195,7 @@ def notify_on_low_stock(product, stock_movements = nil) return product unless product.low_stock_alert return product unless product.low_stock_threshold - affected_stocks = stock_movements&.map { |m| m[:stock_type] }&.uniq + affected_stocks = stock_movements&.compact_blank&.map { |m| m[:stock_type] }&.uniq if (product.stock['internal'] <= product.low_stock_threshold && affected_stocks&.include?('internal')) || (product.stock['external'] <= product.low_stock_threshold && affected_stocks&.include?('external')) NotificationCenter.call type: 'notify_admin_low_stock_threshold',