These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Help with Calculations

Merrijane
Registered: Oct 15 2008
Posts: 6
Answered

Our accounting department wants me to make a check requisition that calculates for users as they fill it out. I set it up so that as users enter a check amount, they can then allocate percentages toward lines of business in different fields to see how much money is represented by each percentage. However, accounting wants this column of allocated dollar amounts to not just visually round up to the next penny, but to ACTUALLY round up so that when they are totaled they could equal more than the requested check amount by a penny or two. (Long story.)

Currently, if I type in a check amount of $50.50, then allocate 50%, 25%, and 25% to three different lines of business, they calculate to amounts of $25.25, $12.63, and $12.63. This should total $50.51, but the total field is showing $50.50. I can't get it to total the rounded up amounts, just the actual amounts. Accounting swears this is possible in Excel, but I've got to do this in a pdf.

Any suggestions? If it involves Javascript, please go slow. I'm a tech writer/editor, not a programmer. Thanks!!

(Sorry, I'm using Mac not Windows. I see I chose the wrong tag.)

My Product Information:
Acrobat Pro 8.1.2, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
How do you currently have your form set up to perform the calculations?

Are you using Acrobat or LiveCycle Designer to create the form?

If I were in your position, I would require the people in accounting to give me explicit rules regarding how rounding should take place. Lacking that, we can only guess at solution. There are many rounding schemes that have been used in financial calculations.

In particular, you need to clarify what numbers like 3.765, 3.775, and -3.765 should be rounded to. Different rounding methods available in JavaScript can round these cases differently. Even if you're not dealing with negative amounts today, you may someday.

George
Merrijane
Registered: Oct 15 2008
Posts: 6
I laid out the form in Quark XPress, then exported it to pdf. Using Acrobat, I added the text and calculation fields. (Can I email the form to you so you can see how the fields are set up? It's not a proprietary document.) Not including personal information and text fields, I have an "Amount Payable" field and two columns titled "Indicate %" and "Calc Field." The Calc Field calculates the product of the Amount Payable and the Indicate % fields for each line of business.

To explain "line of business," our company consists of many different legal entities that follow different tax rules. So when an employee spends money and asks to be reimbursed, he must specify how much of the money should come from each entity or "line of business."

Dollar amounts should be rounded up to the nearest cent if they are over by 1/2 cent or more, or down to the nearest cent if they are under 1/2 cent more. For example, 3.765 should be rounded to 3.77, and 3.764 should be rounded to 3.76. I don't need to deal with negative amounts on this particular form because the user is requesting money to be paid to him--he is not paying money to the company.

Hope this helps. Thanks for your response!
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
To keep it simple in this case, you can set up a custom Validation script for each of your calculated fields:
event.value = util.printf("%.2f", event.value);
This takes the calculated value and rounds it to two decimal places. Normally, you'd include something like this in a custom calculation script, but since you're using the built-in calculation option, you can do this instead. Post again if this doesn't work for some reason.

George
Merrijane
Registered: Oct 15 2008
Posts: 6
Thank you, thank you!