Class: Spree::ShippingRate
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Spree::ShippingRate
- Defined in:
- app/models/spree/shipping_rate.rb
Instance Method Summary collapse
- #calculate_tax_amount ⇒ Object
- #display_base_price ⇒ Object
- #display_price ⇒ Object (also: #display_cost)
- #display_tax_amount(tax_amount) ⇒ Object
- #shipping_method ⇒ Object
- #tax_rate ⇒ Object
Instance Method Details
#calculate_tax_amount ⇒ Object
14 15 16 |
# File 'app/models/spree/shipping_rate.rb', line 14 def calculate_tax_amount tax_rate.calculator.compute_shipping_rate(self) end |
#display_base_price ⇒ Object
10 11 12 |
# File 'app/models/spree/shipping_rate.rb', line 10 def display_base_price Spree::Money.new(cost, currency: currency) end |
#display_price ⇒ Object Also known as: display_cost
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/models/spree/shipping_rate.rb', line 18 def display_price price = display_base_price.to_s if tax_rate tax_amount = calculate_tax_amount if tax_amount != 0 if tax_rate.included_in_price? if tax_amount > 0 amount = "#{display_tax_amount(tax_amount)} #{tax_rate.name}" price += " (#{Spree.t(:incl)} #{amount})" else amount = "#{display_tax_amount(tax_amount*-1)} #{tax_rate.name}" price += " (#{Spree.t(:excl)} #{amount})" end else amount = "#{display_tax_amount(tax_amount)} #{tax_rate.name}" price += " (+ #{amount})" end end end price end |
#display_tax_amount(tax_amount) ⇒ Object
41 42 43 |
# File 'app/models/spree/shipping_rate.rb', line 41 def display_tax_amount(tax_amount) Spree::Money.new(tax_amount, currency: currency) end |
#shipping_method ⇒ Object
45 46 47 |
# File 'app/models/spree/shipping_rate.rb', line 45 def shipping_method Spree::ShippingMethod.unscoped { super } end |