I have been trying to use a formula that is used to work out exclusive VAT in a program that our team is creating. The formula works correctly when used in a calculator or in excel, though gives a different output when used within a function in our program!
here is the function:
function fn_calcVat() { var vRate = Ext.getCmp('crd_vat_rate').getValue(); var vTranAmt = Ext.getCmp('crd_tran_amt').getValue(); if (vRate != '' && vTranAmt != '') { alert(Ext.getCmp('vatable').getValue().toString()); var vAmt = 0; if (Ext.getCmp('vatable').getValue().toString() == 'Y') { vAmt = (vRate / ((vTranAmt / 100) + 1)); Ext.getCmp('crd_vat_amt').setValue(vAmt.toFixed(2)); Ext.getCmp('crd_tran_tot').setValue(vTranAmt.toString()); vAmt = 0; } else { vAmt = ((vRate / 100) * vTranAmt); Ext.getCmp('crd_vat_amt').setValue(vAmt.toFixed(2)); Ext.getCmp('crd_tran_tot').setValue((vTranAmt + vAmt)); vAmt = 0; } } }
the problem formula is vAmt = (vRate / ((vTranAmt / 100) + 1));
The other formula is working perfectly.
an example input would be 100 with a VAT rate of 14.00, and the expected answer would be a tax amount of 14, though it gives it as 7!!!
We are using a mashup of EXTJS, js and C#…
Any help would be greatly appreciated.
Kind Regards
Nick
The formula is incorrect, it should be