Copy link to clipboard
Copied
I have a list of taxable goods each with a price:
VehiclePrice 10,000.00
Delivery 90.00
Prep 195.00
Freight 110.00
DocFees 210.00
Total_Taxable_Items 10,605.00
I need Java PDFScript for sales tax at 6%. Is the one below correct?
var v1 = Number(this.getField("TotalTaxableItems").valueAsString);
event.value = (v1*.06);
Next... if I wanted to allow for a variable Tax Rate percentage (different state taxes) would this script be correct?
The objective would be to type in the Tax rate and have it calculate the correct amount.
var v1 = Number(this.getField("TotalTaxableItems").valueAsString);
var v2 = Number(this.getField("Tax_Rate").valueAsString);
event.value = (v1*v2);
Copy link to clipboard
Copied
Yes, that seems right.
Copy link to clipboard
Copied
Try67,
Thank you. New to Java and trying to find quick reference resource for simple Script items like these.
If you have a suggestion of one please pass it along.
Thanks again,
Jim
Copy link to clipboard
Copied
First thing to know is that it's JavaScript, not Java. Similar names, but quite different languages.
Here are some good resources:
http://www.adobe.com/devnet/acrobat.html
https://acrobatusers.com/tutorials/
And for general JS syntax (keep in mind that many of the examples are for HTML pages, though, so stick to the core functions):
Copy link to clipboard
Copied
I would set the field for the sales tax rate to "Percentage". This will display the sales tax rate as a percentage but take the input of the sales tax rate and the decimal value. In this way the visual appearance displays the percentage but the actual value used is decimal tax rate. You also might want include a rounding function to truncate the actual computed tax amount to exactly 2 decimal places since the actual values used in computer calculation are binary and many decimal values become irrational when converted to binary and the result will be a very long decimal. It will be a very small difference but if the value is taken form form and combined with other sales tax amounts will result is a larger value that what it should be.