Sha256: 6fe76c448c249500c3f1050622d0d52722c7160b75197b965860415d9e7bdca7

Contents?: true

Size: 489 Bytes

Versions: 13

Compression:

Stored size: 489 Bytes

Contents

require_dependency 'spree/calculator'

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

    def self.description
      Spree.t(:flat_percent)
    end

    def compute(object)
      return unless object.present? and object.respond_to?(:item_total)
      item_total = object.item_total
      value = item_total * BigDecimal(self.preferred_flat_percent.to_s) / 100.0
      (value * 100).round.to_f / 100
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
spree_core-2.1.12 app/models/spree/calculator/flat_percent_item_total.rb
spree_core-2.1.11 app/models/spree/calculator/flat_percent_item_total.rb
spree_core-2.1.10 app/models/spree/calculator/flat_percent_item_total.rb
spree_core-2.1.9 app/models/spree/calculator/flat_percent_item_total.rb
spree_core-2.1.8 app/models/spree/calculator/flat_percent_item_total.rb
spree_core-2.1.7 app/models/spree/calculator/flat_percent_item_total.rb
spree_core-2.1.6 app/models/spree/calculator/flat_percent_item_total.rb
spree_core-2.1.5 app/models/spree/calculator/flat_percent_item_total.rb
spree_core-2.1.4 app/models/spree/calculator/flat_percent_item_total.rb
spree_core-2.1.3 app/models/spree/calculator/flat_percent_item_total.rb
spree_core-2.1.2 app/models/spree/calculator/flat_percent_item_total.rb
spree_core-2.1.1 app/models/spree/calculator/flat_percent_item_total.rb
spree_core-2.1.0 app/models/spree/calculator/flat_percent_item_total.rb