item_builder_mwh 0.1.46 → 0.1.48

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: bce7977aea75ad1bd97df14619406111699aa96e40346f29396223733a6aeeda
4
- data.tar.gz: b28d83dc417c3b56c987e24b1b430121f5f93e28fa8022d2cdad4a809b8ef189
3
+ metadata.gz: b79051347f62ea880e963ec7a20788dee46c3146e2d74f4a7393a5b1d2d25b86
4
+ data.tar.gz: 012d3e641d8eac47c7cc225bde3a45e21384713f9173891e6fc454ec43e7e63e
5
5
  SHA512:
6
- metadata.gz: 7009a572231c435b5de10d7c10ef7083feba8ac5c48d949703095bbfadaffcc31d94d5b8bba26d43735960e7735b8062ffd704fe58f369e68cfc401a30b51338
7
- data.tar.gz: 4c5785354cd3100bb785a010570734697c1b8e14bfb867bd4eac1f572b3c51601f64a6524e0bb09951f24216f62f58427a81fa344a7dea19adea6b4c8a058ee5
6
+ metadata.gz: fc70a90c7ff23f21d20ad50d5909b99e81252d8076f12545f28ce55248312d178503ae3ab49a5b17ed032414679288b2522563683a55472a7e1c261b0de7d9ec
7
+ data.tar.gz: 7035ece13341b7f8868398f41ba4f754eb339fc4dd3a003851ab9961da4389d23635daad0b243f28f15d6159a9f04615680f65b1a56af21c45ac21451524531b
@@ -10,7 +10,7 @@ class ItemBuilderMwh
10
10
  @variant = args.fetch(:variant)
11
11
  @stock_alloc = args.fetch(:stock_alloc)
12
12
  @bundle_variants = args.fetch(:bundle_variants)
13
- @existing_allocated_stock = args.fetch(:existing_allocated_stock)
13
+ @existing_allocated_stock = appropriate_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
16
  @selected_warehouse_space = args.fetch(:selected_warehouse_space)
@@ -149,5 +149,22 @@ class ItemBuilderMwh
149
149
  def one_alloc_rsvd_stock(allocated_stock)
150
150
  RestClient.get("#{host}?#{params(allocated_stock)}")
151
151
  end
152
+
153
+ def appropriate_allocated_stock(existing_allocated_stock)
154
+ map_store_ids = VariantListing.where(id: existing_allocated_stock.map(&:variant_association_id)).select(:id, :profile_channel_association_id).to_h
155
+ wh_mapping_by_store = wh_mapping_by_store(map_store_ids.values.flatten.uniq)
156
+ existing_allocated_stock.select do |allocated_stock|
157
+ wh_mapping_by_store[map_store_ids[allocated_stock.variant_association_id]] == wh_ids&.first
158
+ end
159
+ end
160
+
161
+ def wh_mapping_by_store(ids)
162
+ WarehouseMapping
163
+ .joins(:warehouse)
164
+ .where(
165
+ profile_channel_association_id: ids,
166
+ warehouses: { consignment: false }
167
+ ).select(:profile_channel_association_id, :warehouse_id).to_h
168
+ end
152
169
  end
153
170
  end
@@ -12,7 +12,8 @@ class ItemBuilderMwh
12
12
  new_condition: listing.new_condition,
13
13
  minimum_order: listing.minimum_order,
14
14
  etalase_id: listing.tokopedia_showcase_id,
15
- master_option_types: master_option_types
15
+ master_option_types: master_option_types,
16
+ images: images
16
17
  }
17
18
  end
18
19
 
@@ -36,6 +37,17 @@ class ItemBuilderMwh
36
37
  .pluck(:name)
37
38
  .map{|name| YAML.load(name)}
38
39
  end
40
+
41
+ def images
42
+ listing.item_listing_variant_images.map do |img|
43
+ {
44
+ id: img.id,
45
+ local_id: img.local_id,
46
+ local_url: img.local_url,
47
+ url: img.image.image.url(:xlarge, timestamp: false)
48
+ }
49
+ end
50
+ end
39
51
  end
40
52
  end
41
53
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ItemBuilderMwh
4
- VERSION = '0.1.46'
4
+ VERSION = '0.1.48'
5
5
  end
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.46
4
+ version: 0.1.48
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Ivander
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-30 00:00:00.000000000 Z
11
+ date: 2022-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -177,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
177
  - !ruby/object:Gem::Version
178
178
  version: '0'
179
179
  requirements: []
180
- rubygems_version: 3.3.7
180
+ rubygems_version: 3.0.9
181
181
  signing_key:
182
182
  specification_version: 4
183
183
  summary: Item Builder Multiwarehouse