item_builder_mwh 0.1.18 → 0.1.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/item_builder_mwh.rb +12 -4
- data/lib/item_builder_mwh/get_quantity_service.rb +1 -1
- data/lib/item_builder_mwh/modes.rb +2 -2
- data/lib/item_builder_mwh/modes/quantity/base.rb +3 -3
- data/lib/item_builder_mwh/modes/quantity/lazada_service.rb +1 -1
- data/lib/item_builder_mwh/modes/quantity/zalora_service.rb +1 -1
- data/lib/item_builder_mwh/modes/quantity/zilingo_service.rb +1 -1
- data/lib/item_builder_mwh/modes/quantity_service.rb +6 -3
- data/lib/item_builder_mwh/modes/simple_service.rb +13 -3
- data/lib/item_builder_mwh/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08f98253d8c700cbb5849d299ce485fc07ec96d5de0df1077e711dff490055b9'
|
4
|
+
data.tar.gz: 56f60c4b7f0f5356fb22b58eab61b63bed29e603d5ad44155d55cc6b231d077a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1937a3e7a8853bd0a13d554951ba4f32ff8579237ffe05e0c0510a6cbb689bcdae5bd0ff8320ac9d0b9754d043a4b35ca4670accf1e0928289921658e79605f1
|
7
|
+
data.tar.gz: fafb92c7b40c166bd96265618935e1e8aba6aa47977ee13b0727b29326a5c29044ec286d9f64d9ba5cfbb2e7624b246144f8cbe83bb080cf47b55d1a818053d7
|
data/lib/item_builder_mwh.rb
CHANGED
@@ -38,7 +38,7 @@ class ItemBuilderMwh
|
|
38
38
|
listings.map do |listing|
|
39
39
|
if listing.channel_id == 18
|
40
40
|
new_param = qty_simple_params(listing)
|
41
|
-
.merge({
|
41
|
+
.merge({zilingo_quantity: zilingo_quantity})
|
42
42
|
|
43
43
|
modes[mode].new(new_param).perform
|
44
44
|
elsif listing.channel_id == 13
|
@@ -54,7 +54,15 @@ class ItemBuilderMwh
|
|
54
54
|
|
55
55
|
def default
|
56
56
|
listings.map do |listing|
|
57
|
-
|
57
|
+
if listing.channel_id == 2 && mode == :active
|
58
|
+
modes[mode].new(qty_simple_params(listing)).perform
|
59
|
+
elsif listing.channel_id == 18 && mode == :active
|
60
|
+
modes[mode].new(qty_simple_params(listing)
|
61
|
+
.merge(zilingo_quantity: zilingo_quantity)
|
62
|
+
).perform
|
63
|
+
else
|
64
|
+
modes[mode].new(listing: listing).perform
|
65
|
+
end
|
58
66
|
end
|
59
67
|
end
|
60
68
|
|
@@ -118,8 +126,8 @@ class ItemBuilderMwh
|
|
118
126
|
@skus ||= listings.map(&:local_id).uniq
|
119
127
|
end
|
120
128
|
|
121
|
-
def
|
122
|
-
@
|
129
|
+
def zilingo_quantity
|
130
|
+
@zilingo_quantity ||= ItemBuilderMwh::ZilingoQuantityService.new(
|
123
131
|
listings: listings, skus: skus
|
124
132
|
).perform
|
125
133
|
end
|
@@ -16,7 +16,7 @@ class ItemBuilderMwh
|
|
16
16
|
attr_reader :existing_alloc_stocks
|
17
17
|
attr_reader :variant_listings
|
18
18
|
attr_reader :reserved_stocks
|
19
|
-
attr_reader :
|
19
|
+
attr_reader :zilingo_quantity
|
20
20
|
attr_reader :zalora_reserved_stock
|
21
21
|
def initialize(args)
|
22
22
|
@listing = args.fetch(:listing)
|
@@ -28,7 +28,7 @@ class ItemBuilderMwh
|
|
28
28
|
@existing_alloc_stocks = args.fetch(:existing_alloc_stocks, [])
|
29
29
|
@variant_listings = args.fetch(:variant_listings, [])
|
30
30
|
@reserved_stocks = args.fetch(:reserved_stocks, [])
|
31
|
-
@
|
31
|
+
@zilingo_quantity = args.fetch(:zilingo_quantity, [])
|
32
32
|
@zalora_reserved_stock = args.fetch(:zalora_reserved_stock, [])
|
33
33
|
warehouse
|
34
34
|
end
|
@@ -6,14 +6,14 @@ class ItemBuilderMwh
|
|
6
6
|
class Base
|
7
7
|
attr_reader :listing
|
8
8
|
attr_reader :available_quantity
|
9
|
-
attr_reader :
|
9
|
+
attr_reader :local_qty
|
10
10
|
|
11
|
-
def initialize(listing, available_quantity,
|
11
|
+
def initialize(listing, available_quantity, local_qty)
|
12
12
|
raise 'listing is not set' if listing.nil?
|
13
13
|
|
14
14
|
@listing = listing
|
15
15
|
@available_quantity = available_quantity
|
16
|
-
@
|
16
|
+
@local_qty = local_qty
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -45,18 +45,21 @@ class ItemBuilderMwh
|
|
45
45
|
def qty_channel(qty)
|
46
46
|
class_name = "ItemBuilderMwh::Modes::Quantity::#{channel_name}Service"
|
47
47
|
qty_channel_service = class_name.constantize
|
48
|
-
qty_channel_service.new(listing, available_quantity(qty),
|
48
|
+
qty_channel_service.new(listing, available_quantity(qty), local_qty.to_i).perform
|
49
49
|
end
|
50
50
|
|
51
51
|
def channel_name
|
52
52
|
QUANTITY_CHANNEL[listing.channel_id].to_s
|
53
53
|
end
|
54
54
|
|
55
|
-
def
|
55
|
+
def local_qty
|
56
56
|
if channel_name == 'Zilingo'
|
57
|
-
|
57
|
+
return 0 if zilingo_quantity.blank?
|
58
|
+
|
59
|
+
zilingo_quantity[listing.local_id].to_i
|
58
60
|
elsif channel_name == 'Zalora'
|
59
61
|
return 0 if zalora_reserved_stock.blank?
|
62
|
+
|
60
63
|
zalora_reserved_stock[listing.local_id].to_i
|
61
64
|
else
|
62
65
|
reserved_stocks.find {|rs| rs['variant_id'] == listing.variant_id }['reserved_quantity']
|
@@ -88,11 +88,21 @@ class ItemBuilderMwh
|
|
88
88
|
def qty_channel(qty)
|
89
89
|
class_name = "ItemBuilderMwh::Modes::Quantity::#{quantity_name}Service"
|
90
90
|
qty_channel_service = class_name.constantize
|
91
|
-
qty_channel_service.new(listing, available_quantity(qty),
|
91
|
+
qty_channel_service.new(listing, available_quantity(qty), local_qty.to_i).perform
|
92
92
|
end
|
93
93
|
|
94
|
-
def
|
95
|
-
|
94
|
+
def local_qty
|
95
|
+
if channel_name == 'Zilingo'
|
96
|
+
return 0 if zilingo_quantity.blank?
|
97
|
+
|
98
|
+
zilingo_quantity[listing.local_id].to_i
|
99
|
+
elsif channel_name == 'Zalora'
|
100
|
+
return 0 if zalora_reserved_stock.blank?
|
101
|
+
|
102
|
+
zalora_reserved_stock[listing.local_id].to_i
|
103
|
+
else
|
104
|
+
reserved_stocks.find {|rs| rs['variant_id'] == listing.variant_id }['reserved_quantity']
|
105
|
+
end
|
96
106
|
end
|
97
107
|
|
98
108
|
def available_quantity(qty)
|
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.
|
4
|
+
version: 0.1.19
|
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
|
+
date: 2021-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|