-1
Good evening, the question is more about calculation than programming. The problem is this: if I sell something I must add 15% service charge.
var total = 100;
var acrescimoPercent = 15.00;
var acrescimo = total - (total / 100 * acrescimoPercent);
total = total + acrescimo;
Altogether I will have a sale of 115 real, for example. But in case I need to make a chargeback, I can not return the rate of 15%. But now I have 115 and I can not apply the 15% discount why would be less than the original value (97,75), to return to the customer. In short, I need to return the 100 real but I do not know how to apply the percentage for this.
I get it, I didn’t do that calculation in the code, just the calculator. But I need to go back to 100, based on the final value 115 and the rate that is 15%. I may have done it wrong but I couldn’t get to the initial result of 100 by following your example. I will try again
– Alison Paulo
As I mentioned in the reply, just divide the final value by
1 + porcentagem
.. 15% is0.15
.. then just do the calculation115 / 1.15
– fernandosavio
Dude sorry I messed up I was right. Vlw guy, grateful.
– Alison Paulo