Class: Stockman::Logic::Product::StockLevel
- Inherits:
-
Object
- Object
- Stockman::Logic::Product::StockLevel
- Defined in:
- lib/stockman/logic/product/stock_level.rb
Instance Attribute Summary collapse
-
#sellables ⇒ Object
readonly
Returns the value of attribute sellables.
-
#warehouse_id ⇒ Object
readonly
Returns the value of attribute warehouse_id.
Instance Method Summary collapse
- #allocated_amount ⇒ Object
- #available_amount ⇒ Object
-
#initialize(sellables, warehouse_id) ⇒ StockLevel
constructor
A new instance of StockLevel.
- #physical_amount ⇒ Object
- #sellables_stock_levels ⇒ Object
Constructor Details
#initialize(sellables, warehouse_id) ⇒ StockLevel
7 8 9 10 |
# File 'lib/stockman/logic/product/stock_level.rb', line 7 def initialize(sellables, warehouse_id) @sellables = sellables @warehouse_id = warehouse_id.to_i end |
Instance Attribute Details
#sellables ⇒ Object (readonly)
Returns the value of attribute sellables.
5 6 7 |
# File 'lib/stockman/logic/product/stock_level.rb', line 5 def sellables @sellables end |
#warehouse_id ⇒ Object (readonly)
Returns the value of attribute warehouse_id.
5 6 7 |
# File 'lib/stockman/logic/product/stock_level.rb', line 5 def warehouse_id @warehouse_id end |
Instance Method Details
#allocated_amount ⇒ Object
16 17 18 |
# File 'lib/stockman/logic/product/stock_level.rb', line 16 def allocated_amount sellables_stock_levels.sum(&:allocated_amount) end |
#available_amount ⇒ Object
20 21 22 |
# File 'lib/stockman/logic/product/stock_level.rb', line 20 def available_amount sellables_stock_levels.sum(&:available_amount) end |
#physical_amount ⇒ Object
12 13 14 |
# File 'lib/stockman/logic/product/stock_level.rb', line 12 def physical_amount sellables_stock_levels.sum(&:physical_amount) end |
#sellables_stock_levels ⇒ Object
24 25 26 27 28 |
# File 'lib/stockman/logic/product/stock_level.rb', line 24 def sellables_stock_levels @sellables_stock_levels ||= sellables.stock_levels.select do |stock_level| stock_level.warehouse_id == warehouse_id end end |