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
|
|
|
|
|
2023-07-24 10:50:35 +02:00
|
|
|
def gross_price_without_deposit
|
|
|
|
add_percent(price, tax)
|
|
|
|
end
|
|
|
|
|
|
|
|
def gross_deposit_price
|
|
|
|
add_percent(deposit, tax)
|
|
|
|
end
|
|
|
|
|
2017-10-08 12:20:54 +02:00
|
|
|
# @return [Number] Price for the foodcoop-member.
|
|
|
|
def fc_price
|
2023-06-16 13:04:03 +02:00
|
|
|
add_percent(gross_price, FoodsoftConfig[:price_markup].to_i)
|
2017-10-08 12:33:44 +02:00
|
|
|
end
|
|
|
|
|
2023-07-24 10:50:35 +02:00
|
|
|
def fc_price_without_deposit
|
|
|
|
add_percent(gross_price_without_deposit, FoodsoftConfig[:price_markup].to_i)
|
|
|
|
end
|
|
|
|
|
|
|
|
def fc_deposit_price
|
|
|
|
add_percent(gross_deposit_price, FoodsoftConfig[:price_markup].to_i)
|
|
|
|
end
|
|
|
|
|
2017-10-08 12:33:44 +02:00
|
|
|
private
|
|
|
|
|
|
|
|
def add_percent(value, percent)
|
2023-05-12 13:01:12 +02:00
|
|
|
(value * ((percent * 0.01) + 1)).round(2)
|
2017-10-08 12:20:54 +02:00
|
|
|
end
|
|
|
|
end
|