Class: ItemBuilder::GetQuantityService
- Inherits:
-
Object
- Object
- ItemBuilder::GetQuantityService
- Defined in:
- lib/item_builder/get_quantity_service.rb
Instance Attribute Summary collapse
-
#listing ⇒ Object
readonly
Returns the value of attribute listing.
-
#variant ⇒ Object
readonly
Returns the value of attribute variant.
-
#wh_sp ⇒ Object
readonly
Returns the value of attribute wh_sp.
Instance Method Summary collapse
-
#initialize(args) ⇒ GetQuantityService
constructor
A new instance of GetQuantityService.
- #perform ⇒ Object
Constructor Details
#initialize(args) ⇒ GetQuantityService
Returns a new instance of GetQuantityService.
8 9 10 11 12 13 14 15 |
# File 'lib/item_builder/get_quantity_service.rb', line 8 def initialize(args) @listing = args.fetch(:listing) @wh_sp = args.fetch(:wh_sp) @variant = args.fetch(:variant) @stock_alloc = args.fetch(:stock_alloc) @bundle_variants = args.fetch(:bundle_variants) @existing_allocated_stock = args.fetch(:existing_allocated_stock) end |
Instance Attribute Details
#listing ⇒ Object (readonly)
Returns the value of attribute listing.
7 8 9 |
# File 'lib/item_builder/get_quantity_service.rb', line 7 def listing @listing end |
#variant ⇒ Object (readonly)
Returns the value of attribute variant.
7 8 9 |
# File 'lib/item_builder/get_quantity_service.rb', line 7 def variant @variant end |
#wh_sp ⇒ Object (readonly)
Returns the value of attribute wh_sp.
7 8 9 |
# File 'lib/item_builder/get_quantity_service.rb', line 7 def wh_sp @wh_sp end |
Instance Method Details
#perform ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/item_builder/get_quantity_service.rb', line 17 def perform return 0 if check_consignment_variant? if allocated_stock_active? # yang masuk di kondisi ini, # artinya akun tersebut ada allocated stock yang aktif allocated_stock elsif @existing_allocated_stock.present? # yang masuk di kondisi ini, # artinya akun tersebut tidak ada allocated stock yang aktif, # namun ada allocated stock yg aktif dari channel lain warehouse_stock - count_existing_alloc_stock + count_alloc_rsvd_stock else # yang masuk di kondisi ini, # artinya tidak ada allocated stock di item tersebut warehouse_stock end end |