Class: Spree::Stock::InventoryUnitsFinalizer

Inherits:
Object
  • Object
show all
Defined in:
app/models/spree/stock/inventory_units_finalizer.rb

Overview

Service class to finalize inventory units, it means unstock the desired quantity from related stock item and updates the given inventory units to not be pending.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(inventory_units) ⇒ InventoryUnitsFinalizer

Returns a new instance of InventoryUnitsFinalizer.

Parameters:



13
14
15
# File 'app/models/spree/stock/inventory_units_finalizer.rb', line 13

def initialize(inventory_units)
  @inventory_units = inventory_units
end

Instance Attribute Details

#inventory_unitsObject (readonly)



10
11
12
# File 'app/models/spree/stock/inventory_units_finalizer.rb', line 10

def inventory_units
  @inventory_units
end

Instance Method Details

#run!Object

Finalize the inventory units, unstock and mark them as not pending.



18
19
20
21
22
23
# File 'app/models/spree/stock/inventory_units_finalizer.rb', line 18

def run!
  Spree::InventoryUnit.transaction do
    unstock_inventory_units
    finalize_inventory_units
  end
end