Class: Workarea::Inventory::Policies::AllowBackorder

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

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
14
# File 'app/models/workarea/inventory/policies/allow_backorder.rb', line 9

def available_to_sell
  total_available =
    sku.available.to_i + sku.backordered.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/allow_backorder.rb', line 5

def displayable?
  sku.purchasable?
end

#purchase(quantity) ⇒ Object



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

def purchase(quantity)
  result = try_capture(quantity)
  result = try_capture(quantity) until result[:success]
  result
end