seshbot-packing 0.2.0 → 0.7.0
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 +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/lib/seshbot/packing/package.rb +10 -9
- data/lib/seshbot/packing/recipe.rb +27 -15
- data/lib/seshbot/packing/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: bc2128e8b492960b7f2884c5cf7867673d5c8aa57f1af7b9bcd33db76573fc9b
|
4
|
+
data.tar.gz: 1e73660ee059d28c64c278d0e10cc34f3beee5ea693c74f74f795dec64cc95ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 274c0bd6812eca6f29cef6309a4cb9db65e20cb45b5e468dcc4f38815043980b7ceedb8fc415c2b8ee8c117f43fa7f476e9ff4ef7cc9ea9f840c84c358e35d3c
|
7
|
+
data.tar.gz: b5596d94568c96088425011d4ebe48993b0b065f4d9d3dea3bc7bdad83f2d91227a8e4544062b76ba781b199875ab6acb1168d277fbd5f444ec6f40783ca2618
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -23,23 +23,18 @@ module Seshbot
|
|
23
23
|
if result == "B504"
|
24
24
|
result = "B312"
|
25
25
|
end
|
26
|
+
raise "Cannot determine packaged size for SKU: #{sku}" if result.nil?
|
26
27
|
result.gsub!(/^C/, 'B')
|
27
28
|
result
|
28
29
|
end
|
29
30
|
|
30
31
|
def bundle_items(items, fulfilled_at: nil)
|
31
|
-
if fulfilled_at
|
32
|
+
if fulfilled_at.present?
|
32
33
|
bundling_start_date = DateTime.new(2020, 1, 14, 8, 0, 0, Time.new.zone)
|
33
34
|
result = items.map { |item| { "sku" => item.sku, "quantity" => item.quantity, "price" => item.price } }
|
34
35
|
return result if fulfilled_at < bundling_start_date # TODO remove bundling start date method
|
35
36
|
end
|
36
37
|
|
37
|
-
product_type_prices = Hash.new(0)
|
38
|
-
items.each do |item|
|
39
|
-
size = packaged_size(item["sku"])
|
40
|
-
product_type_prices[size] += item["price"]
|
41
|
-
end
|
42
|
-
|
43
38
|
# get a hash of {pack_6: 5, pack_12: 1}
|
44
39
|
product_type_counts = count_product_types(items)
|
45
40
|
|
@@ -55,8 +50,14 @@ module Seshbot
|
|
55
50
|
|
56
51
|
|
57
52
|
def unpack(product_type_counts)
|
58
|
-
|
59
|
-
|
53
|
+
final_result = product_type_counts
|
54
|
+
|
55
|
+
while true
|
56
|
+
new_result = pack_single_step(final_result, unpacking: true)
|
57
|
+
break if new_result == final_result
|
58
|
+
final_result = new_result
|
59
|
+
end
|
60
|
+
final_result
|
60
61
|
end
|
61
62
|
|
62
63
|
def pack_single_step(product_type_counts, unpacking:)
|
@@ -4,41 +4,53 @@ module Seshbot
|
|
4
4
|
class << self
|
5
5
|
def get_recipes
|
6
6
|
{
|
7
|
-
"
|
7
|
+
"bottles_twenty_four_pack_4"=>{
|
8
8
|
"input_fragment"=>"B306",
|
9
9
|
"input_quantity"=>4,
|
10
10
|
"output_fragment"=>"B324",
|
11
11
|
"output_quantity"=>1
|
12
12
|
},
|
13
|
-
"
|
13
|
+
"bottles_twenty_four_pack_3"=>{
|
14
14
|
"input_fragment"=>"B306",
|
15
15
|
"input_quantity"=>3,
|
16
16
|
"output_fragment"=>"B318",
|
17
17
|
"output_quantity"=>1
|
18
18
|
},
|
19
|
-
"
|
19
|
+
"bottles_twelve_pack"=>{
|
20
20
|
"input_fragment"=>"B306",
|
21
21
|
"input_quantity"=>2,
|
22
22
|
"output_fragment"=>"B312",
|
23
23
|
"output_quantity"=>1
|
24
24
|
},
|
25
|
+
"bottles_six_pack"=>{
|
26
|
+
"input_fragment"=>"B301",
|
27
|
+
"input_quantity"=>6,
|
28
|
+
"output_fragment"=>"B306",
|
29
|
+
"output_quantity"=>1
|
30
|
+
},
|
25
31
|
"cans_twenty_four_pack_4"=>{
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
32
|
+
"input_fragment"=>"C306",
|
33
|
+
"input_quantity"=>4,
|
34
|
+
"output_fragment"=>"C324",
|
35
|
+
"output_quantity"=>1
|
30
36
|
},
|
31
37
|
"cans_twenty_four_pack_3"=>{
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
38
|
+
"input_fragment"=>"C306",
|
39
|
+
"input_quantity"=>3,
|
40
|
+
"output_fragment"=>"C318",
|
41
|
+
"output_quantity"=>1
|
36
42
|
},
|
37
43
|
"cans_twelve_pack"=>{
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
44
|
+
"input_fragment"=>"C306",
|
45
|
+
"input_quantity"=>2,
|
46
|
+
"output_fragment"=>"C312",
|
47
|
+
"output_quantity"=>1
|
48
|
+
},
|
49
|
+
"cans_six_pack"=>{
|
50
|
+
"input_fragment"=>"C301",
|
51
|
+
"input_quantity"=>6,
|
52
|
+
"output_fragment"=>"C306",
|
53
|
+
"output_quantity"=>1
|
42
54
|
}
|
43
55
|
}
|
44
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seshbot-packing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shaun
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|