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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b90b6a038e8128138c7eaac833de24f11a6aa3c0
4
- data.tar.gz: bb0a71604bfbfe1e830582eb6f739aeebe1a7ea5
3
+ metadata.gz: fe185c950b0b83c4214df9d95400c053576af3de
4
+ data.tar.gz: b05b85f7c94883edcf75ecb07f251234d45f00a9
5
5
  SHA512:
6
- metadata.gz: 46e130393515b235022765881e11ed5926f279591843a43308b5caccbcd7e1ded87b91a45aa765101b8b9b8562ceefec42ae00434050b16374a9f051024543b5
7
- data.tar.gz: 640adb6ed441cfb9e5d742519d59d70990015aba1ed8a2d248523d4a4987e49a9014c362817dd7301f2757e9ce94a77433f6018d0221ab09c601ccfcaf636055
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
- COST_METHODS.each do |method|
21
- floor = public_send(method, prepare_options(offer, 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
- COST_METHODS.each do |method|
27
- define_method method do |options|
28
- calculated_value =
29
- Solver.calculate(markups, method, options)
30
- @partial_results[method] = calculated_value
31
- result = options[:price] + calculated_value
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: floor_calculator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marek Mikołajczyk