item_builder 0.1.20 → 0.1.21
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48928bd692d1e23385b374cf0c1e488b40bde748a86a0a648148ec82cb91fce3
|
4
|
+
data.tar.gz: 34d42d47a3fe0310969409df85b1b70d29ccdcc7e6ede904d22a078bec914bfb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a17685ebc1909ec2e0156f6f2f0246c5768618ee42e650c2b63f76d78e1bfaef0d392334b6641e186ee8fd816ba324eb5cd94f427fe00a34a1dcb8f5845c7ab
|
7
|
+
data.tar.gz: cbfcc3fbc08ee067efeeafe5b02a4a6bbfb48ecc4c8d6c47c4e576ccee00a20ebae46c7cdc2b2897fc0118e6651988d2edba6d549136f106e4f5c9e18744858e
|
data/lib/item_builder.rb
CHANGED
@@ -41,8 +41,8 @@ class ItemBuilder
|
|
41
41
|
|
42
42
|
def qty_params(listing)
|
43
43
|
{
|
44
|
-
listing: listing, wh_spaces: wh_spaces,
|
45
|
-
|
44
|
+
listing: listing, wh_spaces: wh_spaces, variants: variants,
|
45
|
+
stock_allocs: stock_allocs, variant_listings: variant_listings,
|
46
46
|
bundles: bundles, item_bundle_variants: item_bundle_variants,
|
47
47
|
existing_alloc_stocks: existing_alloc_stocks
|
48
48
|
}
|
@@ -85,7 +85,7 @@ class ItemBuilder
|
|
85
85
|
|
86
86
|
def stock_allocs
|
87
87
|
@stock_allocs ||= VariantListingStockAllocation.where(
|
88
|
-
variant_association_id:
|
88
|
+
variant_association_id: vl_ids
|
89
89
|
)
|
90
90
|
end
|
91
91
|
|
@@ -78,7 +78,7 @@ class ItemBuilder
|
|
78
78
|
if @bundle_variants.present?
|
79
79
|
qty_list = []
|
80
80
|
@bundle_variants.each do |bvr|
|
81
|
-
qty =
|
81
|
+
qty = wh_space.select {|ws| ws.item_variant_id == bvr.variant_id }.first.quantity
|
82
82
|
qty ||= 0
|
83
83
|
qty = qty / bvr.unit
|
84
84
|
qty_list.push(qty)
|
@@ -89,8 +89,8 @@ class ItemBuilder
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
def
|
93
|
-
@
|
92
|
+
def wh_space
|
93
|
+
@wh_space ||= WarehouseSpace.where(item_variant_id: variant_ids)
|
94
94
|
end
|
95
95
|
|
96
96
|
def variant_ids
|
@@ -104,7 +104,7 @@ class ItemBuilder
|
|
104
104
|
def count_existing_alloc_stock
|
105
105
|
return 0 if @existing_allocated_stock.blank?
|
106
106
|
|
107
|
-
@existing_allocated_stock.sum(
|
107
|
+
@existing_allocated_stock.sum(&:quantity)
|
108
108
|
end
|
109
109
|
|
110
110
|
def count_alloc_rsvd_stock
|
data/lib/item_builder/modes.rb
CHANGED
@@ -15,6 +15,7 @@ class ItemBuilder
|
|
15
15
|
attr_reader :bundles
|
16
16
|
attr_reader :item_bundle_variants
|
17
17
|
attr_reader :existing_alloc_stocks
|
18
|
+
attr_reader :variant_listings
|
18
19
|
def initialize(args)
|
19
20
|
@listing = args.fetch(:listing)
|
20
21
|
@wh_spaces = args.fetch(:wh_spaces, [])
|
@@ -23,6 +24,7 @@ class ItemBuilder
|
|
23
24
|
@bundles = args.fetch(:bundles, [])
|
24
25
|
@item_bundle_variants = args.fetch(:item_bundle_variants, [])
|
25
26
|
@existing_alloc_stocks = args.fetch(:existing_alloc_stocks, [])
|
27
|
+
@variant_listings = args.fetch(:variant_listings, [])
|
26
28
|
end
|
27
29
|
|
28
30
|
def base
|
@@ -54,7 +54,15 @@ class ItemBuilder
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def existing_allocated_stock
|
57
|
-
existing_alloc_stocks.
|
57
|
+
existing_alloc_stocks.map do |els|
|
58
|
+
if listings.pluck(:id).include?(els.variant_association_id)
|
59
|
+
els
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def listings
|
65
|
+
variant_listings.select {|vl| vl.variant_id == listing.variant_id}
|
58
66
|
end
|
59
67
|
|
60
68
|
def bundle_variants
|
data/lib/item_builder/version.rb
CHANGED