# Autokosten in template verworpen uitgaven automatisch toewijzen

**URL:** <https://community.silverfin.com/t/autokosten-in-template-verworpen-uitgaven-automatisch-toewijzen/561>\
**Category:** Templates\
**Tags:** input, attribute\_default\
**Created:** [January 2, 2018, 2:04pm UTC](https://community.silverfin.com/t/autokosten-in-template-verworpen-uitgaven-automatisch-toewijzen/561 "2018-01-02T14:04:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin](https://avatars.discourse-cdn.com/v4/letter/k/2acd7d/32.png) [@Kevin](https://community.silverfin.com/u/Kevin)\
**Post date:** [January 2, 2018, 2:04pm UTC](https://community.silverfin.com/t/autokosten-in-template-verworpen-uitgaven-automatisch-toewijzen/561/1 "2018-01-02T14:04:09Z")

</div>

Beste,

Ik ben momenteel de template verworpen uitgaven in Silverfin aan het bekijken en wou aan alle rubrieken vaste rekeningen toewijzen.  
Voor de autokosten heb ik enkele problemen.  
Onder de rubriek “Niet aftrekbare autokosten en minderwaarden op autovoertuigen” heb ik reeds een subcategarie “Kosten personenwagens 50% aftrekbaar” kunnen maken.  
Onder de # VAA en algemene rekeningen kan ik de juiste rekeningen die enkel betrekking hebben op 50% aftrekbaarheid tonen, maar wij zouden graag hebben dat deze rekeningen automatisch onder de subcategorie komen zonder ze te moeten selecteren.  
Verder kan ik de percentages aanpassen, maar gebeurt er geen berekening. Wanneer ik 70% van 100 wil nemen, dan krijg ik 0,00 euro te zien, maar wordt dit correct opgenomen in de tussenberekening.  
Wanneer ik een 2de subcategorie wil maken, dan worden de rekeningen van de eerste automatisch overgenomen ondanks dat ik deze eruit haal. Hoe kan ik dit oplossen?

Kan u mij hiermee verder helpen ?

Alvast bedankt.

Mvg,

Truyts Kevin

---

<div class="post-metadata">

**Author:** ![SamVanEenoo](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/samvaneenoo/32/134_2.png) [@SamVanEenoo](https://community.silverfin.com/u/SamVanEenoo)\
**Post date:** [January 8, 2018, 7:28am UTC](https://community.silverfin.com/t/autokosten-in-template-verworpen-uitgaven-automatisch-toewijzen/561/2 "2018-01-08T07:28:48Z")

</div>

Hi Kevin

You can give defaults accounts to your categorie in this way:

> {% if custom.accounts.subcategorie != blank %}  
> {% assign range\_kosten\_personenwageen\_50 = custom.accounts.subcategorie %}  
> {% endif %}

> {% input custom.accounts.subcategorie as:account\_collection range:6,7 default:range\_kosten\_personenwageen\_50 %}

Regarding the percentage, did you do something like this?

> || | _{{ $1 | currency }}_ | 50% | _{%=$0+ $1_0.50 | round | currency %}\*

Kind regards  
Sam

---

<div class="post-metadata">

**Author:** ![Kevin](https://avatars.discourse-cdn.com/v4/letter/k/2acd7d/32.png) [@Kevin](https://community.silverfin.com/u/Kevin)\
**Post date:** [January 8, 2018, 9:25am UTC](https://community.silverfin.com/t/autokosten-in-template-verworpen-uitgaven-automatisch-toewijzen/561/3 "2018-01-08T09:25:56Z")

</div>

Hi Sam,

This is how my code looks like :

```auto
| **{% t "Niet aftrekbare autokosten en minderwaarden op autovoertuigen" %}**

{{ accounts_header_cars }}{% fori autokost in custom.autokosten %}
|| {% t "Kosten personenwagens 50% aftrekbaar" %} {% input autokost.account_range_vaa as:account_collection range:74641050 placeholder:'VAA' %} {% input autokost.account_range as:account_collection range:61210050,61220050,61240050,63026050,64010050,66300050,74610050,74630050,76300050 placeholder:'Algemene rekeningen' %}{% assign accounts_vaa = period.accounts | range: autokost.account_range_vaa %}{% assign accounts = period.accounts | range: autokost.account_range %}{% assign $1 = -70 %}{% for account in accounts_vaa %}
|| {{ account.number }} {{ account.name }} | {{ account.value | currency}} | {% ic %}{% input autokost[account.number] as:percentage default:'0.7'%}{% endic %}{% nic %}{{ autokost[account.number] | percentage | remove:',0' }}{% endnic %}| {%=$1+ account.value*autokost[account.number] | round | currency %} | | {% endfor %}{% for account in accounts %}
|| {{ account.number }} {{ account.name }} ||| {%=$1+ account.value %}{% endfor %}{% ifi autokost.afschrijving_value != blank %}
|| {% input autokost.afschrijving placeholder_default:"630200 Afschrijving" %} ||| {%=$1+input autokost.afschrijving_value as:currency %}{% endifi %}{% if autokost.key %}{% fori extra in custom[autokost.key] %}
||{% input extra.description %} ||| {%=$1+input extra.value as:currency %} {% endfori %}{% endif %}
|| ||| *{{$1 | currency}}* | {% ic %}{% input autokost.percentage as:percentage as:integer default:'0.5'%}{% endic %}{% nic %}{{ autokost.percentage | percentage | remove:',00' }}{% endnic %} | *{%=$2+ $1*autokost.percentage | round | currency %}* {% endfori %}
|| ||| | | **{%=$0+ $2 | round | currency %}**
| 

{{ accounts_header_cars }}{% fori autokost in custom.autokosten %}
|| {% t "Kosten personenwagens 60% aftrekbaar" %} {% input autokost.account_range_vaa as:account_collection range:74641060 placeholder:'VAA' %} {% input autokost.account_range as:account_collection range:61210060,61220060,61240060,63026060,64010060,66300060,74610060,74630060,76300060 placeholder:'Algemene rekeningen' %}{% assign accounts_vaa = period.accounts | range: autokost.account_range_vaa %}{% assign accounts = period.accounts | range: autokost.account_range %}{% assign $1 = -70 %}{% for account in accounts_vaa %}
|| {{ account.number }} {{ account.name }} | {{ account.value | currency}} | {% ic %}{% input autokost[account.number] as:percentage default:'0.7'%}{% endic %}{% nic %}{{ autokost[account.number] | percentage | remove:',0' }}{% endnic %}| {%=$1+ account.value*autokost[account.number] | round | currency %} | | {% endfor %}{% for account in accounts %}
|| {{ account.number }} {{ account.name }} ||| {%=$1+ account.value %}{% endfor %}{% ifi autokost.afschrijving_value != blank %}
|| {% input autokost.afschrijving placeholder_default:"630200 Afschrijving" %} ||| {%=$1+input autokost.afschrijving_value as:currency %}{% endifi %}{% if autokost.key %}{% fori extra in custom[autokost.key] %}
||{% input extra.description %} ||| {%=$1+input extra.value as:currency %} {% endfori %}{% endif %}
|| ||| *{{$1 | currency}}* | {% ic %}{% input autokost.percentage as:percentage as:integer default:'0.6'%}{% endic %}{% nic %}{{ autokost.percentage | percentage | remove:',00' }}{% endnic %} | *{%=$2+ $1*autokost.percentage | round | currency %}* {% endfori %}
|| ||| | | **{%=$0+ $2 | round | currency %}**
| 
{% nic %}
{:/group}
{::group}
{% endnic %}
{% endifi %}
```

---

<div class="post-metadata">

**Author:** ![SamVanEenoo](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/samvaneenoo/32/134_2.png) [@SamVanEenoo](https://community.silverfin.com/u/SamVanEenoo)\
**Post date:** [January 8, 2018, 10:27am UTC](https://community.silverfin.com/t/autokosten-in-template-verworpen-uitgaven-automatisch-toewijzen/561/4 "2018-01-08T10:27:15Z")

</div>

Hi Kevin

First of all, default values are not automatically saved. This means that the value 0.5 will not be saved in our database. So autokost.percentage will not have the value 0.5 automatically. Only when you change and save it, you can use autokost.percentage. Since we are working with numbers, the best workaround is using a register (i.e. $4)

Also, when you define a number, don’t use quotes around it. This will make a string of the numbers which is not what you want.

The code beneath sums up the 2 issues above and should solve your problem. If not, please let us know.

> ```
> {% $4+input autokost.percentage as:percentage as:integer default:0.5 %}
> {%=$2+ $1*$4 | round | currency %}
> 
> ```

Kind regards  
Sam

---

<div class="post-metadata">

**Author:** ![Kevin](https://avatars.discourse-cdn.com/v4/letter/k/2acd7d/32.png) [@Kevin](https://community.silverfin.com/u/Kevin)\
**Post date:** [January 25, 2018, 11:06am UTC](https://community.silverfin.com/t/autokosten-in-template-verworpen-uitgaven-automatisch-toewijzen/561/5 "2018-01-25T11:06:35Z")

</div>

Hi Sam,

Thanks for the information.  
I just don’t understand it. When I adjust the code, I stil don’t get what I want.  
I get the following :

 ![Printscreen%20Silverfin%20-%20VU](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/1X/e02f6bced41665e1326895d8b28fd05c82749f18.png)  
I don’t get any subcalculations, the same accounts comes again under 60% while it’s is 50%, I get the same subcategorie twice.  
How can I fix these things?

Kind regards,

Kevin

---

<div class="post-metadata">

**Author:** ![sven](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/sven/32/1495_2.png) [@sven](https://community.silverfin.com/u/sven)\
**Post date:** [January 25, 2018, 12:39pm UTC](https://community.silverfin.com/t/autokosten-in-template-verworpen-uitgaven-automatisch-toewijzen/561/6 "2018-01-25T12:39:08Z")

</div>

Hi @Kevin,

Can you post your whole code, so I canhave a look at it,a nd help you further?

Thanks

---

<div class="post-metadata">

**Author:** ![Kevin](https://avatars.discourse-cdn.com/v4/letter/k/2acd7d/32.png) [@Kevin](https://community.silverfin.com/u/Kevin)\
**Post date:** [January 25, 2018, 12:52pm UTC](https://community.silverfin.com/t/autokosten-in-template-verworpen-uitgaven-automatisch-toewijzen/561/7 "2018-01-25T12:52:34Z")

</div>

```auto
| **{% t "Niet aftrekbare autokosten en minderwaarden op autovoertuigen" %}**

{{ accounts_header_cars }}{% fori autokost in custom.autokosten %}
|| {% t "Kosten personenwagens 50% aftrekbaar" %} {% input autokost.account_range_vaa as:account_collection range:74641050 placeholder:'VAA' %} {% input autokost.account_range as:account_collection range:61210050,61220050,61240050,63026050,64010050,66300050,74610050,74630050,76300050 placeholder:'Algemene rekeningen' %}{% assign accounts_vaa = period.accounts | range: autokost.account_range_vaa %}{% assign accounts = period.accounts | range: autokost.account_range %}{% assign $1 = -70 %}{% for account in accounts_vaa %}
|| {{ account.number }} {{ account.name }} | {{ account.value | currency}} | {% ic %}{% input autokost[account.number] as:percentage default:'0.7'%}{% endic %}{% nic %}{{ autokost[account.number] | percentage | remove:',0' }}{% endnic %}| {%=$1+ account.value*autokost[account.number] | round | currency %} | | {% endfor %}{% for account in accounts %}
|| {{ account.number }} {{ account.name }} ||| {%=$1+ account.value %}{% endfor %}{% ifi autokost.afschrijving_value != blank %}
|| {% input autokost.afschrijving placeholder_default:"630200 Afschrijving" %} ||| {%=$1+input autokost.afschrijving_value as:currency %}{% endifi %}{% if autokost.key %}{% fori extra in custom[autokost.key] %}
||{% input extra.description %} ||| {%=$1+input extra.value as:currency %} {% endfori %}{% endif %}
|| ||| *{{$1 | currency}}* | {% ic %}{% $4+input autokost.percentage as:percentage as:integer default:0.5 %}{% endic %}{% nic %}{{ autokost.percentage | percentage | remove:',00' }}{% endnic %} | *{%=$2+ $1*autokost.percentage | round | currency %}* {% endfori %}
|| ||| | | **{%=$2+ $1*$4 | round | currency %}**
| 

{{ accounts_header_cars }}{% fori autokost in custom.autokosten %}
|| {% t "Kosten personenwagens 60% aftrekbaar" %} {% input autokost.account_range_vaa as:account_collection range:74641060 placeholder:'VAA' %} {% input autokost.account_range as:account_collection range:61210060,61220060,61240060,63026060,64010060,66300060,74610060,74630060,76300060 placeholder:'Algemene rekeningen' %}{% assign accounts_vaa = period.accounts | range: autokost.account_range_vaa %}{% assign accounts = period.accounts | range: autokost.account_range %}{% assign $1 = -70 %}{% for account in accounts_vaa %}
|| {{ account.number }} {{ account.name }} | {{ account.value | currency}} | {% ic %}{% input autokost[account.number] as:percentage default:'0.7'%}{% endic %}{% nic %}{{ autokost[account.number] | percentage | remove:',0' }}{% endnic %}| {%=$1+ account.value*autokost[account.number] | round | currency %} | | {% endfor %}{% for account in accounts %}
|| {{ account.number }} {{ account.name }} ||| {%=$1+ account.value %}{% endfor %}{% ifi autokost.afschrijving_value != blank %}
|| {% input autokost.afschrijving placeholder_default:"630200 Afschrijving" %} ||| {%=$1+input autokost.afschrijving_value as:currency %}{% endifi %}{% if autokost.key %}{% fori extra in custom[autokost.key] %}
||{% input extra.description %} ||| {%=$1+input extra.value as:currency %} {% endfori %}{% endif %}
| ||| *{{$1 | currency}}* | {% ic %}{% input autokost.percentage as:percentage as:integer default:'0.4'%}{% endic %}{% nic %}{{ autokost.percentage | percentage | remove:',00' }}{% endnic %} | *{%=$2+ $1*autokost.percentage | round | currency %}* {% endfori %}
|| ||| | | **{%=$0+ $2 | round | currency %}**

| 
{% nic %}
{:/group}
{::group}
{% endnic %}
{% endifi %}
```

---

<div class="post-metadata">

**Author:** ![sven](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/sven/32/1495_2.png) [@sven](https://community.silverfin.com/u/sven)\
**Post date:** [January 25, 2018, 1:29pm UTC](https://community.silverfin.com/t/autokosten-in-template-verworpen-uitgaven-automatisch-toewijzen/561/8 "2018-01-25T13:29:06Z")

</div>

Hm okay I see @Kevin what’s wrong: you use defaults in your input-tags but as explained earlier by @SamVanEenoo you cannot do that.

If you have this for instance (and you can always try this out):

```auto
{% input custom.some.thing default:'70' %}

```

that object will `display` that value of 70 BUT the object `custom.some.thing` is actually **empty**.  
⚠ Only when you change it (and press ENTER), it will store data in that object.

Feel free to check [this](https://community.silverfin.com/t/case-when-to-use-placeholder-default-and-placeholder-default-tags/467) as well 😉

So, basically you gonna need to add something like this in your template:

```auto
{% if autokost.account_range_vaa != blank %}
  {% assign vaa_range = autokost.account_range_vaa %}
{% else %}
  {% assign vaa_range = '74' %}
{% endif %}

```

and use `vaa_range` to define your variable `accounts_vaa` :

```auto
{% assign accounts_vaa = period.accounts | range:vaa_range %}

```

Same goes for the percentage too :

```auto
{% input autokost[account.number] as:percentage default:'0.7'%}

```

The object `autokost[account.number]`is empty (even if you see it in the input/output-mode of Silverfin.

Can you try further with this info @Kevin? Hope this clarifies it a bit for you!
