Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

if then statement help

New Here ,
Aug 12, 2020 Aug 12, 2020

Hello all,

I am trying to create an if /then statement on a sales agreement that needs to calculate different amounts of tax based on the amount of the sale. I don't know if I am using the wrong field names or what but I keep getting syntax errors.

We have a 6% sales tax with an additional Education tax of .5% up to $5000. Everything over $5000 is a 6% tax. The name of the cell that has the value of the subtotal of the sale in it is called SubTotal, the "Tool tip" name is "$_Row_1"

Here is my equation description:

I want to calculate the amount of tax to charge based on the amount in the "SubTotal" cell.

If statement: If cell named SubTotal is < $5000

If True:  then SubTotal * 6.5% (.065)

If False (greater than $5000):  then subtract $5000 from the SubTotal amount and multiply it by 6% (.06) and add $325 ($325 is 6.5% of the first $5000)

 

Here is what I put in the calculation field for "Sale Tax":

 

if(SubTotal<5000, SubTotal*.065,
((SubTotal-5000)*.06)+325)

 

What am I doing wrong? Thanks in advance for your help.

TOPICS
Acrobat SDK and JavaScript
2.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 12, 2020 Aug 12, 2020

You must use Javascript code for this.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 12, 2020 Aug 12, 2020

Thanks for your reply. I'm used to formulas in Excel.  What would the Javascript code be entered to do the same thing?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 12, 2020 Aug 12, 2020
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 12, 2020 Aug 12, 2020

I updated the equation to the following that lets me enter it without errors but it does nothing.

 

if (SubTotal<5000) {SubTotal*.065} else
{((SubTotal-5000)*.06)+325}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 12, 2020 Aug 12, 2020

You're missing a bunch of important stuff... Read this tutorial, too: https://acrobatusers.com/tutorials/how-to-do-not-so-simple-form-calculations

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 12, 2020 Aug 12, 2020

In what field are you try to get result (Same field where value is, or you have another field(example: total price))? and what tax you want if value is exactly $5000 6.5% or 6%?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 12, 2020 Aug 12, 2020

I have the formula in a field named SalesTax

If the amount was exactly $5000 it would be taxed at the 6% rate because the extra .5% education tax goes "up to $5000".

Thanks.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 12, 2020 Aug 12, 2020

In calculation script of the SalesTax field:

if (SubTotal<5000) event.target.value=SubTotal*=.065;

else event.target.value=((SubTotal-5000)*.06)+325;

@+

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 12, 2020 Aug 12, 2020

Hmmm, that didn't work. I tried it with the @+ on the end and it gave me a syntax error

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 12, 2020 Aug 12, 2020

You want SalesTax to show price with aded tax or just tax?

example: $6000= $6360 or just $360

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 12, 2020 Aug 12, 2020

Just tax

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 12, 2020 Aug 12, 2020

Try this as custom calculation script of SalesTax field:

 

var SubTotal = Number(this.getField("SalesTax").value);
if (SubTotal < 5000){
event.value = SubTotal*.065;
}else event.value = SubTotal*.06;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 12, 2020 Aug 12, 2020
LATEST

I played around with it for a while and got it to work:

 

var SubTotal = Number(this.getField("SubTotal").value);
if (SubTotal < 5000) {event.value = SubTotal*.065;} else {event.value = ((SubTotal-5000)*.06)+325;}

 

Thank you so much for your help!

jamesbo

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 12, 2020 Aug 12, 2020

Please, don't type "@+"!!!

for French people's, @+ means "see you soon" or "talk to you soon"...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines