class Stockman::Logic::Variant::StockLevel

Attributes

variant_id[R]
warehouse_id[R]

Public Class Methods

new(variant_id, warehouse_id) click to toggle source
# File lib/stockman/logic/variant/stock_level.rb, line 7
def initialize(variant_id, warehouse_id)
  @variant_id = variant_id.to_i
  @warehouse_id = warehouse_id.to_i
end

Public Instance Methods

allocated_amount() click to toggle source
# File lib/stockman/logic/variant/stock_level.rb, line 16
def allocated_amount
  obtain_amount(:allocated)
end
available_amount() click to toggle source
# File lib/stockman/logic/variant/stock_level.rb, line 20
def available_amount
  physical_amount - allocated_amount
end
physical_amount() click to toggle source
# File lib/stockman/logic/variant/stock_level.rb, line 12
def physical_amount
  obtain_amount(:physical)
end

Private Instance Methods

obtain_amount(type) click to toggle source
# File lib/stockman/logic/variant/stock_level.rb, line 26
def obtain_amount(type)
  Storage.obtain_amount("variants:#{variant_id}:stock_levels:#{warehouse_id}", :"#{type}_amount")
end