item_builder 0.1.20 → 0.1.21

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: 05a5aaf51ca610c9a2ea38268de98a9c610205fae9ecbaf2fdc111799264437f
4
- data.tar.gz: a8a1de4a22e3002203db71564da0c88ed2f0440b5ef3d3c43faf7b419d912727
3
+ metadata.gz: 48928bd692d1e23385b374cf0c1e488b40bde748a86a0a648148ec82cb91fce3
4
+ data.tar.gz: 34d42d47a3fe0310969409df85b1b70d29ccdcc7e6ede904d22a078bec914bfb
5
5
  SHA512:
6
- metadata.gz: 105786a98ff16a0531fa9d82078d70ddeae34c0b3516b44f84760a415e8bd22195bc8771905580df71dd8e6d3788dbf65a64b16741bc69b56674b4c9e4013bd8
7
- data.tar.gz: c00f310744876ea11269848eac6dcdef46887a43fc855f92337bb5b1cc90deca4f169cfd20cfc3f1defe751aac53fb03b39edb7a733c42bf6c85e476da0b5b5a
6
+ metadata.gz: 4a17685ebc1909ec2e0156f6f2f0246c5768618ee42e650c2b63f76d78e1bfaef0d392334b6641e186ee8fd816ba324eb5cd94f427fe00a34a1dcb8f5845c7ab
7
+ data.tar.gz: cbfcc3fbc08ee067efeeafe5b02a4a6bbfb48ecc4c8d6c47c4e576ccee00a20ebae46c7cdc2b2897fc0118e6651988d2edba6d549136f106e4f5c9e18744858e
@@ -41,8 +41,8 @@ class ItemBuilder
41
41
 
42
42
  def qty_params(listing)
43
43
  {
44
- listing: listing, wh_spaces: wh_spaces,
45
- variants: variants, stock_allocs: stock_allocs,
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: variant_ids
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 = wh_sp.select {|ws| s.variant_id == bvr.variant_id }.first.quantity
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 wh_sp
93
- @wh_sp ||= WarehouseSpace.where(item_variant_id: variant_ids)
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(:quantity)
107
+ @existing_allocated_stock.sum(&:quantity)
108
108
  end
109
109
 
110
110
  def count_alloc_rsvd_stock
@@ -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.select {|eas| eas.variant_association_id == listing.id }
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ItemBuilder
4
- VERSION = '0.1.20'
4
+ VERSION = '0.1.21'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: item_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.20
4
+ version: 0.1.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - okaaryanata