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:
parent
ca7416f2e7
commit
386bc7382d
2 changed files with 10 additions and 3 deletions
|
@ -4,11 +4,17 @@ module PriceCalculation
|
||||||
# Gross price = net price + deposit + tax.
|
# Gross price = net price + deposit + tax.
|
||||||
# @return [Number] Gross price.
|
# @return [Number] Gross price.
|
||||||
def gross_price
|
def gross_price
|
||||||
((price + deposit) * (tax / 100 + 1)).round(2)
|
add_percent(price + deposit, tax)
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [Number] Price for the foodcoop-member.
|
# @return [Number] Price for the foodcoop-member.
|
||||||
def fc_price
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,8 +13,9 @@ default: &defaults
|
||||||
# true by default to keep compat with older installations, but test with false here
|
# true by default to keep compat with older installations, but test with false here
|
||||||
use_nick: false
|
use_nick: false
|
||||||
|
|
||||||
|
price_markup: 5
|
||||||
|
|
||||||
# do we really need the following ones?
|
# do we really need the following ones?
|
||||||
price_markup: 5.0
|
|
||||||
tax_default: 6.0
|
tax_default: 6.0
|
||||||
email_sender: noreply@minimal.test
|
email_sender: noreply@minimal.test
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue