• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Complex calculation help

Participant ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

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?
Thanks in advance

 

Rob

Sorry, I am not mathematically minded 🙂

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

Views

483

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , 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;

Votes

Translate

Translate
Enthusiast ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

I believe Nesa may have hit it on the nail.

 

Rob

practice safe design | use a concept ~ Petrula Vrontikis

Votes

Translate

Translate

Report

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

Copy link to clipboard

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;

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

practice safe design | use a concept ~ Petrula Vrontikis

Votes

Translate

Translate

Report

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

Copy link to clipboard

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

 

Rob

practice safe design | use a concept ~ Petrula Vrontikis

Votes

Translate

Translate

Report

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

Copy link to clipboard

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.

Votes

Translate

Translate

Report

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