These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Tax Yes or No in the total price

BrettPXL
Registered: Jul 5 2011
Posts: 1

I have created a form in Acrobat Pro 9 and had all types of different simple calculations on top. These calculations make a subtotal.
 
On this subtotal there is the option to attach taxes or not. Whenever you select taxes (19%) the calculation has to be subtotal*0.19 ofcourse, but whenever you select the 0% taxes then you have to get 0.
 
But the biggest problem is how do I sum up the selected taxes with the subtotal (which goes to Total). I heard and read about some "if" calculations, but it's not really understandable.
 
I'm quite new to Acrobat Pro 9.

My Product Information:
Acrobat Pro 9.3, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
So let's say you have a field called SubTotal, which is just a straight-forward sum of all of your fields. Now, create a read-only text field called SubTotalTax (for example).
Now let's also say you have a (hidden) text field called Tax which has the value 0.19. We'll use that one for the tax calculation instead of hard-coding the value into the script. That way you could easily adjust it in the future, if necessary. And then there's a checkbox called UseTax, which determines whether or not the tax should be calculated.
Now use the following code as the custom calculation script of SubTotalTax:

var useTax = (getField("UseTax").value != "Off");

if (useTax) {
event.value = getField("SubTotal").value * getField("Tax").value;
} else {
event.value = 0;
}

Your Total field can simply be the sum of SubTotal and SubTotalTax. The only thing you need to make sure is that the calculation order is correct, ie that Total is calculated last, SubTotalTax before it, and SubTotal before that.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com