Kindly see the following,
Gross Total : 10000
Discount : 0
Tax % : 10 Tax Amount : 1000
------------
Net Total : 11000
Formula:
Tax Amount = (Gross Total - Discount) * Tax % / 100
Net Total = (Gross Total - Discount + Tax Amount)
Now what i try to accomplish here is, Whenever changing the Net total, the discount amount should be calculated accordingly. By the way tax % is read only. Then Based on the new discount the tax amount should be calculated and hence the (Gross total - discount + tax amount) should match the new given net total.
So in order to achieve it, I just framed an equation like below,
Gross total - x + [(Gross total - x) * tax % / 100] = Net total
where x is the discount amount to be calculated.
Can anybody tell me whether the above equation framed by me is right or wrong.? If right then can you show how to define a formula to find the x.? else Kindly guide me to achieve my requirement in a clean way. I meant accurate way.
Your formula is correct. As for finding a formula for $x$ in terms of the other amounts, let $G$ be the gross total, $T$ be the tax rate, $N$ be the net total. Then, with $x$ the discount as you have it, you want $$G-x+(G-x)\cdot\frac{T}{100}=N$$ $$(G-x)\cdot\left(1+\frac{T}{100}\right)=N$$ $$(G-x)\cdot\frac{100+T}{100}=N.$$ Can you solve that last equation for $x$ in terms of the other variables?