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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9f37232cc5638f6027773c0eb43c054e2cebaf8391d3761a7bbf4042925d10e
4
- data.tar.gz: b8e16766478bc199e8ed6670515c23cefa040def49bf0e0e00a44530f228eb58
3
+ metadata.gz: '08f98253d8c700cbb5849d299ce485fc07ec96d5de0df1077e711dff490055b9'
4
+ data.tar.gz: 56f60c4b7f0f5356fb22b58eab61b63bed29e603d5ad44155d55cc6b231d077a
5
5
  SHA512:
6
- metadata.gz: f2f17d7cc7c47352fc6cbbca5ccedc891a930c87e59598cafb807d5122e1d4eeac723ceffc8528d28ed94a4ce38eaf792f6c228478526c9376e89e90770dbebe
7
- data.tar.gz: 670d7ddafddad88ab0b941a93e811e063e0abe76de56efafd53bc9dc0a2c34ca4df90e1bd2a5e56edacb880a2d138515560794d6aa567166f7bbdf86f14075e6
6
+ metadata.gz: 1937a3e7a8853bd0a13d554951ba4f32ff8579237ffe05e0c0510a6cbb689bcdae5bd0ff8320ac9d0b9754d043a4b35ca4670accf1e0928289921658e79605f1
7
+ data.tar.gz: fafb92c7b40c166bd96265618935e1e8aba6aa47977ee13b0727b29326a5c29044ec286d9f64d9ba5cfbb2e7624b246144f8cbe83bb080cf47b55d1a818053d7
@@ -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({zilingo_delta_quantity: zilingo_delta_quantity})
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
- modes[mode].new(listing: listing).perform
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 zilingo_delta_quantity
122
- @zilingo_delta_quantity ||= ItemBuilderMwh::ZilingoQuantityService.new(
129
+ def zilingo_quantity
130
+ @zilingo_quantity ||= ItemBuilderMwh::ZilingoQuantityService.new(
123
131
  listings: listings, skus: skus
124
132
  ).perform
125
133
  end
@@ -38,7 +38,7 @@ class ItemBuilderMwh
38
38
  def check_consignment_variant?
39
39
  listing.consignment? ||
40
40
  (
41
- !listing.active? && [11, 12, 15, 19, 2].include?(listing.channel_id)
41
+ !listing.active? && [11, 12, 15, 19, 2, 18].include?(listing.channel_id)
42
42
  )
43
43
  end
44
44
 
@@ -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 :zilingo_delta_quantity
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
- @zilingo_delta_quantity = args.fetch(:zilingo_delta_quantity, [])
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 :reserved_stock
9
+ attr_reader :local_qty
10
10
 
11
- def initialize(listing, available_quantity, reserved_stock)
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
- @reserved_stock = reserved_stock
16
+ @local_qty = local_qty
17
17
  end
18
18
  end
19
19
  end
@@ -6,7 +6,7 @@ class ItemBuilderMwh
6
6
  module Quantity
7
7
  class LazadaService < Base
8
8
  def perform
9
- available_quantity + reserved_stock.to_i
9
+ available_quantity + local_qty
10
10
  end
11
11
  end
12
12
  end
@@ -6,7 +6,7 @@ class ItemBuilderMwh
6
6
  module Quantity
7
7
  class ZaloraService < Base
8
8
  def perform
9
- available_quantity + reserved_stock.to_i
9
+ available_quantity + local_qty
10
10
  end
11
11
  end
12
12
  end
@@ -6,7 +6,7 @@ class ItemBuilderMwh
6
6
  module Quantity
7
7
  class ZilingoService < Base
8
8
  def perform
9
- available_quantity - reserved_stock.to_i
9
+ available_quantity - local_qty
10
10
  end
11
11
  end
12
12
  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), reserved_stock).perform
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 reserved_stock
55
+ def local_qty
56
56
  if channel_name == 'Zilingo'
57
- zilingo_delta_quantity[listing.local_id].to_i
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), reserved_stock).perform
91
+ qty_channel_service.new(listing, available_quantity(qty), local_qty.to_i).perform
92
92
  end
93
93
 
94
- def reserved_stock
95
- reserved_stocks.find {|rs| rs['variant_id'] == listing.variant_id }['reserved_quantity']
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ItemBuilderMwh
4
- VERSION = '0.1.18'
4
+ VERSION = '0.1.19'
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.18
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-05-25 00:00:00.000000000 Z
11
+ date: 2021-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler