item_builder_mwh 0.1.27 → 0.1.31

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: 04b4fda61b151bdae803aa466654125bfdd93fac256ba962ddcc7e7e5c05aed0
4
- data.tar.gz: fd2c4433e919374acd2d64065791eca10fb554c10408bc75a207d6fc104734b8
3
+ metadata.gz: '05372970b369a4a3600e27649c65c533c3234ab4be22f6626ee54661bedcd148'
4
+ data.tar.gz: 32b67a281c340c239e6a6f2e2ec4a9906bab6bd1fd5d44661fc95691fa365277
5
5
  SHA512:
6
- metadata.gz: 457e75fd354af093c0cfcf399d3657f555e0efcd2e9dd5e791fc68a0c6d33c3308bf233653f582065ea960cc9336974c54d77dbb5127980a7114f2b08b1223f7
7
- data.tar.gz: d8cda55e85a6777e3ea70711c980209c864af0ae0b6d760f28ec9d9893a54bf5a28db8c230b91650208d83edae3a9b05a72c44e4a129f053c616a87d0b1d4644
6
+ metadata.gz: d9ccaca56ca1183b1bfa1943e88e0e14d5343949bd03004bb12f33533be31b1393b76594b64ad44cbd6b24a44622f7ba8978a6d07cd0709d94c7aa01d3b9f279
7
+ data.tar.gz: 77fecc6feb7ff0e039a7cdf5fd7f389d79defa10d956d7a6df93702f5ca4707478ecce991ca1683a3a124eb1f61f8d0af8ff787812f72bdb8854ac23c9f15c22
@@ -49,7 +49,7 @@ class ItemBuilderMwh
49
49
  qty = sku['multiWarehouseInventories'][0]
50
50
  hash[sku['SellerSku']] = qty['occupyQuantity'] + qty['withholdQuantity']
51
51
  end
52
- end
52
+ end if resp['data'].present?
53
53
  hash
54
54
  end
55
55
 
@@ -15,10 +15,10 @@ class ItemBuilderMwh
15
15
  def to_h(warehouse_space)
16
16
  {
17
17
  active: listing.active,
18
- quantity: warehouse_space.quantity,
19
- warehouse_id: wh_mapping(
18
+ quantity: warehouse_space&.quantity || 0,
19
+ warehouse_id: warehouse_space.present? ? wh_mapping(
20
20
  warehouse_space.warehouse_id
21
- )
21
+ ) : ''
22
22
  }
23
23
  end
24
24
  end
@@ -35,9 +35,9 @@ class ItemBuilderMwh
35
35
 
36
36
  def warehouse_ids(warehouse_space)
37
37
  {
38
- warehouse_id: wh_mapping(
38
+ warehouse_id: warehouse_space.present? ? wh_mapping(
39
39
  warehouse_space.warehouse_id
40
- )
40
+ ) : ''
41
41
  }
42
42
  end
43
43
 
@@ -33,20 +33,19 @@ class ItemBuilderMwh
33
33
  end
34
34
 
35
35
  def to_h(warehouse_space)
36
- if channel_name == "Zilingo"
37
- {
38
- quantity: qty(warehouse_space.quantity),
39
- warehouse_id: wh_mapping(
40
- warehouse_space.warehouse_id
41
- )
42
- }
36
+ {
37
+ quantity: warehouse_space.present? ? real_quantity(warehouse_space) : 0,
38
+ warehouse_id: warehouse_space.present? ? wh_mapping(
39
+ warehouse_space.warehouse_id
40
+ ) : ''
41
+ }
42
+ end
43
+
44
+ def real_quantity(warehouse_space)
45
+ if channel_name == 'Zilingo'
46
+ qty(warehouse_space.quantity)
43
47
  else
44
- {
45
- quantity: [qty(warehouse_space.quantity), 0].sort[1],
46
- warehouse_id: wh_mapping(
47
- warehouse_space.warehouse_id
48
- )
49
- }
48
+ [qty(warehouse_space.quantity), 0].sort[1]
50
49
  end
51
50
  end
52
51
 
@@ -41,14 +41,14 @@ class ItemBuilderMwh
41
41
 
42
42
  def warehouse_ids(warehouse_space)
43
43
  {
44
- warehouse_id: wh_mapping(
44
+ warehouse_id: warehouse_space.present? ? wh_mapping(
45
45
  warehouse_space.warehouse_id
46
- )
46
+ ) : ''
47
47
  }
48
48
  end
49
49
 
50
50
  def simple(warehouse_space)
51
- qty = warehouse_space.quantity
51
+ qty = warehouse_space&.quantity || 0
52
52
  qty(qty).merge(
53
53
  price
54
54
  )
@@ -92,11 +92,11 @@ class ItemBuilderMwh
92
92
  end
93
93
 
94
94
  def local_qty
95
- if channel_name == 'Zilingo'
95
+ if quantity_name == 'Zilingo'
96
96
  return 0 if zilingo_quantity.blank?
97
97
 
98
98
  zilingo_quantity[listing.local_id].to_i
99
- elsif channel_name == 'Zalora'
99
+ elsif quantity_name == 'Zalora'
100
100
  return 0 if zalora_reserved_stock.blank?
101
101
 
102
102
  zalora_reserved_stock[listing.local_id].to_i
@@ -80,9 +80,17 @@ class ItemBuilderMwh
80
80
  if multiwarehouse && wh_routing == 1
81
81
  warehouses << to_h(warehouse_spaces.first)
82
82
  else
83
+ warehouse_list
84
+ end
85
+ end
86
+
87
+ def warehouse_list
88
+ if warehouse_spaces.present?
83
89
  warehouse_spaces.each do |warehouse_space|
84
90
  warehouses << to_h(warehouse_space)
85
91
  end
92
+ else
93
+ warehouses << to_h(nil)
86
94
  end
87
95
  end
88
96
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ItemBuilderMwh
4
- VERSION = '0.1.27'
4
+ VERSION = '0.1.31'
5
5
  end
@@ -57,7 +57,7 @@ class ItemBuilderMwh
57
57
  hash = Hash.new
58
58
  resp.dig("SuccessResponse", "Body", "ProductStocks", "ProductStock").each do |sku|
59
59
  hash[sku['SellerSku']] = sku['ReservedStock']
60
- end
60
+ end if resp.dig('SuccessResponse').present?
61
61
  hash
62
62
  end
63
63
 
@@ -46,7 +46,7 @@ class ItemBuilderMwh
46
46
  hash = Hash.new
47
47
  resp['zilingoSKUQuantities'].each do |sku|
48
48
  hash[sku['zilingoSKUId']] = sku['quantity'] + sku['frozenQuantity']
49
- end
49
+ end if resp['zilingoSKUQuantities'].present?
50
50
  hash
51
51
  end
52
52
 
@@ -40,29 +40,23 @@ class ItemBuilderMwh
40
40
  listings.map do |listing|
41
41
  next unless listing.local_id.present?
42
42
 
43
- if listing.channel_id == 18
44
- new_param = qty_simple_params(listing)
45
- .merge({zilingo_quantity: zilingo_quantity})
46
-
47
- modes[mode].new(new_param).perform
48
- elsif listing.channel_id == 13
49
- new_param = qty_simple_params(listing)
50
- .merge({zalora_reserved_stock: zalora_reserved_stock})
51
-
52
- modes[mode].new(new_param).perform
53
- elsif listing.channel_id == 2
54
- new_param = qty_simple_params(listing)
55
- .merge({shopify_inventory_location: shopify_inventory_location})
56
-
57
- modes[mode].new(new_param).perform
58
- elsif listing.channel_id == 3
59
- new_param = qty_simple_params(listing)
60
- .merge({lazada_quantity: lazada_quantity})
61
-
62
- modes[mode].new(new_param).perform
63
- else
64
- modes[mode].new(qty_simple_params(listing)).perform
65
- end
43
+ param =
44
+ if listing.channel_id == 18
45
+ qty_simple_params(listing)
46
+ .merge(zilingo_quantity: zilingo_quantity)
47
+ elsif listing.channel_id == 13
48
+ qty_simple_params(listing)
49
+ .merge(zalora_reserved_stock: zalora_reserved_stock)
50
+ elsif listing.channel_id == 2
51
+ qty_simple_params(listing)
52
+ .merge({shopify_inventory_location: shopify_inventory_location})
53
+ elsif listing.channel_id == 3
54
+ qty_simple_params(listing)
55
+ .merge({lazada_quantity: lazada_quantity})
56
+ else
57
+ qty_simple_params(listing)
58
+ end
59
+ modes[mode].new(param).perform
66
60
  end.compact
67
61
  end
68
62
 
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.27
4
+ version: 0.1.31
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-09-03 00:00:00.000000000 Z
11
+ date: 2021-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler