## Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.

• Complex calculation help

# Complex calculation help

Participant ,
Jul 28, 2021 Jul 28, 2021

Copied

Hi

I asked sometiem back about how to calculate TAX on a PDF invoice.
My accountant states that there is some issues, which is basically under €300 the tax rate is 0% and above is 9%.
Is there a way to have it write a calculation to take the field (let's say it's called 'subtotal' and the tax field is called 'tax') and to have it calculate and display the options based on the if it is above or below 300?

So, something like:
if subtotal<300 tax=0 else tax=subtotal*0.9 or something like that?

Rob

Sorry, I am not mathematically minded 🙂

practice safe design | use a concept ~ Petrula Vrontikis
TOPICS
How to, JavaScript

Views

38

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Adobe Community Professional , Jul 28, 2021 Jul 28, 2021
If I understand you right, use this as custom calculation of "tax" field: if(this.getField("subtotal").value >= 300) event.value = this.getField("subtotal").value*0.9; else event.value = 0;

Likes

8 Replies 8
Enthusiast ,
Jul 28, 2021 Jul 28, 2021

Copied

You want to show result in 'tax' field or some other field like 'total'?

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Participant ,
Jul 28, 2021 Jul 28, 2021

Copied

I believe Nesa may have hit it on the nail.

Rob

practice safe design | use a concept ~ Petrula Vrontikis

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 28, 2021 Jul 28, 2021

Copied

If I understand you right, use this as custom calculation of "tax" field:

if(this.getField("subtotal").value >= 300)
event.value = this.getField("subtotal").value*0.9;
else event.value = 0;

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Participant ,
Jul 28, 2021 Jul 28, 2021

Copied

I will check this out and let you know. Thanks.

practice safe design | use a concept ~ Petrula Vrontikis

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Participant ,
Jul 28, 2021 Jul 28, 2021

Copied

OK, it seems to be showing the subtotal minus the tax. I need it to show the amount of 9% as an addition to the subtotal. So, 9% of the subtotal, which will then be added in the grand total field.

If that makes sense.

Rob

practice safe design | use a concept ~ Petrula Vrontikis

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 28, 2021 Jul 28, 2021

Copied

The code above is wrong, anyway. If you multiply by 0.9 you get the result of 90% tax, not 9%. You need to multiply by 0.09 for that. If you want to show the total plus tax then multiply by 1.09.

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Participant ,
Jul 28, 2021 Jul 28, 2021

Copied

My mistake I need it to be 0.09 and that works fine.

Rob

practice safe design | use a concept ~ Petrula Vrontikis

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
LEGEND ,
Jul 28, 2021 Jul 28, 2021

Copied

LATEST

You should also find out the rules for rounding tax, and make sure you follow them. Accountants get very picking about fractions of a cent.

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Resources