8a74e7d77f
Annotate: Better look in schema.rb, this reference should be always up to date. Hirb: To reactivate hirb, look in railscasts: http://railscasts.com/episodes/48-console-tricks-revised
33 lines
938 B
Ruby
33 lines
938 B
Ruby
class ArticlePrice < ActiveRecord::Base
|
|
|
|
belongs_to :article
|
|
has_many :order_articles
|
|
|
|
validates_presence_of :price, :tax, :deposit, :unit_quantity
|
|
|
|
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
|
|
def price=(price)
|
|
self[:price] = String.delocalized_decimal(price)
|
|
end
|
|
|
|
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
|
|
def tax=(tax)
|
|
self[:tax] = String.delocalized_decimal(tax)
|
|
end
|
|
|
|
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
|
|
def deposit=(deposit)
|
|
self[:deposit] = String.delocalized_decimal(deposit)
|
|
end
|
|
|
|
# The financial gross, net plus tax and deposit.
|
|
def gross_price
|
|
((price + deposit) * (tax / 100 + 1)).round(2)
|
|
end
|
|
|
|
# The price for the foodcoop-member.
|
|
def fc_price
|
|
(gross_price * (Foodsoft.config[:price_markup] / 100 + 1)).round(2)
|
|
end
|
|
end
|
|
|