Class: Spree::Price
Constant Summary collapse
- MAXIMUM_AMOUNT =
BigDecimal('99_999_999.99')
Instance Method Summary collapse
- #country_iso=(country_iso) ⇒ Object
- #display_country ⇒ Object
- #for_any_country? ⇒ Boolean
- #net_amount ⇒ Object
-
#price ⇒ Object
An alias for #amount.
-
#price=(price) ⇒ Object
Sets this price’s amount to a new value, parsing it if the new value is a string.
Methods included from DisplayMoney
Methods inherited from Base
display_includes, page, preference, #preferences
Methods included from Core::Permalinks
#generate_permalink, #save_permalink
Instance Method Details
#country_iso=(country_iso) ⇒ Object
64 65 66 |
# File 'app/models/spree/price.rb', line 64 def country_iso=(country_iso) self[:country_iso] = country_iso.presence end |
#display_country ⇒ Object
56 57 58 59 60 61 62 |
# File 'app/models/spree/price.rb', line 56 def display_country if country_iso "#{country_iso} (#{country.name})" else I18n.t(:any_country, scope: [:spree, :admin, :prices]) end end |
#for_any_country? ⇒ Boolean
52 53 54 |
# File 'app/models/spree/price.rb', line 52 def for_any_country? country_iso.nil? end |
#net_amount ⇒ Object
48 49 50 |
# File 'app/models/spree/price.rb', line 48 def net_amount amount / (1 + sum_of_vat_amounts) end |
#price ⇒ Object
An alias for #amount
36 37 38 |
# File 'app/models/spree/price.rb', line 36 def price amount end |
#price=(price) ⇒ Object
Sets this price’s amount to a new value, parsing it if the new value is a string.
44 45 46 |
# File 'app/models/spree/price.rb', line 44 def price=(price) self[:amount] = Spree::LocalizedNumber.parse(price) end |