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

Percentage calculations and rounding... HELP!!

Community Beginner ,
Nov 22, 2022 Nov 22, 2022

Copy link to clipboard

Copied

Hi,

 

I wouldn't even call myself a beginner with Adobe and JavaScript... Hence why I have turned to the brains trust for help, please! 

 

I've figured out how to calculate 'Total Gross' (PER DAYRow1 + PER DAYRow2 etc...). 

I now need the form to:

  • Subtract 47% of the whatever the 'Total Gross' will be
  • Round that amount to the nearest dollar

 

I'm hoping that calculating the 'Net Wages' will just be 'Total Gross - Less Tax (rounded) = ... ?

 

TIA, I apprecaite any help I can get! 

TOPICS
How to , JavaScript , PDF forms

Views

1.1K

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Nov 22, 2022 Nov 22, 2022

You don't need script for this, you can use 'Simplified Field Notation' instead.

If you want to round value to whole number, format "LESS TAX" field as number with 0 decimals and since you have space character in field names you need to escape space character with backslash, write exactly like this in simplified field notations:

In "LESS TAX" field under simplified field notation, use this:

0.47*TOTAL\ GROSS

 

In "NET WAGES" field under simplified field notation, use this:

TOTAL\ GROSS-LESS\ TAX

...

Votes

Translate

Translate
Community Expert ,
Nov 22, 2022 Nov 22, 2022

Copy link to clipboard

Copied

You don't need script for this, you can use 'Simplified Field Notation' instead.

If you want to round value to whole number, format "LESS TAX" field as number with 0 decimals and since you have space character in field names you need to escape space character with backslash, write exactly like this in simplified field notations:

In "LESS TAX" field under simplified field notation, use this:

0.47*TOTAL\ GROSS

 

In "NET WAGES" field under simplified field notation, use this:

TOTAL\ GROSS-LESS\ TAX

 

 

Votes

Translate

Translate

Report

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 Beginner ,
Nov 23, 2022 Nov 23, 2022

Copy link to clipboard

Copied

Thanks so much Nesa, you're my new best friend! 

 

When the net wages field calculates, is there a trick so that it calculates the less tax field as a whole dollar amount - at the moment it's calculating as a decimal figure (even though I've changed the format to 0 decimals). 

Votes

Translate

Translate

Report

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 ,
Nov 23, 2022 Nov 23, 2022

Copy link to clipboard

Copied

Sorry, I thought you just want to show rounded number, format only show whole number while value remains the same.

In tax field, use this as custom calculation script:

var TG = Number(this.getField("TOTAL GROSS").valueAsString);
if(TG){
var total = Math.round(0.47*TG);
event.value = total;}
else
event.value = 0;

Votes

Translate

Translate

Report

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 Beginner ,
Nov 23, 2022 Nov 23, 2022

Copy link to clipboard

Copied

Perfect, thank you for your prompt reply. 

 

I'm assuming I will have to amend the 'net wages' field now too?

Votes

Translate

Translate

Report

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 ,
Nov 23, 2022 Nov 23, 2022

Copy link to clipboard

Copied

You can leave 'net wages' field as it is, although you will have to change field calculation order, let me know if you don't know how to do that.

Also, you can remove format from 'tax' field.

Votes

Translate

Translate

Report

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 Beginner ,
Nov 23, 2022 Nov 23, 2022

Copy link to clipboard

Copied

I have no idea how to change field calculation order, sorry - are you able to show/tell me how? 

 

Thank you so much for all your help, it's extremely apprecaited. 

Votes

Translate

Translate

Report

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 ,
Nov 23, 2022 Nov 23, 2022

Copy link to clipboard

Copied

Select 'Prepare form' tool, then click on 'More' then click 'Set field calculation order', make sure tax field is above 'net wages' field.

Votes

Translate

Translate

Report

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 Beginner ,
Nov 23, 2022 Nov 23, 2022

Copy link to clipboard

Copied

LATEST

Thank you so much!

Votes

Translate

Translate

Report

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