Could you explain what you are trying to achieve with the function? For example, I don’t really see the purpose of DividedPrice or SubtractedPrice in calculating the taxed amount.
DividedPrice - SubtractedPrice = Price for original price so if I had 1500, 70 percent of it would = 1050, if i subtract them it should be 450, which is the required price I need to add with so I can get the price of 1500 correctly with tax, so 450 is the fee. I cant really explain it well but if you look at the code it shouldnt be hard to understand
I think the main issue I’m having with understanding your logic is with the fact that tax isn’t usually calculated like that. If you take VAT for example it would be something like:
local price = 1000
function addedTax()
price += price*0.35 -- where 0.35 would be a 35% tax bracket
end
-- if the price included the tax and you know the tax bracket
function taxedPrice()
return price/1.35
end
I really don’t understand the logic you’re using for calculating tax.
You can make it into a single function. I’m just giving an example of the math you could use. Having said that I’m not sure why you would want them in a single function.
The first function returns the price with the tax added (if the price didn’t have the tax incorporated previously). By comparison, the second function returns the price if it already has the tax incorporated. If you wanted the amount of tax itself you could just do:
function addedTax(price)
return price*1.35
end
local tax = addedTax(price) - price
-- or if you have the price with the tax incorporated
function taxedPrice(price)
return price/1.35
end
local tax = price - taxedPrice(price)