Class: Spina::Shop::DeallocateStock

Inherits:
Object
  • Object
show all
Defined in:
app/services/spina/shop/deallocate_stock.rb

Instance Method Summary collapse

Constructor Details

#initialize(order) ⇒ DeallocateStock

Returns a new instance of DeallocateStock.



4
5
6
# File 'app/services/spina/shop/deallocate_stock.rb', line 4

def initialize(order)
  @order = order
end

Instance Method Details

#deallocateObject



8
9
10
11
12
13
14
# File 'app/services/spina/shop/deallocate_stock.rb', line 8

def deallocate
  # Delete StockLevelAdjustments
  StockLevelAdjustment.where(order_item: @order.order_items).delete_all

  # Cache all products involved
  @order.products.each(&:cache_stock_level)
end