Search code examples
javascriptexcellogicreversemathematical-optimization

70-30 Tax reverse calculation get products original amount without tax


There is tax called 70%-30%. Base price of product will be part in 70% and 30%. And tax on 70% amount will be 5% and on 30% will be 18%. Here is Image sample calculated.

enter image description here

Now calculation is required reverse. We have 24000.00273 and tax information. need Base amount to be calculate.

We have tried different method but amount doesn't match.


Solution

  • You calculate total by:

    total = base + ((0.05 * 0.7 * base) + (0.18 * 0.3 * base))
    

    So the reverse is:

    base = total / (1 + ((0.05 * 0.7) + (0.18 * 0.3)))
    

    In JS:

    function reverse(amt, split1, split2, tax1, tax2) {
      return amt / (1 + ((split1 * tax1) + (split2 * tax2)));
    }
    
    var base = reverse(24000.00273, 0.7, 0.3, 0.05, 0.18);
    
    console.log(base);

    In Excel (formula in A6):

    =A1/(1+((A2*A4)+(A3*A5)))
    

    enter image description here