# How to make a total when there are different ranges to consider?

How can the following situation be programmed:

There is a total amount of f.i. 75 000 or 25 000
For the maximum amount of 59 970:
a. for 0-15990: 50% may be deducted
b. for 15990-31990: 25% may be deducted
c. for 31990-59970: 0% may be deducted

This should form a new total serving as a base for new calculations.

There are different ways to calculate this. For instance, you can use the following code:

{% assign calc = MIN(15990;total)*0.50 %}{%=\$0+ calc | currency %}
{% assign calc = MIN(31990-15990;MAX(0;total-15990))*0.25 %}{%=\$0+ calc | currency %}
{% assign calc = MIN(59970-31990;MAX(0;total-31990))*0 %}{%=\$0+ calc | currency %}

The variable `total` is the total amount with which the calculation will be performed.

The `MIN` and `MAX`-tags take into account the lowest or highest amount between brackets.

The `\$0` serves as base for further calculations.

Hope the above is clear for you. In case you have any further questions or in case we misunderstood your question, do not hesitate to contact us.

Kind regards,
Robin

Hi Robin

This code is now used, however the amount is not calculated.

https://vdl.getsilverfin.com/f/1531/238019/permanent_texts/10997101/edit

I assume the print-screen is based on the code I shared here?

Can you further explain how the amount in the column ‘Belastbaar bedrag à 15%’ should be calculated? Perhaps also include an numerical example?

To maintain the overview, would it be possible to keep reacting in the same topic in case your question relates to the same issue?

Thank you!

Kind regards,
Robin

Total bruto auteursrecht Taxable amount 15%
1 75000 47975
2 25000 14752,5
1 For the amount up to 59970: % cost to deduct calculation amount to deduct
0-15990 50% 15990*0,5 7995
15990-31990 25% 16000*0,25 4000
31990-59970 0%
Taxable amount 15% 59970-7995-4000
2 For the amount up to 59970: % cost to deduct calculation amount to deduct
0-15990 50% 15990*0,5 7995
15990-31990 25% 9010*0,25 2252,5
31990-59970 0%
Taxable amount 15% 25000-7995-2252,5

Thank you for sharing this numerical example. Please find the adapted code below:

->Gegevens voor indiening van AANGIFTE ROERENDE HEFFING - AUTEURSRECHTEN<-

Deze gegevens zijn over te nemen in de webtoepassing RV-on-web. Meerdere genieters kunnen op één aangifte ingediend worden.

Aangever: {{ company.name }}
Verantwoordelijke: {% input custom.dossierbeheerder.naam %}
Datum betaalbaarstelling: {% input custom.betaalbaarstelling.datum as:date %}

{% stripnewlines %}
{% newline %}
|Naam
|Totaal bruto auteursrecht
|Belastbaar bedrag à 15%
|Bedrag RV 15%
|Belastbaar bedrag à 30%
|Bedrag RV 30%
{% newline %}

|–
|–:
|–:
|–:
|–:+
{% fori detail in custom.auteursrechten %}
{% newline %}
|{% input detail.naam %}
|{% =\$2+input detail.totaal_bedrag as:currency placeholder:" " %}
{% assign calc_1 = MIN(15990;detail.totaal_bedrag)*0.50 %}
{% assign calc_2 = MIN(31990-15990;MAX(0;detail.totaal_bedrag-15990))*0.25 %}
{% assign calc_3 = MIN(59970-31990;MAX(0;detail.totaal_bedrag-31990))*0 %}
{% capture bedrag_RV_15perc %}bedrag_RV_15perc_{{ forloop.index }}{% endcapture %}
{% capture bedrag_RV_30perc %}bedrag_RV_30perc_{{ forloop.index }}{% endcapture %}
|{% assign [bedrag_RV_15perc] = MIN(59970;detail.totaal_bedrag)-(calc_1+calc_2+calc_3) %}{% =\$3+ [bedrag_RV_15perc] | currency %}
|{% =\$4+ [bedrag_RV_15perc]*0.15 | currency %}
|{% if INT(detail.totaal_bedrag) > 59970 %}{% assign belastbaar_30perc = detail.totaal_bedrag-59970 %}{% =\$5+ belastbaar_30perc | currency %}{% else %}{{ " " }}{% endif %}
|{% if INT(detail.totaal_bedrag) > 59970 %}{% assign [bedrag_RV_30perc] = (detail.totaal_bedrag-59970)*0.30 %}{% =\$6+ [bedrag_RV_30perc] | currency %}{% else %}{{ " " }}{% endif %}
{% endfori %}
{% newline %}
|Totaal te betalen RV
|{{ \$2 | currency }}
|{{ \$3 | currency }}
|{{ \$4 | currency }}
|{{ \$5 | currency }}
|{{ \$6 | currency }}
{% endstripnewlines %}

IN TE DIENEN BINNEN DE 15 DAGEN NA DATUM VAN BETAALBAARSTELLING!

->Overzicht van de toegekende auteursrechten<-

Met oog op eventuele latere melding aan de administratie

{% stripnewlines %}
{% newline %}
|Uitbetalende onderneming:
|{{ company.name }}
{% newline %}
|Datum van toekenning:
|{{ custom.betaalbaarstelling.datum }}
{% newline %}
|Naam
|Bruto auteursrecht
|Bedrag RV 15%
|Bedrag RV 30%
{% newline %}
|–
|–:
|–:+
{% fori detail in custom.auteursrechten %}
{% newline %}
|{% input detail.naam %}
|{% input detail.totaal_bedrag as:currency placeholder:" " %}
{% capture bedrag_RV_15perc %}bedrag_RV_15perc_{{ forloop.index }}{% endcapture %}
|{{ [bedrag_RV_15perc] | currency }}
{% capture bedrag_RV_30perc %}bedrag_RV_30perc_{{ forloop.index }}{% endcapture %}
|{{ [bedrag_RV_30perc] | currency }}
{% endfori %}
{% newline %}
|TOTAAL
|{{ \$2 | currency }}
|{{ \$4 | currency }}
|{{ \$6 | currency }}
{% endstripnewlines %}

I suggest you review this code and in case something is still missing or wrong, try to edit it yourself. In case you have problems or questions in this respect, you can still reach out to us by replying in this topic.

Good luck!

Kind regards,
Robin

The formula for the calculation is correct now.
The only issue i still have is the fact that instead of ‘Bedrag RV15%’ the ‘Belastbaar bedrag RV15%’ is displayed in the second table. However, the total is correct.

I’ve tried bij replacing the ‘captured’ amount by {% =\$4+ [bedrag_RV_15perc]*0.15 | currency %}, but then the total amount is no longer correct.

I think you should just replace `{{ [bedrag_RV_15perc] | currency }}` (around line 74) with

{{ [bedrag_RV_15perc]*0.15 | currency }}

without the `\$4`, otherwise the register will keep on adding the values and the total will be twice the amount of the total of the first table.

Kind regards,
Robin