Calculation percentage in table

The percentage calculated is added up instead of calculated for each line separately.

image

{% newline %}
|Naam
|Bruto auteursrecht
|% RV
|Bedrag RV
|% RV
|Bedrag RV
{% newline %}
|-----30%-----
|----20%----:
|—10%—:
|-----15%—:
|—10%—:
|----15%----:
{% fori detail in custom.overzicht %}
{% newline %}
|{% input detail.naam %}
|{% $0+input detail.bedrag15% as:currency placeholder_default:0 %}
|{{ “15%” }}
|{{ $0/2*0.15 | currency }}
|{{ “30%” }}

A register ($0) is created to easily add up values.

You can find more about registers here:

Therefor it’s normal that the percentage calculated is added up.
You can fix your issue by replacing the line

|{{ $0/2*0.15 | currency }}

with

|{{ detail.bedrag15%/2*0.15 | currency }}

Also, it’s preferable to not use special sign, such as the percentage sign in your variable names, since this sometimes can lead to problems.

I would suggest to replace detail.bedrag15% with detail.bedrag15perc.

Kind regards
Sam

Sam

How can i add registers in a table so that the colums in the table stay in the right place. I’ve tried to add them, but this is the result i get in the table:

{% fori detail in custom.auteursrechten %}
{% newline %}
|{% input detail.naam %}
|{% $0+input detail.totaal_bedrag as:currency placeholder:" " %} | {{ $0 }}
|{{ detail.totaal_bedrag/2 | currency }}
|{{ “15%” }}
|{{ $1+detail.totaal_bedrag/2*0.15 | currency }} | {{ $1 }}

Hello @sylvia.debaeremaeker,

By adding the registers to the table as such (i.e. |{% $0+input detail.totaal_bedrag as:currency placeholder:" " %} | {{ $0 }}) the register is printed in a new column in the table on the same row. Therefore 750,00 will be printed in the third column (’%RV’) as the {{$0}} is printed next to the third pipe (’|’).

You need to make sure the amount of pipes in the content of your table corresponds with the amount of pipes in the header of your table.

Kind regards,
Robin

Is it possible to add the $, but not to display them?

Hi @sylvia.debaeremaeker,

By adding $0 before the input detail.totaal_bedrag the register is already added.

It stores the amount of input detail.totaal_bedrag and can be printed anywhere in or underneath the table. If you don’t with to display the $0 you should not print it.

Hope this is clear for you?

Do not hesitate to reach out in case of further questions.

Kind regards,
Robin

I want to use the outcome of the following formulas in another table and text (in the same template). How do I do that? I’ve tried with assign and result but none of them is working.

{% assign bedrag_RV_30perc = (detail.totaal_bedrag-59970)*0.30%}

|{% if detail.totaal_bedrag > 59970 %}{{ (detail.totaal_bedrag-59970) | currency }}{% else %}{{ " " }}{% endif %}
|{% if detail.totaal_bedrag > 59970 %}{{ (detail.totaal_bedrag-59970)*0.30 | currency }}{% else %}{{ " " }}{% endif %}

Hi @sylvia.debaeremaeker,

If I understand your question correctly, I think the above code you shared should work just fine.

You have assigned the amount of (detail.totaal_bedrag-59970-*0,30 to the variable bedrag_RV_30perc. If you now print this variable anywhere in your template, i.e.:

{{ bedrag_RV_30perc | currency }}

The result should be displayed.

You can also chose to include the assign in your if-statement so that the amount of the variable bedrag_RV_30perc is the result of the formula (in case the if-statement is true) or zero in case the if-statement is false.

Kind regards,
Robin

I’ve tried to use this, but the amount is not displayed.

|{% assign bedrag_RV_30perc = (detail.totaal_bedrag-59970)*0.30 | currency %}

|{{ bedrag_RV_30perc | currency }}


Hi @sylvia.debaeremaeker,

Would it be possible to share your whole code for this table so we can have a more detailed look?

Please make sure you use the ‘Blockquote’ when pasting your code.

Thank you!

Kind regards,
Robin

Blockquote
{% assign belastbaar_30perc = detail.totaal_bedrag-59970 | currency %}
{% assign bedrag_RV_30perc = (detail.totaal_bedrag-59970)*0.30 | currency %}
{% assign calc = MIN(15990;detail.totaal_bedrag)*0.50 %}{%=$0+ calc | currency %}
{% assign calc = MIN(31990-15990;MAX(0;detail.totaal_bedrag-15990))*0.25 %}{%=$0+ calc | currency %}
{% assign calc = MIN(59970-31990;MAX(0;detail.totaal_bedrag-31990))*0 %}{%=$0+ calc | currency %}


->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:" " %}
|{{ $0 | currency }}
|
|{% if detail.totaal_bedrag > 59970 %}{{ (detail.totaal_bedrag-59970) | currency }}{% else %}{{ " " }}{% endif %}
|{% if detail.totaal_bedrag > 59970 %}{{ (detail.totaal_bedrag-59970)*0.30 | currency }}{% else %}{{ " " }}{% endif %}
{% endfori %}
{% newline %}
|Totaal te betalen RV
|
|
|
|
|
{% 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 %}
|{% $2+input detail.totaal_bedrag as:currency placeholder:" " %}
|{{ detail.bedrag15perc/2*0.15 | currency }}
|{{ bedrag_RV_30perc | currency }}
{% endfori %}
{% newline %}
|TOTAAL
|{{ $2/2 | currency }}
|
|
{% endstripnewlines %}

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