floor_calculator 0.3.1 → 0.4.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: 9c9a29685f7d4b2abb4e140d89c7e3aec911a7fd
4
- data.tar.gz: 88439edb17d4f8c5f022f755c6c6d3ebba0210c0
3
+ metadata.gz: 8545db4c50032048bbb5848243c2ec1d0e4cee70
4
+ data.tar.gz: 386510178eed75014f1a78faf3444f1c8af62676
5
5
  SHA512:
6
- metadata.gz: 928a60f6ca3861a18075eda3a3d12062475e7135df021917a72a846d7beff232f7c28a29f4d7e03dc0467550f2f7b335949b39bcf0e0149777f4aa21dc61d74a
7
- data.tar.gz: 1af3242a8ca6c988332e679a5e0e355c6a98e127ff1fef4c70609fd2c65579bbcd410d8bbe4e3bb7ac7c6737a473518a8e2282f8939a1b38288de8dd6006c814
6
+ metadata.gz: ad9a4853bc96963413eaaa0223076084ac8ba9cf494f5581d67c5c1ce22bd22f558d16b4cff58d58f217b51f8a1029bc5ca98a9845c878c9181da15a02946fb0
7
+ data.tar.gz: 18879e8286cb8fc9619ca64897105329d9c4d5944124211f2b74a44a30003744b1fe45f03398b0aa12c84410739812b9bec61176e1e1d01cb33b1ddadb2f08c2
@@ -37,6 +37,7 @@ module FloorCalculator
37
37
  def prepare_options(offer, price)
38
38
  {
39
39
  source: offer[:source_catalog],
40
+ country: offer.country.to_s.downcase,
40
41
  destination: offer.catalog,
41
42
  price: price,
42
43
  condition: offer.condition,
@@ -13,8 +13,12 @@ module FloorCalculator
13
13
  @markups = markups
14
14
  markup = markups.fetch(markup_name.to_s, {})
15
15
  source_formula = source_markup(markup, options[:source])
16
- @formula = destination_markup(source_formula, options[:destination])
17
- raise "Formula not found for: #{options[:source]}, #{options[:destination]}" if @formula.nil?
16
+ country_formula = country_markup(source_formula, options[:country].to_s.downcase)
17
+ @formula = destination_markup(country_formula, options[:destination])
18
+ if @formula.nil?
19
+ raise "Formula not found for: #{options[:source]}, "\
20
+ "#{options[:country].to_s.downcase}, #{options[:destination]}"
21
+ end
18
22
  @price = options[:price]
19
23
  @weight = options[:weight]
20
24
  @fast = options[:fast]
@@ -34,6 +38,10 @@ module FloorCalculator
34
38
  result
35
39
  end
36
40
 
41
+ def country_markup(source, country)
42
+ source.fetch(country) { source.fetch('default', {}) }
43
+ end
44
+
37
45
  def destination_markup(source, destination)
38
46
  source.fetch(destination) { source.fetch('default', nil) }
39
47
  end
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.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marek Mikołajczyk