Sha256: 2e2b174c1ee54309a568bdd1ab21b2d0f96e2a72a4595aa2b37210d497178a2d

Contents?: true

Size: 490 Bytes

Versions: 26

Compression:

Stored size: 490 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
    value = item_total * self.preferred_flat_percent / 100.0
    (value * 100).round.to_f / 100
  end
end

Version data entries

26 entries across 26 versions & 6 rubygems

Version Path
apispree_core-0.0.0 app/models/calculator/flat_percent_item_total.rb
My-Commerce_core-1.1.0 app/models/calculator/flat_percent_item_total.rb
My-Commerce_core-1.0.0 app/models/calculator/flat_percent_item_total.rb
MyCommerceapi-1.0.0 core/app/models/calculator/flat_percent_item_total.rb
MyCommerce-0.0.3 core/app/models/calculator/flat_percent_item_total.rb
rfcommerce_core-0.0.3 app/models/calculator/flat_percent_item_total.rb
spree_core-0.60.6 app/models/calculator/flat_percent_item_total.rb
spree_core-0.60.5 app/models/calculator/flat_percent_item_total.rb
spree_core-0.40.4 app/models/calculator/flat_percent_item_total.rb
spree_core-0.50.4 app/models/calculator/flat_percent_item_total.rb
spree_core-0.60.4 app/models/calculator/flat_percent_item_total.rb
spree_core-0.50.3 app/models/calculator/flat_percent_item_total.rb
spree_core-0.60.3 app/models/calculator/flat_percent_item_total.rb
spree_core-0.60.2 app/models/calculator/flat_percent_item_total.rb
spree_core-0.70.0.rc2 app/models/calculator/flat_percent_item_total.rb
spree_core-0.70.RC1 app/models/calculator/flat_percent_item_total.rb
spree_core-0.60.1 app/models/calculator/flat_percent_item_total.rb
spree_core-0.60.0 app/models/calculator/flat_percent_item_total.rb
spree_core-0.60.0.RC1 app/models/calculator/flat_percent_item_total.rb
spree_core-0.50.2 app/models/calculator/flat_percent_item_total.rb