# Adjusting template 'verworpen uitgaven' from 17 to 40%

We have our own template to calculate the “verworpen uitgaven”
In this template we use 17% for “de voordelen alle aard” of cars. This should be adjusted to 40%. Is this possible by simply adjusting the amounts below from 17% to 40%?

Blockquote

{% ifi accounts_f != empty %}
| {% t “Autokosten ten belope van een gedeelte van het voordeel alle aard” %} {% assign \$1 = 0 %}

{{ accounts_header }}{% for account in accounts_f %}
|| {{ account.number }} {{ account.name }} | {%=\$1+ ABS(account.value) %}{% endfor %}
|| | {{ \$1 | currency }} | 17% | {% assign autokosten_vaa = \$1*0.17 | round %}{%=\$0+ autokosten_vaa | currency %}{% result ‘autokosten_vaa’ autokosten_vaa %}{% endifi %}

Blockquote

Hello @Pieter1,

Welcome to the Community!

What you propose, would actually break your details of fiscal years where the 17% would still be applicable.
Just like in our standard template of “Verworpen uitgaven” you’ll need to build code in your template that gets the percentage of 40% where it should be shown.

In our template we did this for example:

``````{% assign jaar = period.year_end_date | date:'%Y' %}
``````

What we did here, is take the year ( %Y ) out of the `period.year_end_date` (that is the end date of the book year by the way).
So, if you’re working in Q3 2015, that variable `jaar` will give 2015 as result (normal book year!). We do this so we can make our template run in every fiscal period (and that change you’re talking about, is for book years after 2016, right?)

So simply put, you could make something like this:

``````{% if jaar >= '2017' %}
{% assign auto_perc = 0.40 %}
{% else %}
{% assign auto_perc = 0.17 %}
{% endif %}
``````

You could change the percentage (which is fixed text in your example) by:

``````{% assign autokosten_vaa = \$1*auto_perc | round %}
``````

However, above code is only to direct you to the correct code, step by step (if you are new to STL, I strongly suggest to take a look here or take a look at how we solved this in our standard template).
Because this is a change that can be done (and we definitely want to guide you there, step by step), but (knowing the fiscal theory behind it), you still have to take into account that if you have a broken book year that ends in 2017, the costs have to be divided in 2016 (to calculate with the old percentage of 17%) and 2017 (for 40%), right ?

Let us know @Pieter1 if above makes sense to you; if not, don’t hesitate and ask here. We’ll try to guide you there.

Is it correct to change the template to :

Blockquote

{% ifi accounts_f != empty %}
| {% t “Autokosten ten belope van een gedeelte van het voordeel alle aard” %} {% assign \$1 = 0 %}
{% if jaar >= ‘2017’ %}
** {% assign auto_perc = 0.40 %}**
{% else %}
** {% assign auto_perc = 0.17 %}**
{% endif %}

{{ accounts_header }}{% for account in accounts_f %}
|| {{ account.number }} {{ account.name }} | {%=\$1+ ABS(account.value) %}{% endfor %}
|| | {{ \$1 | currency }} | 40% | {% assign autokosten_vaa = \$1*auto_perc | round %}
{%=\$0+ autokosten_vaa | currency %}{% result ‘autokosten_vaa’ autokosten_vaa %}{% endifi %}

Blockquote

But with I still have no solution for a broken book year that ends in 2017, the costs have to be divided in 2016 (to calculate with the old percentage of 17%) and 2017 (for 40%). Do you have a solution ?

Hello Sven,

Is it correct to change the template to :

Blockquote

{% ifi accounts_f != empty %}
| {% t “Autokosten ten belope van een gedeelte van het voordeel alle aard” %} {% assign \$1 = 0 %}
{% if jaar >= ‘2017’ %}
** {% assign auto_perc = 0.40 %}**
{% else %}
** {% assign auto_perc = 0.17 %}**
{% endif %}

{{ accounts_header }}{% for account in accounts_f %}
|| {{ account.number }} {{ account.name }} | {%=\$1+ ABS(account.value) %}{% endfor %}
|| | {{ \$1 | currency }} | 40% | {% assign autokosten_vaa = \$1*auto_perc | round %}
{%=\$0+ autokosten_vaa | currency %}{% result ‘autokosten_vaa’ autokosten_vaa %}{% endifi %}

Blockquote

But with I still have no solution for a broken book year that ends in 2017, the costs have to be divided in 2016 (to calculate with the old percentage of 17%) and 2017 (for 40%). Do you have a solution ?

Hey @Pieter1,

If you’re completely new in STL, this might be a little be too much in the beginning, but I’ll try to explain you how this function is tackled in our standard code

``````{% comment %} vanaf 1/1/2017 update percentage vr VU 17% -> 40% indien tankkaart. Wordt meegeteld met link naar 'belastingberekening' -update 22/4/2017{% endcomment %}
{% assign jaar = period.year_end_date | date:'%Y' %}
{% if jaar >= '2017' %}
{% assign accounts_f_40_new = true %}
{% assign accounts_f_perc = 0.40 %}
{% endif %}
``````

So here we look at the year for the last period of the book year; if that is `2017` we’ll need to use a new percentage.
That’s what this does :

``````{% if jaar >= '2017' %}
{% assign accounts_f_40_new = true %}
{% assign accounts_f_perc = 0.40 %}
{% endif %}
``````

further more, we’ll have this code :

``````{% comment %}
onderstaande is enkel voor gebroken boekjaar op te vangen van 2016-2017, waarbij deel 2016 aan 17% is, en 2017 aan 40% is -
boekjaren die 3 kalenderjaren beslaan, wordt niet ondersteund
voor beide jaren wordt gerekend met de teller = 365 dagen
{% endcomment %}
{% if jaar == '2017' %}
{% if period.calendar_years.size == 2 %}
{% assign broken_by_2017 = true %}
{% endif %}
{% endif %}
``````

Basically, what we do here, is check if it’s indeed book year 2017 BUT also to check if it’s a broken book year.
We can know this by following code :

``````  {% if period.calendar_years.size == 2 %}
{% assign broken_by_2017 = true %}
{% endif %}
``````

So this variable `period.calendar_years.size` gives us how many calendar years there are in one current book year. If it’s 2, we have ourselves a broken book year.

Finally, we have the big code that generates the calculations with the right percentage, and a split up between 2016 and 2017 in case of a broken book year :

``````{% if accounts_f_40_new %}
{% ifi accounts_f_40 != empty or custom.f_40 != empty or check == true %}
| &nbsp;&nbsp;**{% t "Met tankkaart" %}** {% input custom.accounts.f_40 as:account_collection range:6,7 range:range_tankkaart %}{% assign \$1 = 0 %}
| {% ic %}*{% t "koppel hier de rekeningen die betrekking hebben op autokosten met tankkaart" %}*{% endic %}

{{ accounts_header }}{% for account in accounts_f_40 %}
|| {{ account.number }} {{ account.name }} | {%=\$1+ ABS(account.value) %}{% endfor %}{% fori extra in custom.f_40 %}
|| {% input extra.description %}           | {%=\$1+input extra.value as:currency placeholder:'0'%}{% endfori %}{% if broken_by_2017 %}
||{% ic %}*{% t "Er wordt gerekend met aantal dagen kalenderjaar / door aantal dagen begin boekjaar tot einddatum periode" %}*{% endic %}{% for year in period.calendar_years %}{% stripnewlines %}
{% assign start_date = year.start_date %}
{% assign end_date = year.end_date %}
{% assign by = year.end_date | date:'%Y' %}
{% assign amount_of_days = end_date+1-start_date %}
{% assign \$3 = 0 %}
{% endstripnewlines %}
|| {% t "Deel" %} {{ year.start_date | date:'%Y' }}| {% assign deel_bj = \$1*amount_of_days/total_days_in_book_year %}*{% \$3+input custom[year].tankkaart.deel_bj as:currency placeholder_default:deel_bj %}* | {% if by == '2017' %}{{ accounts_f_perc*100 | integer }}% | {% assign autokosten_vaa_new_aj = \$3*accounts_f_perc | round %}{% if autokosten_vaa_new_aj <= 0 %}*{%=\$0+ 0 | currency %}*{% else %}*{%=\$0+ autokosten_vaa_new_aj | currency %}*{% endif %}{% else %} 17% | {% assign autokosten_vaa_old_aj = \$3*0.17 | round %}{% if autokosten_vaa_old_aj <= 0 %}*{%=\$0+ 0 | currency %}*{% else %}*{%=\$0+ autokosten_vaa_old_aj | currency %}*{% endif %}{% endif %}{% endfor %}{% endif %}{% unless broken_by_2017 %}
||                                         | *{{ \$1 | currency }}* | {{ accounts_f_perc*100 | integer }}% | {% assign autokosten_vaa_new_aj = \$1*accounts_f_perc | round %}*{%=\$0+ autokosten_vaa_new_aj | currency %}*{% endunless %}
{% nic %}
{:/group}
{::group}
{% endnic %}
{% endifi %}
{% endif %}
{% endifi %}
``````

Can this be a start for you to tackle this code? I don’t want to dig in deeper with you, because it might be too much the first time around.

Can you try with your code?

PS every quarter we give 3 technical workshops (for free!) for people that want to start with STL; no need to have experience in coding because we start from scratch.