Calculation percentage in table

Hello again @sylvia.debaeremaeker,

I have taken a look at your code, and I have amended it a bit based on my understanding of what the template should look like. Please find the 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 belastbaar_15perc = detail.totaal_bedrag %}{% =$3+ belastbaar_15perc | currency %}
|{% assign [bedrag_RV_15perc] = calc_1+calc_2+calc_3 %}{% =$4+ [bedrag_RV_15perc] | 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 %}

For the most part the code was fine, lets discuss some of the changes I made.

First off, you started out with assigning the variables (belastbaar_30perc, bedrag_RV_30perc and calc) above your table and fori-loop. As you will use these variables in the loop, you should make sure they are assigned inside the loop.

As I understand that you want to display these variables on each line of the two tables, I have linked the variables to the specific forloop index by doing

{% capture bedrag_RV_15perc %}bedrag_RV_15perc_{{ forloop.index }}{% endcapture %}

So for the first line, the variable is called bedrag_RV_15perc_1, for the second line it’s called bedrag_RV_15perc_2 and so on. Thanks to this, I can also print these variables in the bottom table as for each line the correct variable will be displayed.

Next to that, I have added totals at the bottom of each column using different registers, e.g.:

{{ $2 | currency }}

Kindly note that in your initial code for the bottom table you coded

{{ $2/2 | currency }}

The reason you had to divide the $2 by two, is because the register kept adding the numbers over the two tables. You could solve this by adding assign $2 = 0 to reset the $2 to zero, or just show $2 in your total and recalculating the number again in the second table.

Hope the above code proofs useful to you.

In case you any more questions, do not hesitate to contact us.

Kind regards,
Robin