Copy link to clipboard
Copied
Apologies if this is a simple answer but I've looked and I'm stuck.
I'm only just learning interactive form fields and I've managed to get most of what I need from simplified field notation. Essentially I have a gross figure and from that I need to calculate the net amount and the amount on VAT. In this instance the VAT value is 6%. My fields are called GrossAmount, NetAmount and VatAmount so my simplified field notation for the net amount is: 'GrossAmount/1.06' and my calculation for the VAT amount is: 'GrossAmount-NetAmount'.
However, whilst the results work like that I also need to ROUND the results to two decimal places (rather than just DISPLAY two decimal places) . My understanding is that this can only be done using a custom calculation script? Since I don't think these can both be run together, I'm stumped! I imagine my only solution is to code the simplified field notation into a custom script, which I have no idea how to do...
Is there a simple solution to this or am I missing something?!
Any help greatly appreciated!
Copy link to clipboard
Copied
The calculation script for the first one could be something like:
event.value = util.printf("%.2f", getField("GrossAmount").value / 1.06);
And the other could be:
event.value = util.printf("%.2f", getField("GrossAmount").value - getField("NetAmount").value);
Copy link to clipboard
Copied
The calculation script for the first one could be something like:
event.value = util.printf("%.2f", getField("GrossAmount").value / 1.06);
And the other could be:
event.value = util.printf("%.2f", getField("GrossAmount").value - getField("NetAmount").value);
Copy link to clipboard
Copied
George Johnson, you are a truly wonderful human being! That appears to have done exactly what I wanted it to do. One billion thanks!

