Sha256: cdc1291d283b93991c8883740f82307948f5ada06e6924e5a3cbeef2679d80e7

Contents?: true

Size: 447 Bytes

Versions: 4

Compression:

Stored size: 447 Bytes

Contents

class Calculator::FlatPercentItemTotal < Calculator
  preference :flat_percent, :decimal, :default => 0

  def self.description
    I18n.t("flat_percent")
  end

  def self.register
    super
    ShippingMethod.register_calculator(self)
  end

  def compute(object)
    return unless object.present? and object.line_items.present?
    item_total = object.line_items.map(&:amount).sum
    item_total * self.preferred_flat_percent / 100.0
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spree_core-0.30.2 app/models/calculator/flat_percent_item_total.rb
spree_core-0.30.1 app/models/calculator/flat_percent_item_total.rb
spree_core-0.30.0 app/models/calculator/flat_percent_item_total.rb
spree_core-0.30.0.beta1 app/models/calculator/flat_percent_item_total.rb