fix deposit is net value
This commit is contained in:
parent
f29ab603b6
commit
90e06a475f
10 changed files with 75 additions and 34 deletions
|
|
@ -4,15 +4,15 @@ module PriceCalculation
|
|||
# Gross price = net price + deposit + tax.
|
||||
# @return [Number] Gross price.
|
||||
def gross_price
|
||||
add_percent(price + deposit, tax)
|
||||
add_percent(price, tax) + deposit
|
||||
end
|
||||
|
||||
def gross_price_without_deposit
|
||||
add_percent(price, tax)
|
||||
end
|
||||
|
||||
def gross_deposit_price
|
||||
add_percent(deposit, tax)
|
||||
def net_deposit_price
|
||||
remove_percent(deposit, tax)
|
||||
end
|
||||
|
||||
# @return [Number] Price for the foodcoop-member.
|
||||
|
|
@ -25,11 +25,15 @@ module PriceCalculation
|
|||
end
|
||||
|
||||
def fc_deposit_price
|
||||
add_percent(gross_deposit_price, FoodsoftConfig[:price_markup].to_i)
|
||||
add_percent(deposit, FoodsoftConfig[:price_markup].to_i)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def remove_percent(value, percent)
|
||||
(value / ((percent * 0.01) + 1)).round(2)
|
||||
end
|
||||
|
||||
def add_percent(value, percent)
|
||||
(value * ((percent * 0.01) + 1)).round(2)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue