Class: Spree::ShippingRate
- Inherits:
-
Base
- Object
- ActiveRecord::Base
- Base
- Spree::ShippingRate
show all
- Defined in:
- app/models/spree/shipping_rate.rb
Instance Method Summary
collapse
Methods inherited from Base
#initialize_preference_defaults, page, preference
#default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference
Instance Method Details
#calculate_tax_amount ⇒ Object
15
16
17
|
# File 'app/models/spree/shipping_rate.rb', line 15
def calculate_tax_amount
tax_rate.calculator.compute_shipping_rate(self)
end
|
#display_base_price ⇒ Object
11
12
13
|
# File 'app/models/spree/shipping_rate.rb', line 11
def display_base_price
Spree::Money.new(cost, currency: currency)
end
|
#display_price ⇒ Object
Also known as:
display_cost
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'app/models/spree/shipping_rate.rb', line 19
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
42
43
44
|
# File 'app/models/spree/shipping_rate.rb', line 42
def display_tax_amount(tax_amount)
Spree::Money.new(tax_amount, currency: currency)
end
|