item_builder_mwh 0.1.28 → 0.1.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb7b98bbb829748842913583d5fd9b676ae548d49eccf88e2cbd39967e3dc20e
4
- data.tar.gz: d3a91b8e34b5644bcaffd6bccac057595df3c9a0161633dd19c58da2cece9fe1
3
+ metadata.gz: 2b78cf06c6468a43cb0276bce86475e9e26225998a51a07ebc0f5abcccbb275a
4
+ data.tar.gz: 26f16ef4c2b1e4c0d27ba8f1da2817b1c185713c0fa64af76f440ce9ec218eec
5
5
  SHA512:
6
- metadata.gz: 378009edaa560ef37c91565a64c8907dc39b62873ecf61de4a174ab30b13027fea05d3c8379b1b7f9f5ead88a0b607e2b6df97e7b3b0936cf6832297cce176d3
7
- data.tar.gz: 5f386b734f3bb639dc81dd55bf3286c4f7d58fd6b888573a0e9afdd8a944220a73b6232f89a97ea55a3bb24538d1e50719fee986b428b1b2389558135a725db5
6
+ metadata.gz: 5db1144fc273bb1861c8477a72dfc9d119c98e6c0fddb9befc07d13b431bfe116075ec0c70b315de618b2d7ddc35f9c8d8e4b241f8e26421d15b8a3ec502ac55
7
+ data.tar.gz: 0a02b711a5dd12ebd751ffa106f786949456c25b555638962a102fbee3ef57c9ee5bb34e34e37d9af6ba673c357b8be82f88b88d21895293a4bbed43ef79bff4
@@ -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.28'
4
+ VERSION = '0.1.29'
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.28
4
+ version: 0.1.29
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-06 00:00:00.000000000 Z
11
+ date: 2021-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler