tiny_builder 0.2.3 → 0.2.5

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: 05a45b04a328cfa7d0a09e78678b7e414c5b1e5ceff7434baaabca56c014e926
4
- data.tar.gz: 6f39cdef8b1b3b712f3d204f7b26ba34d895c8c7ea70a044dbc90d3a822a5293
3
+ metadata.gz: 3b1aa960d2ca0a701307b0e42a87cfaa04fb1cc79e7b6c93edea686475cb60ec
4
+ data.tar.gz: cde6147e66a52b4ea53266c5f6bda5717caa4b1a3e4e8a65955887d28dca9cf1
5
5
  SHA512:
6
- metadata.gz: cf511d8ad9b79bc1e3126aee1800753c911dc1faf1ce0d7e81a7797cc33e6b4b8e379ae0a798837d6364fe269222c2a747b780bd4d7e6379cf8416bb77c2e385
7
- data.tar.gz: ca3c588673a3c2d7cf606855577de0f9dc5a12a2c4303b050bdfd2868c724be14bc54b7dbcc575352cea867e7bc470d9748b33c5016a4b16ad9c870dc389c86f
6
+ metadata.gz: ca74c43055014bc237dd433bc26ae4487f1b98b2aaa4921957c73efab706d476e7e1ea6acbeda0395346225be64e03c07570af2c7ca59801a0a19dd80991e1af
7
+ data.tar.gz: 6162db162dd9dbacd5cf67d399c89d01911f66bdc2a4d2462c6c0dc32f38ed93cab5bb57a988bb353764b90d7eadc705dfecd64506518d7ceb04089d31e0e4c3
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ class MongoWarehouse
4
+ include Mongoid::Document
5
+ include Mongoid::Attributes::Dynamic
6
+
7
+ store_in collection: 'warehouses', client: 'inventory'
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ class MongoWarehouseMapping
4
+ include Mongoid::Document
5
+ include Mongoid::Attributes::Dynamic
6
+
7
+ store_in collection: 'warehouse_mappings', client: 'inventory'
8
+ end
@@ -26,9 +26,12 @@ class TinyBuilder
26
26
  end
27
27
 
28
28
  def warehouse_mappings
29
- @warehouse_mappings ||= WarehouseMapping.joins(:warehouse).where(
30
- profile_channel_association_id: account_id
31
- ).where(warehouses: {consignment: false})
29
+ @warehouse_mappings ||= get_warehouse_mappings
30
+ end
31
+
32
+ def get_warehouse_mappings
33
+ wh_mappings = MongoWarehouseMapping.where(profile_channel_association_id: account_id).map{|wm| wm}
34
+ wh_mappings.select{|wm| !MongoWarehouse.find_by(old_id: wm.warehouse_id).consignment }
32
35
  end
33
36
 
34
37
  def warehouse_mapping
@@ -36,7 +39,7 @@ class TinyBuilder
36
39
  end
37
40
 
38
41
  def mapped_wh_mappings
39
- @mapped_wh_mappings ||= warehouse_mappings.pluck(:warehouse_id, :channel_warehouse_id).to_h
42
+ @mapped_wh_mappings ||= warehouse_mappings.map{|wm| [wm.warehouse_id, wm.channel_warehouse_id] }.to_h
40
43
  end
41
44
 
42
45
  def associated_listings
@@ -25,13 +25,10 @@ class TinyBuilder
25
25
  end
26
26
 
27
27
  def warehouse_stock
28
- case variant.config.downcase
29
- when 'default'
28
+ if bundle?
29
+ qty_bundle
30
+ else
30
31
  qty_default(warehouse_space)
31
- when 'free gift', 'combo'
32
- qty_bundle
33
- else
34
- raise "config not recognize => #{variant.config}"
35
32
  end
36
33
  end
37
34
 
@@ -86,5 +83,10 @@ class TinyBuilder
86
83
  return [] unless bundle
87
84
  bundle.bundle_variants.select { |bv| !bv[:main] }
88
85
  end
86
+
87
+ def bundle?
88
+ product = MasterProduct.find_by("variants.id": variant.id)
89
+ product.variants.find{|v| v["id"] == variant.id}["bundle_id"].present?
90
+ end
89
91
  end
90
92
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class TinyBuilder
4
- VERSION = '0.2.3'
4
+ VERSION = '0.2.5'
5
5
  end
data/lib/tiny_builder.rb CHANGED
@@ -5,6 +5,8 @@ require 'models/master_product'
5
5
  require 'models/mongo_item_listing'
6
6
  require 'models/mongo_variant_listing'
7
7
  require 'models/mongo_warehouse_space'
8
+ require 'models/mongo_warehouse'
9
+ require 'models/mongo_wh_mapping'
8
10
  require 'models/allocation'
9
11
  require 'tiny_builder/version'
10
12
  require 'tiny_builder/mode_executor'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - hayakaza
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-03 00:00:00.000000000 Z
11
+ date: 2025-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -133,11 +133,12 @@ files:
133
133
  - lib/models/master_product.rb
134
134
  - lib/models/mongo_item_listing.rb
135
135
  - lib/models/mongo_variant_listing.rb
136
+ - lib/models/mongo_warehouse.rb
136
137
  - lib/models/mongo_warehouse_space.rb
138
+ - lib/models/mongo_wh_mapping.rb
137
139
  - lib/tiny_builder.rb
138
140
  - lib/tiny_builder/active_builder.rb
139
141
  - lib/tiny_builder/allocated_stock.rb
140
- - lib/tiny_builder/allocation.rb
141
142
  - lib/tiny_builder/apigateway_helper.rb
142
143
  - lib/tiny_builder/base_builder.rb
143
144
  - lib/tiny_builder/data_loader.rb
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Allocation
4
- include Mongoid::Document
5
- include Mongoid::Attributes::Dynamic
6
-
7
- store_in collection: 'warehouse_space_allocations', client: 'inventory'
8
-
9
- belongs_to :warehouse_space, class_name: 'MongoWarehouseSpace'
10
- end