Skip to content

Commit

Permalink
(bug) unable to update product low stock alert
Browse files Browse the repository at this point in the history
  • Loading branch information
gnepud committed Jan 22, 2025
1 parent 7be7b97 commit 327b460
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- updated rails to 7.0.8.7
- updated tzinfo-data to 1.2025.1
- Fix a bug: unable to update opening/closing time for the calendar
- Fix a bug: unable to update product low stock alert

## v6.3.36 2024 December 12

Expand Down
2 changes: 1 addition & 1 deletion app/services/product_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def amount_multiplied_by_hundred(amount)
# @param stock_movements [{stock_type: string, reason: string, quantity: number|string, order_item_id: number|nil}]
def update_stock(product, stock_movements = nil)
remaining_stock = { internal: product.stock['internal'], external: product.stock['external'] }
product.product_stock_movements_attributes = stock_movements&.map do |movement|
product.product_stock_movements_attributes = stock_movements&.compact_blank&.map do |movement|
quantity = ProductStockMovement::OUTGOING_REASONS.include?(movement[:reason]) ? -movement[:quantity].to_i : movement[:quantity].to_i
remaining_stock[movement[:stock_type].to_sym] += quantity
{
Expand Down

0 comments on commit 327b460

Please sign in to comment.