Sha256: eb1e5c2f45d93e6abc68201b80b5f0a5d68d6dfac7f5590958dc6c4cb0cb1c97

Contents?: true

Size: 689 Bytes

Versions: 14

Compression:

Stored size: 689 Bytes

Contents

class TaxRate < ActiveRecord::Base
  belongs_to :zone
  belongs_to :tax_category

  validates :amount, :presence => true, :numericality => true

  calculated_adjustments :default => Calculator::SalesTax
  scope :by_zone, lambda { |zone| where("zone_id = ?", zone)}

  # Searches all possible TaxRates and returns the Zone which represents the most appropriate match (if any.)
  # To be considered for a match, the Zone must include the supplied address.  If multiple matches are
  # found, the Zone with the highest rate will be returned.  This method will return +nil+ if no match is found.
  def self.match(address)
    TaxRate.all.select { |rate| rate.zone.include? address }
  end
end

Version data entries

14 entries across 14 versions & 6 rubygems

Version Path
apispree_core-0.0.0 app/models/tax_rate.rb
My-Commerce_core-1.1.0 app/models/tax_rate.rb
My-Commerce_core-1.0.0 app/models/tax_rate.rb
MyCommerceapi-1.0.0 core/app/models/tax_rate.rb
MyCommerce-0.0.3 core/app/models/tax_rate.rb
rfcommerce_core-0.0.3 app/models/tax_rate.rb
spree_core-0.60.6 app/models/tax_rate.rb
spree_core-0.60.5 app/models/tax_rate.rb
spree_core-0.60.4 app/models/tax_rate.rb
spree_core-0.60.3 app/models/tax_rate.rb
spree_core-0.60.2 app/models/tax_rate.rb
spree_core-0.60.1 app/models/tax_rate.rb
spree_core-0.60.0 app/models/tax_rate.rb
spree_core-0.60.0.RC1 app/models/tax_rate.rb