Class: KktShoppe::TaxRate
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- KktShoppe::TaxRate
- Includes:
- AssociatedCountries
- Defined in:
- app/models/kkt_shoppe/tax_rate.rb
Constant Summary collapse
- ADDRESS_TYPES =
The order address types which may be used when choosing how to apply the tax rate
['billing', 'delivery']
Instance Method Summary collapse
-
#description ⇒ String
A description of the tax rate including its name & percentage.
-
#rate_for(order) ⇒ BigDecimal
The rate for a given order based on the rules on the tax rate.
Methods included from AssociatedCountries
#countries, #country?, included
Instance Method Details
#description ⇒ String
A description of the tax rate including its name & percentage
31 32 33 |
# File 'app/models/kkt_shoppe/tax_rate.rb', line 31 def description "#{name} (#{rate}%)" end |
#rate_for(order) ⇒ BigDecimal
The rate for a given order based on the rules on the tax rate
38 39 40 41 42 43 |
# File 'app/models/kkt_shoppe/tax_rate.rb', line 38 def rate_for(order) return rate if countries.empty? return rate if address_type == 'billing' && (order.billing_country.nil? || country?(order.billing_country)) return rate if address_type == 'delivery' && (order.delivery_country.nil? || country?(order.delivery_country)) BigDecimal(0) end |