item_builder 0.1.25 → 0.1.26

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: f7fe5aee9e5ad53c176f35a5f67d68dedcc66bb5475861c432865a1fe762252f
4
- data.tar.gz: d1c4b8a261c1a9839d273b3a9c2fb4aad7a4a5ac62cfec359e9c7b5f1cbc38ed
3
+ metadata.gz: 8492d320599234405f053957073589a52c3338b44df6d9788de69a166dda571a
4
+ data.tar.gz: 61ca9debe7fbd6eb3fb52e7231a486049f2d223fc7f511fbac1bb1aeea63bbc5
5
5
  SHA512:
6
- metadata.gz: 4293e1f028ae58b3a9b1925adad9f24a3e9aeb1262254691c6bda8138cce5dbddcba15011259bdfaadc473ef92b1cd9fa7bc5373f9de2608ee63f60401151bdd
7
- data.tar.gz: b6a48cb493ad29427f51a8d85dc6abf529b2ad09ad8e6498aa606c8d940146f21a3c05d4c63e8d9d732f50171d9f08ed578aab8990ce43bf3243ba241eb7343c
6
+ metadata.gz: 7bc64e7ef1ca238fb7ba1d09348501f55b3417de1982a6b8009fae8687bf3e6213491f209a6104df813ec35a059d935daaab89b8d927a0ee091aa5e551ae7201
7
+ data.tar.gz: 97670ab47df3c2f85bf88fb8f3eb3f56faf6c77d8c302255777eb6e1819ab847235feda7b633c5af06f56df3c6648183c5bc080e4f2640273d10434450df52f6
data/lib/item_builder.rb CHANGED
@@ -26,20 +26,20 @@ class ItemBuilder
26
26
  end
27
27
 
28
28
  def mode_check
29
- if mode == :quantity
30
- quantity_mode
29
+ if mode == :quantity || mode == :simple
30
+ quantity_simple_mode
31
31
  else
32
32
  default
33
33
  end
34
34
  end
35
35
 
36
- def quantity_mode
36
+ def quantity_simple_mode
37
37
  listings.map do |listing|
38
- modes[mode].new(qty_params(listing)).perform
38
+ modes[mode].new(qty_simple_params(listing)).perform
39
39
  end
40
40
  end
41
41
 
42
- def qty_params(listing)
42
+ def qty_simple_params(listing)
43
43
  {
44
44
  listing: listing, wh_spaces: wh_spaces, variants: variants,
45
45
  stock_allocs: stock_allocs, variant_listings: variant_listings,
@@ -37,5 +37,39 @@ class ItemBuilder
37
37
  sku: listing.sku
38
38
  }
39
39
  end
40
+
41
+ def existing_allocated_stock
42
+ existing_alloc_stocks.map do |els|
43
+ if listings.pluck(:id).include?(els.variant_association_id)
44
+ els
45
+ end
46
+ end.compact
47
+ end
48
+
49
+ def listings
50
+ variant_listings.select {|vl| vl.variant_id == listing.variant_id}
51
+ end
52
+
53
+ def bundle_variants
54
+ if bundle.present?
55
+ item_bundle_variants.select {|ibv| ibv.bundle_id == bundle.id }
56
+ end
57
+ end
58
+
59
+ def bundle
60
+ bundles.select {|b| b.variant_id == listing.variant_id }.first
61
+ end
62
+
63
+ def stock_alloc
64
+ stock_allocs.select {|sa| sa.variant_association_id == listing.id }.first
65
+ end
66
+
67
+ def warehouse
68
+ wh_spaces.select {|ws| ws.item_variant_id == listing.variant_id }.first
69
+ end
70
+
71
+ def variant
72
+ variants.select {|v| v.id == listing.variant_id }.first
73
+ end
40
74
  end
41
75
  end
@@ -56,40 +56,6 @@ class ItemBuilder
56
56
  existing_allocated_stock: existing_allocated_stock
57
57
  ).perform
58
58
  end
59
-
60
- def existing_allocated_stock
61
- existing_alloc_stocks.map do |els|
62
- if listings.pluck(:id).include?(els.variant_association_id)
63
- els
64
- end
65
- end.compact
66
- end
67
-
68
- def listings
69
- variant_listings.select {|vl| vl.variant_id == listing.variant_id}
70
- end
71
-
72
- def bundle_variants
73
- if bundle.present?
74
- item_bundle_variants.select {|ibv| ibv.bundle_id == bundle.id }
75
- end
76
- end
77
-
78
- def bundle
79
- bundles.select {|b| b.variant_id == listing.variant_id }.first
80
- end
81
-
82
- def stock_alloc
83
- stock_allocs.select {|sa| sa.variant_association_id == listing.id }.first
84
- end
85
-
86
- def warehouse
87
- wh_spaces.select {|ws| ws.item_variant_id == listing.variant_id }.first
88
- end
89
-
90
- def variant
91
- variants.select {|v| v.id == listing.variant_id }.first
92
- end
93
59
  end
94
60
  end
95
61
  end
@@ -17,7 +17,13 @@ class ItemBuilder
17
17
  end
18
18
 
19
19
  def quantity
20
- QuantityService.new(listing: listing).to_h
20
+ QuantityService.new(
21
+ listing: listing, wh_spaces: wh_spaces, variants: variants,
22
+ stock_allocs: stock_allocs, variant_listings: variant_listings,
23
+ bundles: bundles, item_bundle_variants: item_bundle_variants,
24
+ existing_alloc_stocks: existing_alloc_stocks,
25
+ reserved_stocks: reserved_stocks
26
+ ).to_h
21
27
  end
22
28
 
23
29
  def price
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ItemBuilder
4
- VERSION = '0.1.25'
4
+ VERSION = '0.1.26'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: item_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.25
4
+ version: 0.1.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - okaaryanata
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-29 00:00:00.000000000 Z
11
+ date: 2021-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler