Class: Workarea::Orderbot::Inventory::ImportInventory

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
app/workers/workarea/orderbot/inventory/import_inventory.rb

Instance Method Summary collapse

Instance Method Details

#perform(attrs = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/workers/workarea/orderbot/inventory/import_inventory.rb', line 7

def perform(attrs = {})
  inventory = attrs.deep_symbolize_keys

  return unless inventory[:sku].present?

  sku = Workarea::Inventory::Sku.find_or_initialize_by(id: inventory[:sku])

  sku.available = inventory[:quantity_on_hand] || 0
  sku.policy = get_policy(inventory[:sku])

  sku.save!
end