Skip to main content
Participating Frequently
July 5, 2024
Answered

Script for calculating sales tax on only certain fields

  • July 5, 2024
  • 3 replies
  • 2645 views

Hello, I am looking to calculate 5% tax on only certain field I have listed below.   The script below calculates 10% and but shows as $14750.00 on a subtotal of $1475.00.  Please help, what am I doing wrong.

 

var a = this.getField("fill_76").value;
var b = this.getField("Full Clean").value;
var c = this.getField("Floors only").value;
if (a !=="" || b !=="" || c !=="") {
event.value = a+b+c*(.05/100);
} else {
event.value ="";
}

This topic has been closed for replies.
Correct answer PDF Automation Station

368.75 should be the discount amount and the total rental less discount is the total rental less the discount.


I think you totally misunderstood my directions on the radio buttons.  You originally had one set of radio buttons for 4 possible answers, now you have 4 separate radio buttons.  You need a Yes/No set for Youth Group and a Yes/No set for Non-Profit.  The export values should be the decimals only, (i.e. .15 and .25), not Choice 1=".25".  Better yet, I wouldn't even use radio buttons.  I would use one check box for Youth Group and another for Non-profit.  The export values will be either .15/.25 when checked, or "Off" when unchecked.

3 replies

PDF Automation Station
Community Expert
Community Expert
July 5, 2024

The 5% calculation on the sum of the three fields should be:

(a+b+c) * .05

 

 

Participating Frequently
July 5, 2024

Thank you, I attached the actual file and I have another question.  At the top of the form there are check boxes for youth groups and non profit group.  Is there a way if someone clicked the Yes box in one of these fields that the discount would automatically appear at the bottom of the form in the fields "nonprofit group 15%" or "Youth Group 25%" depending on the option they chose. How would I write this?

PDF Automation Station
Community Expert
Community Expert
July 5, 2024

You need 2 sets of radio buttons:  One for Youth and another for non-profit.  Change the export values of the Yes buttons to .15 and .25 respectively, and the No buttons to zero.  The text fields are shown as $ not percent.  % of which field?  You put a calculation in the text fields that says Value is the product of then select the 2 fields (the radio button set and the field that it is a percentage of).

 

Polite suggestion: You should put seperate questions in separate posts to make it easier for readers to search and find answers.

Participating Frequently
July 5, 2024
I would like the %5 gst to only calculate for the "fill_76" and the "Full Clean" field and the "Floors only" field. I want the tax total to appear in "fill_81"

Therese Picton
Executive Assistant
[cid:image001.png@01DACED4.EC92C040]
Office: 250-615-6100 Toll Free: 1-800-663-3208 Fax: 250-635-9222
Email: tpicton@rdks.bc.ca Website: http://www.rdks.bc.ca<>
Northwest BC Resource Benefits Alliance: https://www.nwresourcebenefits.ca/
PLEASE NOTE: This message is intended solely for the use of the individual or organization to whom it is addressed and may contain information that is privileged, confidential and prohibited from disclosure under the Freedom of Information and Protection of Privacy Act and other applicable laws. Any other reproduction, distribution or disclosure is strictly prohibited.
Please consider the environment before printing this e-mail.
________________________________
Thom Parker
Community Expert
Community Expert
July 5, 2024

The script you've posted does not calculate 10% of 1450. 

It add as "a", "b", and .05% of "c", i.e., that's .0005 * c

In the form the "b" and "c" values are empty strings, so the value of GST at 5% is the "subtotal", which is what's happening. 

 

Please explain exactly how you want the calculation to work. 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participating Frequently
July 5, 2024

I want to calculate the 5% tax using the "Fill_76" field and the "Full Clean" field and the "Floors only" field and I want the result to show up in "Fill_81"