5 Replies Latest reply on Apr 2, 2013 11:51 PM by Ivaja

# Help!  Trying to calculate tax on only taxable items

Hi everyone,

I have a working invoice that incorporates the following code to calculate tax on a subtotal:

var f = this.getField("Subtotal");

event.value = Math.round(f.value * 7) / 100;

It's been working just fine but I would like to modify my invoice to only calculate the tax for taxable items.  Trying to save myself some time and effort since I am frequently putting in items for both taxable and nontaxable amounts on my invoices, and I don't need tax for the entire subtotal, just for taxable items.  Should I use some "if" code involving radio buttons to indicate taxable items?  Like, if Amount1 and Amount2 are taxable, calculate tax, and then add for total tax value.

Any help would be greatly appreciated!  I really have little to no javascript experience or any idea how to code it.

Thanks so much for any help.

Working in Acrobat 9 Pro on Mac

• ###### 1. Re: Help!  Trying to calculate tax on only taxable items

Yes, if you add a check box for each item that indicates whether it is taxable or not, you can calculate tax. If you provide the field names of both the row total (line item cost) fields and the corresponding check box, someone can probably suggest specific code.

• ###### 2. Re: Help!  Trying to calculate tax on only taxable items

Each raw total for line items is labeled as "Amount1", "Amount2" all the way through "Amount15".  The corresponding radio buttons for each are "Amount1Taxable" through "Amount15Taxable" with values of either "Yes" or "No".  Yea, I'm definitely looking for specific code help on this.

• ###### 3. Re: Help!  Trying to calculate tax on only taxable items

Try:

// variable for total taxable amount

var TaxableAmount = 0;

// loop through the Amount#Taxable fields

for ( i = 1; i < 6 ; i++) {

// compute Amount Taxable check box name

// test computed i check box name equal to "Yes"

if(this.getField("Amount" + i + "Taxable").value == "Yes") {

// add computed name amount to TaxableAmount

TaxableAmount += this.getField("Amount" + i).value;

} // end if taxable

}// end loop of check boxes

// compute tax at 7% tax rate

event.value = Math.round(TaxableAmount * 7) / 100;

• ###### 4. Re: Help!  Trying to calculate tax on only taxable items

GKaiseril,

Thanks so much!  That did the trick   Sorry for the late response, holiday season and all!

Happy New Year!

• ###### 5. Re: Help!  Trying to calculate tax on only taxable items

Hi there,

Do you have an example of your form I can view please? Calculating tax?

I'm using radio buttons for users to select either Yes or No in Adobe livecycle.  There are 3 fields - field 1 allows you to enter the total invoice amount.  Field 2 are the radio buttons Yes or No.   Field 3 is the net amount.

If users select Yes from the radio button then I want the total invoice amount to calculate the gst and net mount.  If users select no then the amount in Field 3 stays the same as the total invoice.

I send a message before on how to calculate gst but I think I confused myself and everyone else probably why no-one has replied.

If anyone out there can help - I would be really greatful.