Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Simplified field notation vs Custom calculation script

New Here ,
Feb 28, 2018 Feb 28, 2018

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!

TOPICS
PDF forms
1.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
LEGEND ,
Feb 28, 2018 Feb 28, 2018

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);

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 28, 2018 Feb 28, 2018

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);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 28, 2018 Feb 28, 2018
LATEST

George Johnson, you are a truly wonderful human being! That appears to have done exactly what I wanted it to do. One billion thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines