Skip to main content
Yardmax
Known Participant
January 9, 2019
Question

Calculate Tax Owed Script in PDF

  • January 9, 2019
  • 1 reply
  • 1551 views

I haven't written formulas for PDF before, but have programmed websites for over 20 years. I need to display the tax owed in a field, which will be the result of the following:   ("Subtotal Parts" + "Subtotal Labor")*.08 = "TaxOwed" where the field labels/names are in the quote marks. I have no idea how to write this formula! Can someone help me, please? I'm assuming this would go in the Field Properties > Calculate > Custom calculation script  field, correct?

Here is the current script that I thought would work:

var p = this.getField("Subtotal Parts");

var l = this.getField("Subtotal Labor");

event.value = Math.round((p+l).value * 8.25) / 100;

This topic has been closed for replies.

1 reply

try67
Community Expert
January 9, 2019

You're almost there... Use this instead:

var p = Number(this.getField("Subtotal Parts").valueAsString);

var l = Number(this.getField("Subtotal Labor").valueAsString);

event.value = Math.round((p+l)*0.08);

Yardmax
YardmaxAuthor
Known Participant
January 9, 2019

This is awesome! Thank you! Now, the only thing is having the taxes displayed in dollars and cents. It's rounding it up to the next whole number, it seems. Even though the format of the field is currency.

try67
Community Expert
January 9, 2019

I assumed you wanted it rounded because you added the Math.round() command... If you don't, just drop it, like this:

event.value = (p+l)*0.08;