2009-01-29 01:57:51 +01:00
|
|
|
class ArticlePrice < ActiveRecord::Base
|
|
|
|
|
2013-03-16 17:53:24 +01:00
|
|
|
belongs_to :article
|
2009-01-29 01:57:51 +01:00
|
|
|
has_many :order_articles
|
2010-07-01 16:12:02 +02:00
|
|
|
|
|
|
|
validates_presence_of :price, :tax, :deposit, :unit_quantity
|
2013-04-08 14:40:02 +02:00
|
|
|
validates_numericality_of :price, :greater_than_or_equal_to => 0
|
|
|
|
validates_numericality_of :unit_quantity, :greater_than => 0
|
2012-12-11 10:59:50 +01:00
|
|
|
validates_numericality_of :deposit, :tax
|
2009-02-09 20:12:56 +01:00
|
|
|
|
2012-12-11 10:59:50 +01:00
|
|
|
localize_input_of :price, :tax, :deposit
|
2009-01-29 01:57:51 +01:00
|
|
|
|
|
|
|
# The financial gross, net plus tax and deposit.
|
|
|
|
def gross_price
|
2009-03-01 18:45:34 +01:00
|
|
|
((price + deposit) * (tax / 100 + 1)).round(2)
|
2009-01-29 01:57:51 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
# The price for the foodcoop-member.
|
|
|
|
def fc_price
|
2012-08-24 19:52:38 +02:00
|
|
|
(gross_price * (FoodsoftConfig[:price_markup] / 100 + 1)).round(2)
|
2009-01-29 01:57:51 +01:00
|
|
|
end
|
|
|
|
end
|
2011-05-07 21:55:24 +02:00
|
|
|
|