flowcommerce_spree 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/spree/flow_io_product_decorator.rb +14 -10
- data/lib/flowcommerce_spree/version.rb +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: d0e6c714f8986d91af70150c8365f3bde79a15b843151cc84bf5fabd83cf7e87
         | 
| 4 | 
            +
              data.tar.gz: 4b0b172606e24bddd55d8254da339af2bf4751b441d918478310835102c9f282
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 915818b7f7ffd75a3e2adf67d25403b5ea342b0095f2b051d4044ef91c942bee15e2e6b0a235a62f53b7e95af88f6b2626f0a3a58767214e413ad9fc3695a36a
         | 
| 7 | 
            +
              data.tar.gz: '048827e500e921d90c3dba7169644a09702f89551be7083820b0d4c337a97a0f513609417dee1f9017f266a8f28bf846dcb5c124262dee7fed03defecbda97fd'
         | 
| @@ -28,9 +28,9 @@ module Spree | |
| 28 28 | 
             
                  flow_data["#{flow_exp.key}.excluded"].to_i != 1
         | 
| 29 29 | 
             
                end
         | 
| 30 30 |  | 
| 31 | 
            -
                def price_range(product_zone)
         | 
| 31 | 
            +
                def price_range(product_zone, currencies = [])
         | 
| 32 32 | 
             
                  prices = {}
         | 
| 33 | 
            -
                   | 
| 33 | 
            +
                  master_prices_with_currencies(currencies).each do |p|
         | 
| 34 34 | 
             
                    currency = p.currency
         | 
| 35 35 | 
             
                    min = nil
         | 
| 36 36 | 
             
                    max = nil
         | 
| @@ -40,15 +40,15 @@ module Spree | |
| 40 40 | 
             
                        price = v.price_in(currency)
         | 
| 41 41 | 
             
                        next if price.nil? || price.amount.nil?
         | 
| 42 42 |  | 
| 43 | 
            -
                        min = price  | 
| 44 | 
            -
                        max = price  | 
| 43 | 
            +
                        min = [price, min].compact.min { |a, b| a.amount <=> b.amount }
         | 
| 44 | 
            +
                        max = [price, max].compact.max { |a, b| a.amount <=> b.amount }
         | 
| 45 45 | 
             
                      end
         | 
| 46 46 | 
             
                    else
         | 
| 47 47 | 
             
                      min = max = master.price_in(currency)
         | 
| 48 48 | 
             
                    end
         | 
| 49 49 |  | 
| 50 | 
            -
                    rmin = min | 
| 51 | 
            -
                    rmax = max | 
| 50 | 
            +
                    rmin = round_with_precision(min, 0)
         | 
| 51 | 
            +
                    rmax = round_with_precision(max, 0)
         | 
| 52 52 |  | 
| 53 53 | 
             
                    prices[currency] = { min: rmin, max: rmax }
         | 
| 54 54 | 
             
                  end
         | 
| @@ -56,6 +56,10 @@ module Spree | |
| 56 56 | 
             
                  add_flow_price_range(prices, product_zone)
         | 
| 57 57 | 
             
                end
         | 
| 58 58 |  | 
| 59 | 
            +
                def round_with_precision(number, precision)
         | 
| 60 | 
            +
                  number&.amount&.to_s(:rounded, precision: precision) || 0
         | 
| 61 | 
            +
                end
         | 
| 62 | 
            +
             | 
| 59 63 | 
             
                def add_flow_price_range(prices, product_zone)
         | 
| 60 64 | 
             
                  flow_experience_key = product_zone&.flow_data&.[]('key')
         | 
| 61 65 | 
             
                  return prices if flow_experience_key.blank?
         | 
| @@ -70,8 +74,8 @@ module Spree | |
| 70 74 | 
             
                      price = v.flow_local_price(flow_experience_key)
         | 
| 71 75 | 
             
                      next if price.amount.nil? || price.currency != currency
         | 
| 72 76 |  | 
| 73 | 
            -
                      min = price  | 
| 74 | 
            -
                      max = price  | 
| 77 | 
            +
                      min = [price, min].compact.min { |a, b| a.amount <=> b.amount }
         | 
| 78 | 
            +
                      max = [price, max].compact.max { |a, b| a.amount <=> b.amount }
         | 
| 75 79 | 
             
                    end
         | 
| 76 80 | 
             
                  end
         | 
| 77 81 |  | 
| @@ -80,8 +84,8 @@ module Spree | |
| 80 84 | 
             
                    max ||= master_price
         | 
| 81 85 | 
             
                  end
         | 
| 82 86 |  | 
| 83 | 
            -
                  rmin = min | 
| 84 | 
            -
                  rmax = max | 
| 87 | 
            +
                  rmin = round_with_precision(min, 0)
         | 
| 88 | 
            +
                  rmax = round_with_precision(max, 0)
         | 
| 85 89 |  | 
| 86 90 | 
             
                  prices[currency] = { min: rmin, max: rmax }
         | 
| 87 91 | 
             
                  prices
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: flowcommerce_spree
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.11
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Aurel Branzeanu
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2021-08- | 
| 12 | 
            +
            date: 2021-08-05 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: active_model_serializers
         |