Class: Workarea::Inventory::Policies::Standard

Inherits:
Base
  • Object
show all
Defined in:
app/models/workarea/inventory/policies/standard.rb

Direct Known Subclasses

DisplayableWhenOutOfStock

Instance Attribute Summary

Attributes inherited from Base

#sku

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Workarea::Inventory::Policies::Base

Instance Method Details

#available_to_sellObject



9
10
11
12
13
# File 'app/models/workarea/inventory/policies/standard.rb', line 9

def available_to_sell
  total_available = sku.available.to_i - sku.reserve.to_i
  total_available = 0 if total_available < 0
  total_available
end

#displayable?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'app/models/workarea/inventory/policies/standard.rb', line 5

def displayable?
  sku.purchasable?
end

#purchase(quantity) ⇒ Object



15
16
17
18
19
# File 'app/models/workarea/inventory/policies/standard.rb', line 15

def purchase(quantity)
  result = sku.capture(quantity)
  result = sku.capture(quantity) until result[:success]
  result
end