Class: Spree::Price
- Extended by:
- DisplayMoney
- Includes:
- Discard::Model, ParanoiaDeprecations
- Defined in:
- app/models/spree/price.rb
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 included from ParanoiaDeprecations
#paranoia_delete, #paranoia_destroy
Methods inherited from Base
display_includes, #initialize_preference_defaults, page, preference
Methods included from Spree::Preferences::Preferable
#admin_form_preference_names, #default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference
Instance Method Details
#country_iso=(country_iso) ⇒ Object
70 71 72 |
# File 'app/models/spree/price.rb', line 70 def country_iso=(country_iso) self[:country_iso] = country_iso.presence end |
#display_country ⇒ Object
62 63 64 65 66 67 68 |
# File 'app/models/spree/price.rb', line 62 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
58 59 60 |
# File 'app/models/spree/price.rb', line 58 def for_any_country? country_iso.nil? end |
#net_amount ⇒ Object
54 55 56 |
# File 'app/models/spree/price.rb', line 54 def net_amount amount / (1 + sum_of_vat_amounts) end |
#price ⇒ Object
An alias for #amount
42 43 44 |
# File 'app/models/spree/price.rb', line 42 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.
50 51 52 |
# File 'app/models/spree/price.rb', line 50 def price=(price) self[:amount] = Spree::LocalizedNumber.parse(price) end |