Class: ItemBuilderMwh::GetQuantityService
- Inherits:
-
Object
- Object
- ItemBuilderMwh::GetQuantityService
- Defined in:
- lib/item_builder_mwh/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.
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 16 17 |
# File 'lib/item_builder_mwh/get_quantity_service.rb', line 8 def initialize(args) @listing = args.fetch(:listing) @variant = args.fetch(:variant) @stock_alloc = args.fetch(:stock_alloc) @bundle_variants = args.fetch(:bundle_variants) @existing_allocated_stock = appropriate_allocated_stock(args.fetch(:existing_allocated_stock) || []) @listing_wh_sp_quantity = args.fetch(:listing_wh_sp_quantity) @wh_routing = args.fetch(:wh_routing, 0) @selected_warehouse_space = args.fetch(:selected_warehouse_space) end |
Instance Attribute Details
#listing ⇒ Object (readonly)
Returns the value of attribute listing.
7 8 9 |
# File 'lib/item_builder_mwh/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_mwh/get_quantity_service.rb', line 7 def variant @variant end |
Instance Method Details
#perform ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/item_builder_mwh/get_quantity_service.rb', line 19 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 |