rounding

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Post Reply
msbask99
User
Posts: 27
Joined: Wed Jul 22, 2020 9:01 pm

rounding

Post by msbask99 »

We have a form that multiplies a purchase price by a sales tax and surcharge rate, then adds the three numbers together.

In the example attached, the actual product of the purchase price times the sales tax is $598.104; and the product of the purchase price times the surcharge is $24.921. When the numbers are added, the total is $17,237.03 but it should be $17,237.02.

Can anyone help with how to round both the sales tax and surcharge, so that the total will be correct?

test-math.pdf
(7.18 KiB) Downloaded 28 times
User avatar
Ovg
User
Posts: 461
Joined: Tue Sep 05, 2017 4:56 pm

Re: rounding

Post by Ovg »

change actions to:

Sales Tax (3.6%)

Code: Select all

event.value = (Number(this.getField("purchasePrice").valueAsString) * 0.036).toFixed(2);
Surcharge (0.15%)

Code: Select all

event.value =(Number(this.getField("purchasePrice").valueAsString) * 0.0015).toFixed(2);
test-math.pdf
(7.2 KiB) Downloaded 54 times
It's impossible to lead us astray for we don't care even to choose the way.
PDF-XChange PRO, 10.1.1 (Build 381) / W7 SP1 x64
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: rounding

Post by Tracker Supp-Stefan »

Hello Ovg,

Many thanks for the suggestions!

@msbask99 - please do let us know if the above helps!

Kind regards,
Stefan
msbask99
User
Posts: 27
Joined: Wed Jul 22, 2020 9:01 pm

Re: rounding

Post by msbask99 »

Ovg wrote: Mon Feb 06, 2023 6:05 am
I can't thank you enough. This works perfectly. Much appreciated!
User avatar
Ovg
User
Posts: 461
Joined: Tue Sep 05, 2017 4:56 pm

Re: rounding

Post by Ovg »

2msbask99

:thumbsup:, You're welcome! :)
It's impossible to lead us astray for we don't care even to choose the way.
PDF-XChange PRO, 10.1.1 (Build 381) / W7 SP1 x64
User avatar
Radi - Tracker Supp
Site Admin
Posts: 598
Joined: Tue Mar 03, 2015 12:46 pm

rounding

Post by Radi - Tracker Supp »

:)
Post Reply