item_builder 0.1.25 → 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.rb +5 -5
- data/lib/item_builder/modes.rb +34 -0
- data/lib/item_builder/modes/quantity_service.rb +0 -34
- data/lib/item_builder/modes/simple_service.rb +7 -1
- data/lib/item_builder/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8492d320599234405f053957073589a52c3338b44df6d9788de69a166dda571a
|
4
|
+
data.tar.gz: 61ca9debe7fbd6eb3fb52e7231a486049f2d223fc7f511fbac1bb1aeea63bbc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
36
|
+
def quantity_simple_mode
|
37
37
|
listings.map do |listing|
|
38
|
-
modes[mode].new(
|
38
|
+
modes[mode].new(qty_simple_params(listing)).perform
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
def
|
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,
|
data/lib/item_builder/modes.rb
CHANGED
@@ -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(
|
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
|
data/lib/item_builder/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2021-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|