floor_calculator 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/floor_calculator/pricer.rb +7 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 525994f2058fc47b37d0a407c86bf5e7e3f0694f
|
4
|
+
data.tar.gz: 7205f4ae35e4c5058177d4b0c65e27046593bb56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04f99fe1af0ca40e9e6a3f4a7bd370f302892796e2b8f35bb418ec891d6e07fea8bd59fcb2aceac2bc1fa245c6eec20b04125e0881b6c625c7724a08fafba419
|
7
|
+
data.tar.gz: 9a226d3dcf581e8e4b5981533b1fa95332d29a62a9eaff9f196b630f86ef63d3bdaf2c5687fb9d5ad535ae90a8e4c28efbb5d86dbbefbef8a8a4cd836534b5c5
|
@@ -3,6 +3,8 @@ require 'floor_calculator'
|
|
3
3
|
module FloorCalculator
|
4
4
|
class Pricer
|
5
5
|
attr_reader :partial_results, :markups, :source_catalog, :destination, :offer, :weight
|
6
|
+
COST_METHODS = %i[cost_of_overheads cost_to_fill cost_to_ship cost_of_spoilage
|
7
|
+
minimum_profit cost_to_list].freeze
|
6
8
|
|
7
9
|
def initialize(offer, weight, markups)
|
8
10
|
@partial_results = {}
|
@@ -14,15 +16,13 @@ module FloorCalculator
|
|
14
16
|
end
|
15
17
|
|
16
18
|
def calculate_floor
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
round_to_20s(cost_to_list(prepare_options(offer, new_price)).fractional)
|
19
|
+
floor = COST_METHODS.each_with_object(offer.price) do |method, price|
|
20
|
+
public_send(method, prepare_options(offer, price))
|
21
|
+
end
|
22
|
+
round_to_20s(floor.fractional)
|
22
23
|
end
|
23
24
|
|
24
|
-
|
25
|
-
cost_to_ship minimum_profit).each do |method|
|
25
|
+
COST_METHODS.each do |method|
|
26
26
|
define_method method do |options|
|
27
27
|
calculated_value =
|
28
28
|
Solver.calculate(markups, method, options)
|