seshbot-packing 0.2.0 → 0.7.0

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: fb6f487a85ab3bea24e16e9d12c02ae511a58e5e79b2cf76e647cc0c064e8db0
4
- data.tar.gz: 347038a58ec75af02cd61551cc05210257f49fee6ef2841c359a01cdc388ccc7
3
+ metadata.gz: bc2128e8b492960b7f2884c5cf7867673d5c8aa57f1af7b9bcd33db76573fc9b
4
+ data.tar.gz: 1e73660ee059d28c64c278d0e10cc34f3beee5ea693c74f74f795dec64cc95ea
5
5
  SHA512:
6
- metadata.gz: 62b68bf0c4ec15a201d60a33d0528bef7d7357178be258743eb6e1fe0f026c2bf03800ddd4310ca9b9dcad2bc7cd52b999bbfe4c00b02012a95f5df3c014c7d0
7
- data.tar.gz: 372ff6ce363c20a1d82aea75c0bfd460acdd04b67c2d37967f4a51468b72bad2b8e585bd512a594537688e60ccbbef5a2f3a2c057998ac166689dcc78f4ab758
6
+ metadata.gz: 274c0bd6812eca6f29cef6309a4cb9db65e20cb45b5e468dcc4f38815043980b7ceedb8fc415c2b8ee8c117f43fa7f476e9ff4ef7cc9ea9f840c84c358e35d3c
7
+ data.tar.gz: b5596d94568c96088425011d4ebe48993b0b065f4d9d3dea3bc7bdad83f2d91227a8e4544062b76ba781b199875ab6acb1168d277fbd5f444ec6f40783ca2618
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ *.gem
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- seshbot-packing (0.2.0)
4
+ seshbot-packing (0.5.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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
- result = pack_single_step(product_type_counts, unpacking: true)
59
- result
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
- "twenty_four_pack_4"=>{
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
- "twenty_four_pack_3"=>{
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
- "twelve_pack"=>{
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
- "input_fragment"=>"C306",
27
- "input_quantity"=>4,
28
- "output_fragment"=>"C324",
29
- "output_quantity"=>1
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
- "input_fragment"=>"C306",
33
- "input_quantity"=>3,
34
- "output_fragment"=>"C318",
35
- "output_quantity"=>1
38
+ "input_fragment"=>"C306",
39
+ "input_quantity"=>3,
40
+ "output_fragment"=>"C318",
41
+ "output_quantity"=>1
36
42
  },
37
43
  "cans_twelve_pack"=>{
38
- "input_fragment"=>"C306",
39
- "input_quantity"=>2,
40
- "output_fragment"=>"C312",
41
- "output_quantity"=>1
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
@@ -1,5 +1,5 @@
1
1
  module Seshbot
2
2
  module Packing
3
- VERSION = "0.2.0"
3
+ VERSION = "0.7.0"
4
4
  end
5
5
  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.2.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-15 00:00:00.000000000 Z
11
+ date: 2020-12-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: