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

Adjustment Calculation

billh098
Registered: Jun 6 2009
Posts: 47
Answered

Hello,

I have 3 fields that I am trying to get to do calculations between.

First field is called AP (for adjusted percentage) and settins is set to number with decimal point at 2 and vaule is set to 0. (this is for manually entering in a discount percentage ie .10)

Second field is called B (for sales price) that is also manually entered. Settings for this field are set to number.

Third field is called ASP1 (for adjusted sales price) Settings for this field are set to number and custom calculation script is:

// total purchase
var a = this.getField("B").value;
// discount rate of total purchase
var b = this.getField("AP").value;
// compute discount amount
var fDiscount = a * b;
// compute total puchase less discount, net purchase price
event.value = a - fDiscount;

When the data is entered it gives me a answer for the subtracted adjusted price.

Is there a formula that would give me the subtracted OR added adjusted price by some way of entering maybe the + sign or the - sign first and then gining me the adjustment price. ie +.10 OR -.10

Thanks

My Product Information:
Acrobat Pro 8.1.2, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Why not just use the sign in the discount rate field entry?

Unless you specify otherwise, only a negative sign will show by default.

George Kaiser

billh098
Registered: Jun 6 2009
Posts: 47
Actually what shows is just the decimal and the number in the discount entry. ie. .10 I tried using the + sign first ie +.10 and it still gives me the subtracted discount on the adjusted sales price. ie $10,000, .10, $9,000. ???
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Have you tried anything else?

I used '-0.10' and the discount shows a "-10.00%". This would indicate a premium and not a discount.

To use the posative sign, I used "+0.10" and got "10.00%" displayed.

George Kaiser

billh098
Registered: Jun 6 2009
Posts: 47
Well that worked. When I entered a - it added the percentage to the Adjusted sales price. I would have thought you needed to add the + sign for it to "Add" the percentage like on a calculator. I don't understand how that works but it does. - for adding and + for subtracting??? If you have time you can explain why that is.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Think about your formula. You are subtracting the computed value.

If you use a negative number for the discount value you are subtracting a negative number. Subtracting a number is the same a adding the result of multiplying the number by a negative one and a negative number times a negative number results in a positive number being added.

It might help and be clearer to you and the users of your form to show then computed discount amount.

George Kaiser

billh098
Registered: Jun 6 2009
Posts: 47
I get it for the most part. I think the form is complete now and have tested it and it all works. I really appreciate all your help as I would have been stuck without it. This will save us alot of time and as I am fairly new to this scripting I can see where it makes life alot easier once it's done. Thanks again for your help and patience.