Skip to main content
jprainBPS
Participant
February 17, 2018
Question

Objective: To calculate Sales tax on an invoice.

  • February 17, 2018
  • 1 reply
  • 441 views

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

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
February 17, 2018

Yes, that seems right.

jprainBPS
jprainBPSAuthor
Participant
February 17, 2018

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

try67
Community Expert
Community Expert
February 17, 2018

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/

http://www.pdfscripting.com/

And for general JS syntax (keep in mind that many of the examples are for HTML pages, though, so stick to the core functions):

JavaScript Tutorial