item_builder_mwh 0.1.32 → 0.1.36

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9da445a18b519533b75e157d652b618e614c3ff3bc4388b8ea5d3f7264b6262e
4
- data.tar.gz: '09fdd60c9a5c78216313feff2f1ed5818b49c7a1cd43e28252c080edfb1bbfcf'
3
+ metadata.gz: 3044b951b57b920f3eea27b69237a999a8ce4528b12893658fb9c62f7814beab
4
+ data.tar.gz: 95108a90ba22977428d32d6bc27771574bbdf5767d46da4f3b9ec737c18f28b0
5
5
  SHA512:
6
- metadata.gz: c749e04ccab8b17aa1659bc33c68eefa846784f5050d65879ff59cd73311baf22b52fb6d97d23cd8195a8b8bdb15fd91628c4fd116ff069684f6847fdeecf9c5
7
- data.tar.gz: 63da4cd71aa9c076d2afa53211de2fa90e7462523fa2b6e73a4e5cacafb702abb960726a08676d8477d0ce11d19e2044f59a0df298bc1bb21c2de7632c54341e
6
+ metadata.gz: 3186f7dc5c8c923d5154a710dbb338892eb70d8c78e64599d094311455cb6e9e638c1af981300d4d1d4b4eccf71982c21a35c0c6a7bcd4a2e27cdaab7e1a7231
7
+ data.tar.gz: f8e0cd37864a1922ced00b119f4d132543187511dec8f3d0062a5616ea4ce2c871037a06e4b11fd2aa70d7a61b2f2c577c3bc92a19fc3f12cee036ce8a11bc78
@@ -13,6 +13,7 @@ class ItemBuilderMwh
13
13
  @existing_allocated_stock = args.fetch(:existing_allocated_stock)
14
14
  @listing_wh_sp_quantity = args.fetch(:listing_wh_sp_quantity)
15
15
  @wh_routing = args.fetch(:wh_routing, 0)
16
+ @selected_warehouse_space = args.fetch(:selected_warehouse_space)
16
17
  end
17
18
 
18
19
  def perform
@@ -96,9 +97,8 @@ class ItemBuilderMwh
96
97
  if @bundle_variants.present?
97
98
  qty_list = []
98
99
  @bundle_variants.each do |bvr|
99
- warehouse_space = wh_space.select {|ws| ws.item_variant_id == bvr.variant_id }.first
100
- qty = warehouse_space.quantity if warehouse_space.present?
101
- qty ||= 0
100
+ qty_wh_spaces = wh_space.select {|ws| ws.item_variant_id == bvr.variant_id }
101
+ qty = qty_wh_spaces.sum(&:quantity)
102
102
  qty = qty / bvr.unit
103
103
  qty_list.push(qty)
104
104
  end
@@ -109,7 +109,7 @@ class ItemBuilderMwh
109
109
  end
110
110
 
111
111
  def wh_space
112
- @wh_space ||= WarehouseSpace.where(item_variant_id: variant_ids)
112
+ @wh_space ||= WarehouseSpace.where(item_variant_id: variant_ids, warehouse_id: @selected_warehouse_space.warehouse_id)
113
113
  end
114
114
 
115
115
  def variant_ids
@@ -6,7 +6,7 @@ class ItemBuilderMwh
6
6
  module Quantity
7
7
  class LazadaService < Base
8
8
  def perform
9
- available_quantity + local_qty
9
+ available_quantity
10
10
  end
11
11
  end
12
12
  end
@@ -43,24 +43,24 @@ class ItemBuilderMwh
43
43
 
44
44
  def real_quantity(warehouse_space)
45
45
  if channel_name == 'Zilingo'
46
- qty(warehouse_space.quantity)
46
+ qty(warehouse_space)
47
47
  else
48
- [qty(warehouse_space.quantity), 0].sort[1]
48
+ [qty(warehouse_space), 0].sort[1]
49
49
  end
50
50
  end
51
51
 
52
- def qty(qty)
52
+ def qty(warehouse_space)
53
53
  if channel_name.empty? || channel_name == "Shopify"
54
- available_quantity(qty)
54
+ available_quantity(warehouse_space)
55
55
  else
56
- qty_channel(qty)
56
+ qty_channel(warehouse_space)
57
57
  end
58
58
  end
59
59
 
60
- def qty_channel(qty)
60
+ def qty_channel(warehouse_space)
61
61
  class_name = "ItemBuilderMwh::Modes::Quantity::#{channel_name}Service"
62
62
  qty_channel_service = class_name.constantize
63
- qty_channel_service.new(listing, available_quantity(qty), local_qty.to_i).perform
63
+ qty_channel_service.new(listing, available_quantity(warehouse_space), local_qty.to_i).perform
64
64
  end
65
65
 
66
66
  def channel_name
@@ -95,12 +95,13 @@ class ItemBuilderMwh
95
95
  0
96
96
  end
97
97
 
98
- def available_quantity(qty)
98
+ def available_quantity(warehouse_space)
99
99
  ItemBuilderMwh::GetQuantityService.new(
100
100
  listing: listing, stock_alloc: stock_alloc,
101
101
  variant: variant, bundle_variants: bundle_variants,
102
102
  existing_allocated_stock: existing_allocated_stock,
103
- listing_wh_sp_quantity: qty, wh_routing: wh_routing
103
+ listing_wh_sp_quantity: warehouse_space.quantity, wh_routing: wh_routing,
104
+ selected_warehouse_space: warehouse_space
104
105
  ).perform
105
106
  end
106
107
  end
@@ -101,7 +101,7 @@ class ItemBuilderMwh
101
101
  .joins('JOIN warehouses ON
102
102
  warehouse_spaces.warehouse_id = warehouses.id')
103
103
  .where("warehouse_mappings.profile_channel_association_id=#{pca}")
104
- .where("warehouse_spaces.item_variant_id=#{listing.variant_id}")
104
+ .where("warehouse_spaces.item_variant_id=#{variant_id}")
105
105
  .where('warehouses.consignment = 0')
106
106
  end
107
107
 
@@ -109,6 +109,10 @@ class ItemBuilderMwh
109
109
  listing.profile_channel_association_id.to_s
110
110
  end
111
111
 
112
+ def variant_id
113
+ bundle_variants&.first&.variant_id || listing.variant_id
114
+ end
115
+
112
116
  def warehouse_mapping(warehouse_id)
113
117
  WarehouseMapping
114
118
  .where(profile_channel_association_id:
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ItemBuilderMwh
4
- VERSION = '0.1.32'
4
+ VERSION = '0.1.36'
5
5
  end
@@ -89,7 +89,7 @@ class ItemBuilderMwh
89
89
  def existing_alloc_stocks
90
90
  @existing_alloc_stocks ||= VariantListingStockAllocation.where(
91
91
  variant_association_id: vl_ids
92
- ).where('ADDTIME(end_at, "07:00") >= NOW()')
92
+ ).where('end_at >= NOW()')
93
93
  end
94
94
 
95
95
  def vl_ids
@@ -155,9 +155,7 @@ class ItemBuilderMwh
155
155
  end
156
156
 
157
157
  def lazada_quantity
158
- @lazada_quantity ||= ItemBuilderMwh::LazadaQuantityService.new(
159
- listings: listings, skus: skus
160
- ).perform
158
+ @lazada_quantity ||= nil
161
159
  end
162
160
 
163
161
  def order_host
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: item_builder_mwh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.32
4
+ version: 0.1.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Ivander
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-08 00:00:00.000000000 Z
11
+ date: 2021-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler