Copy link to clipboard
Copied
I have a field "subtotal"
I want to round up or round down my value from "subtotal" field,
If 50.49 it will be 50.00
If 50.50 it will be 51.00
less than .50 will round down (.10-.49)
greater or equal to .50 will round up
please help me.
I am very new in JavaScript, but this is a great community to learn JavaScript.
OK. Let's say the first quantity field is called Qty1 and the first unit price field is called UnitPrice1.
As the custom calculation script of the first total price field enter the following:
var qty = Number(this.getField("Qty1").valueAsString);
var price = Number(this.getField("UnitPrice1").valueAsString);
event.value = Math.round(qty*price);
Copy link to clipboard
Copied
Please post the exact name of the Adobe program you use so a Moderator may move this message to that forum
.
When you ask a question you always need to provide some basic information
-Forum quick start https://community.adobe.com/t5/Community-Help/ASK-Forum-Success-Guide-Efficiently-using-the-forums/t...
-https://community.adobe.com/t5/Get-Started/Questions-you-need-to-answer-to-receive-better-help/td-p/...
-https://community.adobe.com/t5/get-started/how-to-post-and-get-your-issue-resolved-or-what-do-you-ne...
Copy link to clipboard
Copied
[Moderator moved from Creative Cloud Services to Acrobat SDK.]
Copy link to clipboard
Copied
How are you currently calculating the value of this field?
Copy link to clipboard
Copied
In 1st row total price will round up $21, and 2nd row total price will be $22.00
19.49 will be 19.00, 19.50 will be 20
Copy link to clipboard
Copied
You did not answer my question...
Copy link to clipboard
Copied
In 1st row total price will round up $21, and 2nd row total price will be $22.00
19.49 will be 19.00, 19.50 will be 20
How I will round up or round down Total Price value?
I am new here.
Copy link to clipboard
Copied
Let's try it differently. Are you using a script, or the Simple Field Notation option, or the Product option in the Calculate tab?
Copy link to clipboard
Copied
Using Product Option now.
Copy link to clipboard
Copied
OK. Let's say the first quantity field is called Qty1 and the first unit price field is called UnitPrice1.
As the custom calculation script of the first total price field enter the following:
var qty = Number(this.getField("Qty1").valueAsString);
var price = Number(this.getField("UnitPrice1").valueAsString);
event.value = Math.round(qty*price);
Copy link to clipboard
Copied
Great, Its work fine,
Thank You Very much.
Copy link to clipboard
Copied
Be very careful. Money is much harder to work with than many people think, and accountants and others check for errors. Consider: 3 lines, each 4 @ $1.10. So each line is 4.40. You round each line to $4. The bill must be for $12.
Seems simple? Now take the grand total. It's 4.40 x 3, which is 13.20 so you round it to $13. So you send someone a bill for which adds up to $12, but charge them $13. This is likely to lead to bad discussions with accountants, tax authorities and others.