Sha256: e16b35aab6cf53f8ea26118ff30b5f1666d589ef73f9c6f2c35a95d410743d80
Contents?: true
Size: 795 Bytes
Versions: 3
Compression:
Stored size: 795 Bytes
Contents
module Shoppe class TaxRate < ActiveRecord::Base # Set the table name self.table_name = 'shoppe_tax_rates' # Tax rates are associated with countries include Shoppe::AssociatedCountries # Validations validates :name, :presence => true validates :rate, :numericality => true # Relationships has_many :products, :dependent => :restrict_with_exception has_many :delivery_service_prices, :dependent => :restrict_with_exception # Scopes scope :ordered, -> { order("shoppe_tax_rates.id")} def description "#{name} (#{rate}%)" end def rate_for(order) if countries.empty? || order.country.nil? || country?(order.country) self.rate else 0.0 end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
shoppe-0.0.14 | app/models/shoppe/tax_rate.rb |
shoppe-0.0.13 | app/models/shoppe/tax_rate.rb |
shoppe-0.0.12 | app/models/shoppe/tax_rate.rb |