Sha256: 7ead7fe191038875ca2020d7e0dba007df0dc86a074e9cbdb66b5a1fea0833c5

Contents?: true

Size: 454 Bytes

Versions: 19

Compression:

Stored size: 454 Bytes

Contents

require_dependency 'spree/shipping_calculator'

module Spree
  module Calculator::Shipping
    class FlatPercentItemTotal < ShippingCalculator
      preference :flat_percent, :decimal, default: 0

      def compute_package(package)
        compute_from_price(total(package.contents))
      end

      def compute_from_price(price)
        value = price * BigDecimal(preferred_flat_percent.to_s) / 100.0
        value.round(2)
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
solidus_core-2.4.2 app/models/spree/calculator/shipping/flat_percent_item_total.rb
solidus_core-2.3.1 app/models/spree/calculator/shipping/flat_percent_item_total.rb
solidus_core-2.4.1 app/models/spree/calculator/shipping/flat_percent_item_total.rb
solidus_core-2.2.2 app/models/spree/calculator/shipping/flat_percent_item_total.rb
solidus_core-2.1.1 app/models/spree/calculator/shipping/flat_percent_item_total.rb
solidus_core-2.4.0 app/models/spree/calculator/shipping/flat_percent_item_total.rb
solidus_core-2.4.0.rc1 app/models/spree/calculator/shipping/flat_percent_item_total.rb
solidus_core-2.4.0.beta1 app/models/spree/calculator/shipping/flat_percent_item_total.rb
solidus_core-2.3.0 app/models/spree/calculator/shipping/flat_percent_item_total.rb
solidus_core-2.3.0.rc3 app/models/spree/calculator/shipping/flat_percent_item_total.rb
solidus_core-2.3.0.rc2 app/models/spree/calculator/shipping/flat_percent_item_total.rb
solidus_core-2.3.0.rc1 app/models/spree/calculator/shipping/flat_percent_item_total.rb
solidus_core-2.3.0.beta1 app/models/spree/calculator/shipping/flat_percent_item_total.rb
solidus_core-2.2.1 app/models/spree/calculator/shipping/flat_percent_item_total.rb
solidus_core-2.2.0 app/models/spree/calculator/shipping/flat_percent_item_total.rb
solidus_core-2.2.0.rc1 app/models/spree/calculator/shipping/flat_percent_item_total.rb
solidus_core-2.2.0.beta1 app/models/spree/calculator/shipping/flat_percent_item_total.rb
solidus_core-2.1.0 app/models/spree/calculator/shipping/flat_percent_item_total.rb
solidus_core-2.1.0.rc1 app/models/spree/calculator/shipping/flat_percent_item_total.rb