how to stop java script from rounding dollars

New Here ,
Sep 08, 2022 Sep 08, 2022

Copy link to clipboard

Copied

I have a fillable PDF with java running calculations to give me sales commissions, and I cannot figure out how to get it to stop rounding dollars up (e.g., I want $75.50 and not $76.00).  All the fields are set to two decimal places, and the code also specifies two.  I did not write this code; someone did it for me because I am not familiar with java.  So I need a solution, if possible, that does not involve writing new code.  Any help will be greatly appreciated!

 

TOPICS
JavaScript

Views

38

Likes

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 ,
Sep 08, 2022 Sep 08, 2022

Copy link to clipboard

Copied

What script does you use?

Likes

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
New Here ,
Sep 08, 2022 Sep 08, 2022

Copy link to clipboard

Copied

This is the code that was written for me. The fields called COMMISSION9 and MRC9 are both number fields with two decimal places. They also have the currency symbol, if that makes any difference. As I said, I don't know much of anything about java.

//
//Calculate9:Annot1:MouseDown:Action1
//
/*********** belongs to: AcroForm:Calculate9:Annot1:MouseDown:Action1 ***********/
if (this.getField('FIXED9').value > 0) {
this.getField('COMMISSION9').value = this.getField('FIXED9').value;
}
else
{
this.getField('COMMISSION9').value = Math.round(this.getField('PERCENT9').value / 100 * this.getField('MRC9').value,2);
}
//
//

Laura Gustafson
Operations Coordinator
lgustafson@apxnet.com
207-814-8010

[A few men shaking hands Description automatically generated with low confidence]<>

Likes

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 ,
Sep 11, 2022 Sep 11, 2022

Copy link to clipboard

Copied

LATEST

It is difficult to see the equation work if you don't provide the values that are on each field that leads to a total of $76.00.

 

Would you mind posting the values that you are currently using in FIXED9,  COMMISION9, PERCENT9 and MRC9 respectively?

 

I don't see clearly what is Math.round doing to the total of  that equation as it also includes roubding in the line of code outlined below for 

field MRC9 total value: 

 

  • this.getField('MRC9').value,2)

 

Likes

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