Class: ItemBuilder::Modes::ActiveService

Inherits:
Object
  • Object
show all
Includes:
ItemBuilder::Modes
Defined in:
lib/item_builder/modes/active_service.rb

Instance Attribute Summary

Attributes included from ItemBuilder::Modes

#bundles, #existing_alloc_stocks, #item_bundle_variants, #lazada_quantity, #listing, #shipping_providers, #shopify_inventory_location, #stock_allocs, #variant_listings, #variants, #wh_id, #wh_spaces, #zalora_reserved_stock, #zilingo_quantity

Instance Method Summary collapse

Methods included from ItemBuilder::Modes

#base, #bundle, #bundle_variants, #existing_allocated_stock, #initialize, #listings, #stock_alloc, #variant, #warehouse

Instance Method Details

#active_variantObject



32
33
34
35
36
# File 'lib/item_builder/modes/active_service.rb', line 32

def active_variant
  VariantListing
    .where(local_item_id: listing.local_item_id,
           active: 1)
end

#performObject



10
11
12
# File 'lib/item_builder/modes/active_service.rb', line 10

def perform
  to_h.merge(base).merge(quantity)
end

#quantityObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/item_builder/modes/active_service.rb', line 21

def quantity
  QuantityService.new(
    listing: listing, wh_spaces: wh_spaces, variants: variants,
    stock_allocs: stock_allocs, variant_listings: variant_listings,
    bundles: bundles, item_bundle_variants: item_bundle_variants,
    existing_alloc_stocks: existing_alloc_stocks,
    zilingo_quantity: zilingo_quantity,
    zalora_reserved_stock: zalora_reserved_stock
  ).to_h
end

#to_hObject



14
15
16
17
18
19
# File 'lib/item_builder/modes/active_service.rb', line 14

def to_h
  {
    active: listing.active,
    active_variant: active_variant.count
  }
end