2017-10-08 12:20:54 +02:00
|
|
|
module PriceCalculation
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
# Gross price = net price + deposit + tax.
|
|
|
|
# @return [Number] Gross price.
|
|
|
|
def gross_price
|
2017-10-08 12:33:44 +02:00
|
|
|
add_percent(price + deposit, tax)
|
2017-10-08 12:20:54 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
# @return [Number] Price for the foodcoop-member.
|
|
|
|
def fc_price
|
2017-10-08 12:33:44 +02:00
|
|
|
add_percent(gross_price, FoodsoftConfig[:price_markup])
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def add_percent(value, percent)
|
|
|
|
(value * (percent * 0.01 + 1)).round(2)
|
2017-10-08 12:20:54 +02:00
|
|
|
end
|
|
|
|
end
|