floor_calculator 0.2.1 → 0.3.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 +9 -12
- 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: fe185c950b0b83c4214df9d95400c053576af3de
|
4
|
+
data.tar.gz: b05b85f7c94883edcf75ecb07f251234d45f00a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60bbfb0045d413053a228daf8b04e23143f0ffbe6fa6ff04543cd49ed0deb357bc661aa222616e48475ce01b96027549af7ffbc64975e1c72a4da2eea1470cf3
|
7
|
+
data.tar.gz: 04dcedee3b828a5041f10209481964540811ca632cde0cf8d5f7ca18bb34c795833aef0842e28cc4ad1e1e50342f8f361759471561a2fd53e00871abc44ec009
|
@@ -3,8 +3,6 @@ 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
|
8
6
|
|
9
7
|
def initialize(offer, weight, markups)
|
10
8
|
@partial_results = {}
|
@@ -12,25 +10,24 @@ module FloorCalculator
|
|
12
10
|
@weight = weight
|
13
11
|
@offer = offer
|
14
12
|
@source_catalog = offer[:source_catalog]
|
13
|
+
@types = markups['pipelines']['floor_calculation']
|
15
14
|
@destination = offer.catalog
|
16
15
|
end
|
17
16
|
|
18
17
|
def calculate_floor
|
19
18
|
floor = offer.price
|
20
|
-
|
21
|
-
floor =
|
19
|
+
@types.each do |method|
|
20
|
+
floor = cost_method(method, prepare_options(offer, floor))
|
22
21
|
end
|
23
22
|
round_to_20s(floor.fractional)
|
24
23
|
end
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
result
|
33
|
-
end
|
25
|
+
def cost_method(name, options)
|
26
|
+
calculated_value =
|
27
|
+
Solver.calculate(markups, name, options).round(4)
|
28
|
+
@partial_results[name] = calculated_value
|
29
|
+
result = options[:price] + calculated_value
|
30
|
+
result
|
34
31
|
end
|
35
32
|
|
36
33
|
def round_to_20s(price)
|