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.
Hi @sylvia.debaeremaeker,
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 @sylvia.debaeremaeker,
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
Hi @sylvia.debaeremaeker,
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.
Hi @sylvia.debaeremaeker,
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