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

Calculated Field

Community Beginner ,
Jun 23, 2023 Jun 23, 2023

Struggling to make this work.  I need a calculated field to solve the following problem:

 

5. Claimed compensation (line 4). Deduct 1.75% of the first $1,000 and 1.5%of the amount in excess of $1,000 with a $50 cap. (Total compensation may not exceed $50.).

 

I'm "code stupid", so any help someone could provide would be appreciated.

TOPICS
JavaScript , PDF forms
621
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 ,
Jun 23, 2023 Jun 23, 2023

What are the field names included in this calculation?

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 Beginner ,
Jun 23, 2023 Jun 23, 2023

This particular field is named "ClaimedCompensation".  The field before this is entitled "GrossKentuckySalesAndUseTax"

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 ,
Jun 23, 2023 Jun 23, 2023

You can use this code as the custom calculation script of the cap field:

 

var cap = 0;
var maxCap = 50;
var amount = Number(this.getField("GrossKentuckySalesAndUseTax").valueAsString);
if (amount>1000) {
	cap+=1000*0.0175;
	amount-=1000;
	cap+=amount*0.015;
} else cap+=amount*0.0175;
event.value = Math.min(cap, maxCap);
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 Beginner ,
Jun 26, 2023 Jun 26, 2023
LATEST

This worked great!  Thanks so much.

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