item_builder_mwh 0.1.47 → 0.1.49

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: 4fcf40ca468a06cfbfba282400c026b98a98549ac95b5c355b219613f80809e4
4
- data.tar.gz: 2f67bbbe6492e65abac33573c07f02f1b734e069660e8bb80e6e1c3a9ff2453c
3
+ metadata.gz: 4c684bd1ca1d60ef042e9ff7b481f1a09103fb086333e132b1df399cf3e4401c
4
+ data.tar.gz: 1761355253dbed7f682c225367962d400e440a473973aac1d1a366dc5595f65d
5
5
  SHA512:
6
- metadata.gz: 35848b583b002229004c80aad457dcc3b45d8d938b066258cf9449f7cc457712d023ba3fed2939e0cf0aedbee4960e12250778dc04c8b743d9e1bcd8cc095ffb
7
- data.tar.gz: 7ea2198492cc024d6d10ef7d6853b9f9f5064cb6043636f6b4f04d29c0b6b3c2a9fd47164480b970ef16fc7e2e6934ae52dfa66fa91d823caf2a1b609effac95
6
+ metadata.gz: 25f05619f7a6237bf7fb2ebf45ca70cd9a96e7c1963fa5fb3c72993452928d1568e75312b2019d539a71057abeed0bd31564b3f1834a132f9ecf4f245c92424d
7
+ data.tar.gz: a0b6f17096b4524dad7cd91cee8ff9b5a626c6d5797324386f0f609f76386cd431d0f2fc1f90d65dda7cff09259f948bb795b4b40cabe11736a32b6487733243
@@ -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
@@ -10,17 +10,11 @@ class ItemBuilderMwh
10
10
  def perform
11
11
  {
12
12
  price: listing.price,
13
- sale_price: sale_price,
13
+ sale_price: sale_price_policy.sale_price,
14
14
  sale_start_at: listing.sale_start_at,
15
15
  sale_end_at: listing.sale_end_at
16
16
  }
17
17
  end
18
-
19
- private
20
-
21
- def sale_price
22
- sale_price_policy.on_sale? ? listing.sale_price : listing.price
23
- end
24
18
  end
25
19
  end
26
20
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ItemBuilderMwh
4
- VERSION = '0.1.47'
4
+ VERSION = '0.1.49'
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.47
4
+ version: 0.1.49
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-10-11 00:00:00.000000000 Z
11
+ date: 2022-11-23 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