How to select a car and other data of that car in an other template

Hi,

Is it possible to select a car that is inserted in the template Wagenpark in an other template?
if this is selected, is it also possible to give the correct %VU verworpen, like in template “VU autokosten” or “Voordelen van alle aard”

case:
I would like to create a template “beroepsverplaatsingen” for “eenmanszaken” that calculates the fiscal % and also calculates a proffesional %.

Hi Alexander,

It is possible to loop over all cars in the fleet template, like this:

{% for car in period.reconciliations.wagenpark.custom.fleet %}
  Taxyear 2021 starting on 01/01/2020 or later:
  {% capture car_disallowed %}car_disallowed_{{ car.key }}{% endcapture %}
  The disallowed % is: {{ period.reconciliations.wagenpark.results.[car_disallowed] }}
{% endfor %}

In all other cases, before TY2021, it works a bit different because for those tax years there are fixed ranges of disallowed percentages: 10, 20, 25, 30, 40 and 50%. All cars with a specific % are put into one result tag that you can use as a collection to loop over them, e.g. for 50%:

{% assign cars_at_50 = period.reconciliations.wagenpark.results.cars_at_50 | split:"," %}

{% for car in cars_at_50 %}
  {{ car }} {% comment %}car is here combination of brandtype and license plate {% endcomment %}
{% endfor %}

Regards,
Michiel

Michiel,

Is it also possible to loop over resulttag “Car_total_fleet”?
I tried this similar like code mentioned above but it didn’t work.

Is it also possible to loop over the name of the car? (“wagen” or “merk en type”)

Goal is to create a table like this:
Wagen | totale kost wagen | % privé beperking | kost wagen na privé beperking | %fiscale beperking | kost wagen na Fiscale beperking

Hi Alexander,

Looping over the car type is possible.

{% for car in period.reconciliations.wagenpark.custom.fleet %}
{{ car.brand_type }}
{% endfor %}

To loop over results you first need to be sure how they are called. You can find it in the code or using debug mode. To access the result and its workings I refer you to our documentation.

Regards,

Gary

Hey, Code mentioned above works just fine.

But I also want to include the “Datum aankoop”, VU% and Total.

In fact, I want to create a table looking like this:

Yellow is data from wagenpark.
Collum “Wagen” a select options, so only the ‘personenwagens’ can be selected.
further more, if a car is bought before 01/01/2018 then an if statement should be made
if “datum aankoop” is before 01/01/2018 then %aftrekbaar = 75%

Hi @AlexanderDB

That is a useful case you are building! :slight_smile:

This should help you get started to build the template you need:

{% stripnewlines %}
| Car
| Driver
| Purchase date
| D.E.%
| Total
{% newline %}
|--------
|--------
|:------:
|-------:
|-------:
  {% for car in period.reconciliations.wagenpark.custom.fleet %}
    {% capture car_disallowed %}car_disallowed_{{ car.key }}{% endcapture %}
    {% assign disallowed_percentage = period.reconciliations.wagenpark.results.[car_disallowed] %}

    {% capture car_total %}car_total_{{ car.key }}{% endcapture %}
    {% assign car_total_cost = period.reconciliations.wagenpark.results.[car_total] %}

      {% if disallowed_percentage != blank %}
        {% newline %}
        | {{ car.brand_type }}
        | {{ car.beneficiary }}
        | {{ car.purchasedate | date:"%d/%m/%Y" }}
        | {{ disallowed_percentage | percentage }}
        | {{ car_total_cost | currency }}
      {% endif %}

  {% endfor %}
{% endstripnewlines %}

Robbe,

Thanks for the help.

This is the code I have for now:

{% stripnewlines %}
| {% t "Car" %}
| {% ic %}{% t "Driver" %} {::infotext as="hover"}Deze kolom is verborgen in "voorbeelweergave"{:/infotext}{% endic %}
| {% ic %}{% t "Purchase date" %} {::infotext as="hover"}Deze kolom is verborgen in "voorbeelweergave"{:/infotext}{% endic %}
| {% t "D.E.%" %}
| {% t "BRUTOBEDRAG" %}
| {% t "BEROEPSBEPERKING (AFTREKBAAR)" %}
| {% t "BEDRAG NA BEROEPSBEPERKING" %}
| {% t "FISCALE BEPERKING (AFTREKBAAR)" %}
| {% t "NETTOBEDRAG" %}

{% newline %}
|--------
|--------
|:------:
|-------:
|-------:
|-------:
|-------:
|-------:
|-------:
{% ic %}#{% endic %}
{% nic %}+{% endnic %}

  {% for car in period.reconciliations.wagenpark.custom.fleet %}
    {% capture car_disallowed %}car_disallowed_{{ car.key }}{% endcapture %}
    {% assign disallowed_percentage = period.reconciliations.wagenpark.results.[car_disallowed] %}

    {% capture car_total %}car_total_{{ car.key }}{% endcapture %}
    {% assign car_total_cost = period.reconciliations.wagenpark.results.[car_total] %}

      {% if disallowed_percentage != blank %}
        {% newline %}
        | {{ car.brand_type }} {{ car.license_plate }}
        | {% ic %}{{ car.beneficiary }}{% endic %}
        | {% ic %}{{ car.purchasedate | date:"%d/%m/%Y" }}{% endic %}
        
        {% assign date_1 = "2018-01-01" %}
        {% assign aankoopdatum = car.purchasedate |date:"%Y-%m-%d" %}
        
        | {% if aankoopdatum > date_1  or car.emission > 199 %}{% assign VU = disallowed_percentage %}{% else %}{% assign VU = 0.25 %}{% endif %} 
          {{ VU |percentage }}
        | {% =$10+ car_total_cost | currency %}
        
{% comment %}beroepspercentage (aftrekbaar) default 100% laten weergeven en automatisch "bedrag na beroepsbeperking" laten berekenen {% endcomment %}

        |*{% input custom.percentageberoepPW.percentage  as:percentage %}*
        {% assign defpercPW = custom.percentageberoepPW.percentage   %}
        
        |{% assign beroepsbep = defpercPW*car_total_cost %}
        {% =$11+ beroepsbep | currency %}
        |{% assign aftrekbaarfiscaal = 1-VU %}
        {{ aftrekbaarfiscaal | percentage }}
        | {% assign fiscbeperking = beroepsbep*aftrekbaarfiscaal %} 
        {% =$12+ fiscbeperking | currency %}
     
        | 
      {% endif %}
  {% endfor %}
{% newline %}

{% comment %}bereken de totalen van beroeps en fiscale eperkingen{% endcomment %}
|**{% t "Totaal" %}**
|
|
|
|{% assign totpw = $10 as:currency %}
**{{ totpw | currency }}**
|
| {% assign totberoepsbep = $11 as:currency %}
**{{ totberoepsbep | currency }}**
|
|{% assign totfiscbeperking = $12 as:currency %}
**{{ totfiscbeperking | currency }}**
{% endstripnewlines %}

Still, I’m struggling with this part:

{% comment %}beroepspercentage (aftrekbaar) default 100% laten weergeven en automatisch "bedrag na beroepsbeperking" laten berekenen {% endcomment %}

        |*{% input custom.percentageberoepPW.percentage  as:percentage %}*

If I give a value, e.g. 70,00% in the input field on the first line, it will be the same in the next lines, which is not what I expect.

I should be able to give different values in the next lines.
I can’t remember how to solve this.

Can you help me with this?

Hi @AlexanderDB

The reason for this, is that now you are creating the same inputfield in each iteration of the for loop.

You can create an inputfield based on the car.key that is already used to fetch the results from the fleet template.

For example:

|{% capture percentageberoepPW %}percentageberoepPW_{{ car.key }}{% endcapture %}
 *{% input custom.[percentageberoepPW].percentage  as:percentage %}*
{% assign defpercPW = custom.[percentageberoepPW].percentage %}

This way every car has it’s own inputfield to provide the percentage of professional use :slight_smile:

1 Like

Robbe,

That’s it!
I’ve should have know’n this one.

This works,
Thanks!

Hey @Robbe_Dewilde ,

I am interested in this model, however here is what I get when I copy the code

Thank’s for your help,

Kind regards

Hi @THANAS

This example is taking information that was completed in the fleet reconciliation template.
So this will only show the cars that are completed there.

Best regards
Robbe

hi @Robbe_Dewilde,

In reconciliation “fleet”, the informations are completed but the informations don’t appear.


thank’s a lot,

Hi @THANAS

The code snippet combined with the car information below is displaying the information in the template for me, could you check if this is working for you as well?

{% assign fleet_template = period.reconciliations.wagenpark %}

{% if fleet_template != blank %}

{% stripnewlines %}
| {% t "Car" %}
| {% ic %}{% t "Driver" %} {::infotext as="hover"}Deze kolom is verborgen in "voorbeelweergave"{:/infotext}{% endic %}
| {% ic %}{% t "Purchase date" %} {::infotext as="hover"}Deze kolom is verborgen in "voorbeelweergave"{:/infotext}{% endic %}
| {% t "D.E.%" %}
| {% t "BRUTOBEDRAG" %}
| {% t "BEROEPSBEPERKING (AFTREKBAAR)" %}
| {% t "BEDRAG NA BEROEPSBEPERKING" %}
| {% t "FISCALE BEPERKING (AFTREKBAAR)" %}
| {% t "NETTOBEDRAG" %}

{% newline %}
|--------
|--------
|:------:
|-------:
|-------:
|-------:
|-------:
|-------:
|-------:
{% ic %}#{% endic %}
{% nic %}+{% endnic %}

  {% for car in period.reconciliations.wagenpark.custom.fleet %}
    {% capture car_disallowed %}car_disallowed_{{ car.key }}{% endcapture %}
    {% assign disallowed_percentage = period.reconciliations.wagenpark.results.[car_disallowed] %}

    {% capture car_total %}car_total_{{ car.key }}{% endcapture %}
    {% assign car_total_cost = period.reconciliations.wagenpark.results.[car_total] %}

      
        {% newline %}
        | {{ car.brand_type }} {{ car.license_plate }}
        | {% ic %}{{ car.beneficiary }}{% endic %}
        | {% ic %}{{ car.purchasedate | date:"%d/%m/%Y" }}{% endic %}
        
        {% assign date_1 = "2018-01-01" %}
        {% assign aankoopdatum = car.purchasedate |date:"%Y-%m-%d" %}
        
        | {% if aankoopdatum > date_1  or car.emission > 199 %}{% assign VU = disallowed_percentage %}{% else %}{% assign VU = 0.25 %}{% endif %} 
          {{ VU |percentage }}
        | {% =$10+ car_total_cost | currency %}
        
{% comment %}beroepspercentage (aftrekbaar) default 100% laten weergeven en automatisch "bedrag na beroepsbeperking" laten berekenen {% endcomment %}

        |*{% input custom.percentageberoepPW.percentage  as:percentage %}*
        {% assign defpercPW = custom.percentageberoepPW.percentage   %}
        
        |{% assign beroepsbep = defpercPW*car_total_cost %}
        {% =$11+ beroepsbep | currency %}
        |{% assign aftrekbaarfiscaal = 1-VU %}
        {{ aftrekbaarfiscaal | percentage }}
        | {% assign fiscbeperking = beroepsbep*aftrekbaarfiscaal %} 
        {% =$12+ fiscbeperking | currency %}
     
        | 
  {% endfor %}
{% newline %}

{% comment %}bereken de totalen van beroeps en fiscale eperkingen{% endcomment %}
|**{% t "Totaal" %}**
|
|
|
|{% assign totpw = $10 %}
**{{ totpw | currency }}**
|
| {% assign totberoepsbep = $11 %}
**{{ totberoepsbep | currency }}**
|
|{% assign totfiscbeperking = $12 %}
**{{ totfiscbeperking | currency }}**
{% endstripnewlines %}

{% endif %}

hey @Wouter_Bruynsteen ,

It works.

Is it possible that instead of the percentage in the column “BEROEPSBEPERKING” we can put a number and add a column just after which divides the amount of the column “Brutobedrag” by the number of the column “BEROPSBEPERKING”?

Is it possible that the amount in the “Brutobedrag” column can be changed? In Fleet template, we added an account that we do not want to include in our table here

Thank you so much for your help,

Hi @THANAS

Yes, those things should be possible:

  1. You can change the input type of {% input custom.percentageberoepPW.percentage as:percentage %} from percentage to integer or currency to add a number instead of a percentage.
  2. You can add this new column by adjusting the numbers of pipes in the headers, table definition & inside {% for car in period.reconciliations.wagenpark.custom.fleet %}, where you can then print the calculated amount of Brutobedrag/Beroepsbeperking
  3. You can change the amount of the “Brutobedrag” by deducting the amount(s) of the accounts you don’t want to include from the original “Brutobedrag”.

If you need help on some specific parts in the code while making these adjustments, don’t hesitate to ask!

Kind regards
Wouter