Class: Spree::Price

Inherits:
Base
  • Object
show all
Extended by:
DisplayMoney
Includes:
VatPriceCalculation
Defined in:
app/models/spree/price.rb

Constant Summary collapse

MAXIMUM_AMOUNT =
BigDecimal('99_999_999.99')

Instance Method Summary collapse

Methods included from DisplayMoney

money_methods

Methods included from VatPriceCalculation

#gross_amount

Methods inherited from Base

belongs_to_required_by_default, page, spree_base_scopes

Methods included from Spree::Preferences::Preferable

#clear_preferences, #default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference

Instance Method Details

#amount=(amount) ⇒ Object


27
28
29
# File 'app/models/spree/price.rb', line 27

def amount=(amount)
  self[:amount] = Spree::LocalizedNumber.parse(amount)
end

#display_price_including_vat_for(price_options) ⇒ Object


38
39
40
# File 'app/models/spree/price.rb', line 38

def display_price_including_vat_for(price_options)
  Spree::Money.new(price_including_vat_for(price_options), currency: currency)
end

#moneyObject


23
24
25
# File 'app/models/spree/price.rb', line 23

def money
  Spree::Money.new(amount || 0, currency: currency)
end

#price_including_vat_for(price_options) ⇒ Object


33
34
35
36
# File 'app/models/spree/price.rb', line 33

def price_including_vat_for(price_options)
  options = price_options.merge(tax_category: variant.tax_category)
  gross_amount(price, options)
end

#variantObject

Remove variant default_scope `deleted_at: nil`


43
44
45
# File 'app/models/spree/price.rb', line 43

def variant
  Spree::Variant.unscoped { super }
end