item_builder_mwh 0.1.22 → 0.1.26
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/get_quantity_service.rb +15 -4
- data/lib/item_builder_mwh/modes/quantity_service.rb +4 -2
- data/lib/item_builder_mwh/shopify_quantity_service.rb +16 -6
- data/lib/item_builder_mwh/version.rb +1 -1
- data/lib/item_builder_mwh/zalora_quantity_service.rb +2 -0
- data/lib/item_builder_mwh.rb +14 -10
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e01aa6ef954cf51bc3dcb92ca26f17d430c4ea1fc51d4ef8c90fecfc990f0fd
|
4
|
+
data.tar.gz: f11f2141638776fa7aa54fed48488b4b5435288dcd9367290d51443963d2434b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fff1385a38d7539f9ecf9776fb3fd2d6bc06047035cae7f529b9e5f11bb4de9107a21b1dca457a579d3fb6b59bcec691b0b5799b37ef5e98a40d45cb96e4982
|
7
|
+
data.tar.gz: 5e8dea305c73d37530197d3506d5f9a697c35e4690281d96465e93b0f65d59ad73f8ca20897fae1bdcc4ccee0b10f600d419968a7f596aeb977cafa06d305f03
|
@@ -79,10 +79,18 @@ class ItemBuilderMwh
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def listing_warehouse_routing_quantity
|
82
|
-
warehouse_spaces = WarehouseSpace.where(item_variant_id: variant.id)
|
82
|
+
warehouse_spaces = WarehouseSpace.where(item_variant_id: variant.id, warehouse_id: wh_ids)
|
83
83
|
warehouse_spaces.sum(:quantity)
|
84
84
|
end
|
85
85
|
|
86
|
+
def wh_mappings
|
87
|
+
WarehouseMapping.where(profile_channel_association_id: listing.profile_channel_association_id)
|
88
|
+
end
|
89
|
+
|
90
|
+
def wh_ids
|
91
|
+
@wh_ids ||= wh_mappings.map{|x|x.warehouse_id}.flatten.uniq
|
92
|
+
end
|
93
|
+
|
86
94
|
def qty_bundle
|
87
95
|
# Quantity for bundle config
|
88
96
|
if @bundle_variants.present?
|
@@ -128,9 +136,12 @@ class ItemBuilderMwh
|
|
128
136
|
end
|
129
137
|
|
130
138
|
def params(allocated_stock)
|
131
|
-
|
132
|
-
|
133
|
-
|
139
|
+
{
|
140
|
+
channel_id: allocated_stock.variant_listing.channel_id,
|
141
|
+
item_variant_id: allocated_stock.variant_listing.variant_id,
|
142
|
+
start_at: allocated_stock.start_at.to_date.beginning_of_day,
|
143
|
+
end_at: allocated_stock.end_at.to_date.end_of_day
|
144
|
+
}.to_query
|
134
145
|
end
|
135
146
|
|
136
147
|
# one_alloc_rsvd_stock fungsi untuk mendapatkan satu
|
@@ -21,7 +21,9 @@ class ItemBuilderMwh
|
|
21
21
|
|
22
22
|
def perform
|
23
23
|
if channel_name == "Shopify"
|
24
|
-
|
24
|
+
dataSIL = shopify_inventory_location[listing.local_id]
|
25
|
+
|
26
|
+
base.merge!(dataSIL, warehouse: warehouses ) if dataSIL.present?
|
25
27
|
else
|
26
28
|
base.merge!(
|
27
29
|
warehouse: warehouses
|
@@ -31,7 +33,7 @@ class ItemBuilderMwh
|
|
31
33
|
|
32
34
|
def to_h(warehouse_space)
|
33
35
|
if channel_name == "Zilingo"
|
34
|
-
{
|
36
|
+
{
|
35
37
|
quantity: qty(warehouse_space.quantity),
|
36
38
|
warehouse_id: wh_mapping(
|
37
39
|
warehouse_space.warehouse_id
|
@@ -14,9 +14,14 @@ class ItemBuilderMwh
|
|
14
14
|
def perform
|
15
15
|
datas = {}
|
16
16
|
@listings.each do |listing|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
if listing.local_id.present?
|
18
|
+
@listing = listing
|
19
|
+
@sku = listing.local_id
|
20
|
+
resp = response_process
|
21
|
+
next if resp[:inventory_item_id].nil? || resp[:inventory_item_id] == 0
|
22
|
+
|
23
|
+
datas[@sku] = resp
|
24
|
+
end
|
20
25
|
end
|
21
26
|
|
22
27
|
# update variant real_local_id database icava
|
@@ -100,8 +105,12 @@ class ItemBuilderMwh
|
|
100
105
|
def response_process
|
101
106
|
hash = Hash.new
|
102
107
|
|
103
|
-
|
104
|
-
|
108
|
+
begin
|
109
|
+
hash[:inventory_item_id] = inventory_item_id.to_i
|
110
|
+
hash[:location_id] = location_id.to_i
|
111
|
+
rescue
|
112
|
+
hash
|
113
|
+
end
|
105
114
|
|
106
115
|
hash
|
107
116
|
end
|
@@ -109,8 +118,9 @@ class ItemBuilderMwh
|
|
109
118
|
def rest_client(params, rescued_codes = 200)
|
110
119
|
RestClient::Request.execute(params.merge(timeout: 3)) do |response|
|
111
120
|
code = response.code
|
121
|
+
resp = response.body.to_str
|
112
122
|
unless Array.wrap(rescued_codes).include?(code)
|
113
|
-
raise "Response Code is #{code}"
|
123
|
+
raise "Response Code is #{code}" unless resp.include?('Response code = 404')
|
114
124
|
end
|
115
125
|
|
116
126
|
response
|
@@ -47,6 +47,8 @@ class ItemBuilderMwh
|
|
47
47
|
raise "Response Code is #{resp.dig("response_code")}"
|
48
48
|
elsif resp.dig('ErrorResponse', 'Head', 'ErrorMessage') == 'E009: Access Denied'
|
49
49
|
return nil
|
50
|
+
elsif resp.dig('ErrorResponse').present?
|
51
|
+
return nil
|
50
52
|
end
|
51
53
|
success_handle(resp)
|
52
54
|
end
|
data/lib/item_builder_mwh.rb
CHANGED
@@ -37,6 +37,8 @@ class ItemBuilderMwh
|
|
37
37
|
|
38
38
|
def quantity_simple_mode
|
39
39
|
listings.map do |listing|
|
40
|
+
next unless listing.local_id.present?
|
41
|
+
|
40
42
|
if listing.channel_id == 18
|
41
43
|
new_param = qty_simple_params(listing)
|
42
44
|
.merge({zilingo_quantity: zilingo_quantity})
|
@@ -55,19 +57,21 @@ class ItemBuilderMwh
|
|
55
57
|
else
|
56
58
|
modes[mode].new(qty_simple_params(listing)).perform
|
57
59
|
end
|
58
|
-
end
|
60
|
+
end.compact
|
59
61
|
end
|
60
62
|
|
61
63
|
def default
|
62
64
|
listings.map do |listing|
|
63
|
-
if listing.
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
65
|
+
if listing.local_id.present?
|
66
|
+
if listing.channel_id == 2 && mode == :active
|
67
|
+
modes[mode].new(qty_simple_params(listing)).perform
|
68
|
+
elsif listing.channel_id == 18 && mode == :active
|
69
|
+
modes[mode].new(qty_simple_params(listing)
|
70
|
+
.merge(zilingo_quantity: zilingo_quantity)
|
71
|
+
).perform
|
72
|
+
else
|
73
|
+
modes[mode].new(listing: listing).perform
|
74
|
+
end
|
71
75
|
end
|
72
76
|
end
|
73
77
|
end
|
@@ -176,6 +180,6 @@ class ItemBuilderMwh
|
|
176
180
|
end
|
177
181
|
|
178
182
|
def listings
|
179
|
-
@listings ||= VariantListing.where(id: listing_ids)
|
183
|
+
@listings ||= VariantListing.joins(:variant).where(id: listing_ids)
|
180
184
|
end
|
181
185
|
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.
|
4
|
+
version: 0.1.26
|
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-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
167
|
requirements: []
|
168
|
-
rubygems_version: 3.
|
168
|
+
rubygems_version: 3.2.3
|
169
169
|
signing_key:
|
170
170
|
specification_version: 4
|
171
171
|
summary: Item Builder Multiwarehouse
|