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

Round up or round down

Explorer ,
Apr 17, 2021 Apr 17, 2021

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.

 

Views

894

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 , Apr 18, 2021 Apr 18, 2021

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);

Votes

Translate

Translate
Community Expert ,
Apr 17, 2021 Apr 17, 2021

Copy link to clipboard

Copied

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 ,
Apr 17, 2021 Apr 17, 2021

Copy link to clipboard

Copied

[Moderator moved from Creative Cloud Services to Acrobat SDK.]

 

Nancy O'Shea— Product User, Community Expert & Moderator

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 ,
Apr 18, 2021 Apr 18, 2021

Copy link to clipboard

Copied

How are you currently calculating the value of this 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
Explorer ,
Apr 18, 2021 Apr 18, 2021

Copy link to clipboard

Copied

 

for upload.JPG

 

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

 

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 ,
Apr 18, 2021 Apr 18, 2021

Copy link to clipboard

Copied

You did not answer my question...

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
Explorer ,
Apr 18, 2021 Apr 18, 2021

Copy link to clipboard

Copied

for upload.JPG

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.

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 ,
Apr 18, 2021 Apr 18, 2021

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?

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
Explorer ,
Apr 18, 2021 Apr 18, 2021

Copy link to clipboard

Copied

Using Product Option now.

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 ,
Apr 18, 2021 Apr 18, 2021

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);

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
Explorer ,
Apr 18, 2021 Apr 18, 2021

Copy link to clipboard

Copied

LATEST

Great, Its work fine,

Thank You Very 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
LEGEND ,
Apr 18, 2021 Apr 18, 2021

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. 

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