Support integers for price_markup

The config panel writes an integer into the settings table in the
database, which results in a wrong calculation of the fc_price.
This commit is contained in:
Patrick Gansterer 2017-10-08 12:33:44 +02:00
parent ca7416f2e7
commit 386bc7382d
2 changed files with 10 additions and 3 deletions

View file

@ -4,11 +4,17 @@ module PriceCalculation
# Gross price = net price + deposit + tax.
# @return [Number] Gross price.
def gross_price
((price + deposit) * (tax / 100 + 1)).round(2)
add_percent(price + deposit, tax)
end
# @return [Number] Price for the foodcoop-member.
def fc_price
(gross_price * (FoodsoftConfig[:price_markup] / 100 + 1)).round(2)
add_percent(gross_price, FoodsoftConfig[:price_markup])
end
private
def add_percent(value, percent)
(value * (percent * 0.01 + 1)).round(2)
end
end

View file

@ -13,8 +13,9 @@ default: &defaults
# true by default to keep compat with older installations, but test with false here
use_nick: false
price_markup: 5
# do we really need the following ones?
price_markup: 5.0
tax_default: 6.0
email_sender: noreply@minimal.test