Export disclosure in style

Hello Sven,

This is the code:

{% t= "Detail van de kosten" fr:"Détails des frais" en:"Detail of all costs" %}
{% t= "Beroeps-<br />beperking" fr:"Limite professionnelle" en:"Occupational disability" %}
{% t= "Totale beperking" fr:"Limite totale" en:"Total limitation" %}
{% t= "Aftrekbaar" fr:"Déductible" en:"Deductible" %}
{% t= "Niet aftrekbaar" fr:"Non déductible" en:"Not deductible" %}
{% t= "Totaal" fr:"Total" en:"Total" %}
{% t= "Divers" fr:"Divers" en:"Miscellaneous" %}
{% t= "titel rubriek" fr:"titre rubrique" en:"title category" %}

{% if cost_categories_string == blank or cost_keys_string == blank %}
  {% assign cost_categories_string = "Personenwagens|Bedrijfswagens|Overige" %}
  {% assign cost_keys_string = "personenwagens|bedrijfswagen|soverige" %}
{% endif %}

{% t= "Personenwagens|Bedrijfswagens|Overige" en:"Vehicles passenger cars|Vehicles company cars|Other" fr:"Voitures|Véhicules d'entreprise|Autres" de:"Vehicles passenger cars|Vehicles company cars|Other" %}
{% capture cost_categories_string %} {% t "Personenwagens|Bedrijfswagens|Overige" %}{% endcapture %}

{% assign cost_categories = cost_categories_string | split:"|" %}
{% assign cost_keys = cost_keys_string | split:"|" %}

{% assign toegewezen = "" %}
{% assign count = 0 %}

{% ic %}*Release 2018-09*{% endic %}

{% capture header %}|-----------64%---------------|---------------12%-----------:|---------------12%-----------:|---------------12%-----------:+{% endcapture %}

{% capture table %}

-----------------------------------------------------------------------------------------------------------

{% stripnewlines %}
{{ header }}
{% newline %}
| **{% t "Detail van de kosten" %}**    
| **{{ period.year_end_date | date:'%Y' }}**
| **{% t "Beroeps-<br />beperking" %}**<br />**({% t "Niet aftrekbaar" %})**
| **{% t "Totale beperking" %}**    
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %}                
{% newline %}
{% for cost_category in cost_categories %}
  {% assign $11 = 0 %}
  {% assign $12 = 0 %}
  {% assign $13 = 0 %}
  {% assign category_key = cost_keys[forloop.index0] %}  
  
  {% ifi custom[category_key].accounts != blank %}
  {% newline %}
  | {% t cost_category %} {% input custom[category_key].accounts as:account_collection range:6,7 accounts_var:costs %}  | | |
  {% newline %}
  {{ header }}
  {% newline %}
  {% for account in costs %}
    {% assign toegewezen = toegewezen | append: account.number | append:";" %}
    | {{ account.name }}
    | {%=$11+ account.value as:currency %}
    | {% input custom[account.number].vin as:percentage placeholder:'0.00%' %}
        {% if custom[account.number].vin == blank %}
          {% assign vin = 1 %}
        {% else %}
          {% assign vin = 1-custom[account.number].vin placeholder:'' %}
        {% endif %}
        {% $12+ vin*account.value as:currency %}
    | {{ account.value-1*vin*account.value | currency }}
    {% newline %}
  {% endfor %}
  {% capture custfieldname %}vrije_lijnen_{{category_key}}{%endcapture%}
  {% fori vrije_cost_lijnen in custom.[custfieldname] %}
    | {% input vrije_cost_lijnen.omschrijving placeholder:'' %} 
    | {% $31+input vrije_cost_lijnen.value as:currency as:currency placeholder:'' %} {% assign $33 = vrije_cost_lijnen.value %}
    | {% input vrije_cost_lijnen.vin as:percentage placeholder:'0.00%' %}
        {% if vrije_cost_lijnen.vin == blank %}
          {% assign vin = 1 %}
        {% else %}
          {% assign vin = 1-vrije_cost_lijnen.vin placeholder:'' %}
        {% endif %}
        {% $32+ vin*$33 as:currency %} 
    | {{ $33-1*vin*$33 | currency }} 
    {% newline %}
    {% if forloop.last %}
      |     
      | **{% =$21+ $11+$31 as:currency %}** 
      |     
      | **{% =$22+ ($11-$12)+($31-$32) as:currency %}** 
      {% result category_key $34 %}|
  {% assign $31 = 0 %}
  {% assign $32 = 0 %}
  {% newline %}
  {% endif %}
  {% endfori %}
  {% newline %}
  {% endifi %}
{% endfor %}
{% fori vrije_cost in custom.vrije_tekst %}
  {% assign $11 = 0 %}
  {% assign $12 = 0 %}
  {% assign $13 = 0 %}
{% newline %}
  | {% input vrije_cost.titel placeholder:'titel rubriek' %} {% input vrije_cost.accounts as:account_collection range:6,7 accounts_var:vrije_costs %} | | |
  {% newline %}
  {{ header }}
  {% newline %}
  {% for account2 in vrije_costs %}
     |{{ account2.name }}
     |{%=$11+ account2.value as:currency %}
     | {% input custom[account2.number].vin as:percentage placeholder:'0.00%' %}
        {% if custom[account2.number].vin == blank %}
          {% assign vin = 1 %}
        {% else %}
          {% assign vin = 1-custom[account2.number].vin placeholder:'' %}
        {% endif %}
        {% $12+ vin*account2.value as:currency %}
     |{{ account2.value-1*vin*account2.value | currency }}
    {% newline %}
  {% endfor %}
  {% capture custfieldname2 %}vrije_lijnen2_{{vrije_cost.key}}{%endcapture%}
  {% fori vrije_cost_lijnen2 in custom.[custfieldname2] %}
    | {% input vrije_cost_lijnen2.omschrijving placeholder:'' %} {% assign $33 = vrije_cost_lijnen2.value %}
    | {% $31+input vrije_cost_lijnen2.value as:currency as:currency placeholder:'' %} 
    | {% input vrije_cost_lijnen2.vin as:percentage placeholder:'0.00%' %}
        {% if vrije_cost_lijnen2.vin == blank %}
          {% assign vin = 1 %}
        {% else %}
          {% assign vin = 1-vrije_cost_lijnen2.vin placeholder:'' %}
        {% endif %}
        {% $32+ vin*$33 as:currency %} 
    | {{ $33-1*vin*$33 | currency }} 
    {% newline %}
    {% if forloop.last %}
      |     
      | **{% =$21+ $11+$31 as:currency %}** 
      |     
      | **{% =$22+ ($11-$12)+($31-$32) as:currency %}** 
      {% result category_key $34 %}|
      {% assign $31 = 0 %}
      {% assign $32 = 0 %}
      {% newline %}
  {% endif %}
  {% endfori %}
  {% newline %}
{% endfori %}
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %}                
{% newline %}
{% endstripnewlines %}

{{ header }}
| **{% t "Totaal" %}**                  | **{{ $21 | currency }}** |  |  **{{ $22 | currency }}** 

-----------------------------------------------------------------------------------------------------------

{% endcapture %}

{{ table }}

Thanks,

Sylvie

@svalais,

as I thought… It is that issue that I explained earlier.

You can find the reasoning behind it, asl well as a direction into the solution here:

Can you put your own spin on it? Let us know if it works :muscle:

Hello Sven,

I changed the ifi statement in the following but it doesn’t work: {% ifi custom[category_key].accounts != blank or custom.[custfieldname].omschrijving != blank %}

What do I wrong?

Thanks,

Sylvie

Hello @svalais,

As I mentionned before, your custom object :

custom[category_key].accounts

is empty if you don’t click on the hast-tag # . You need to leave that out of your ifi-statement, and/or replace it with something that does have actual value.

Like your accounts_var costs :

You could check on the value `costs.value’
like

{% ifi costs.value != 0 %}

or

the object itself :

{% ifi costs != blank %}

The second part of your ifi-statement seems okay, although I don’t see it in your original posted code where that object is being made (or inputted).

Hello Sven,

We are using the code of your disclosure Beroepskosten 2.0 but we use the code in 2 different disclosures.

In your code you also have the same ifi statement but we add for each code free lines and that the 2nd part of ifi statement I added today but it doesn’t work.

I tried to use {% ifi costs != blank %} but it does also not work.

Can you help me?

Thanks,

Sylvie

Sure @svalais

Just to be sure, can you post the whole code again? Because I’m not sure yet if I’m working on the right code or not :see_no_evil:

Sven,

This is the whole code:

{% t= "Detail van de kosten" fr:"Détails des frais" en:"Detail of all costs" %}
{% t= "Beroeps-<br />beperking" fr:"Limite professionnelle" en:"Occupational disability" %}
{% t= "Totale beperking" fr:"Limite totale" en:"Total limitation" %}
{% t= "Aftrekbaar" fr:"Déductible" en:"Deductible" %}
{% t= "Niet aftrekbaar" fr:"Non déductible" en:"Not deductible" %}
{% t= "Totaal" fr:"Total" en:"Total" %}
{% t= "Divers" fr:"Divers" en:"Miscellaneous" %}
{% t= "titel rubriek" fr:"titre rubrique" en:"title category" %}

{% if cost_categories_string == blank or cost_keys_string == blank %}
  {% assign cost_categories_string = "Personenwagens|Bedrijfswagens|Overige" %}
  {% assign cost_keys_string = "personenwagens|bedrijfswagen|soverige" %}
{% endif %}

{% t= "Personenwagens|Bedrijfswagens|Overige" en:"Vehicles passenger cars|Vehicles company cars|Other" fr:"Voitures|Véhicules d'entreprise|Autres" de:"Vehicles passenger cars|Vehicles company cars|Other" %}
{% capture cost_categories_string %} {% t "Personenwagens|Bedrijfswagens|Overige" %}{% endcapture %}

{% assign cost_categories = cost_categories_string | split:"|" %}
{% assign cost_keys = cost_keys_string | split:"|" %}

{% assign toegewezen = "" %}
{% assign count = 0 %}

{% ic %}*Release 2018-10*{% endic %}

{% capture header %}|-----------64%---------------|---------------12%-----------:|---------------12%-----------:|---------------12%-----------:+{% endcapture %}

{% capture table %}

-----------------------------------------------------------------------------------------------------------

{% stripnewlines %}
{{ header }}
{% newline %}
| **{% t "Detail van de kosten" %}**    
| **{{ period.year_end_date | date:'%Y' }}**
| **{% t "Beroeps-<br />beperking" %}**<br />**({% t "Niet aftrekbaar" %})**
| **{% t "Totale beperking" %}**    
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %}                
{% newline %}
{% for cost_category in cost_categories %}
  {% assign $11 = 0 %}
  {% assign $12 = 0 %}
  {% assign $13 = 0 %}
  {% assign category_key = cost_keys[forloop.index0] %}  
  
  {% ifi costs != blank %}
  {% newline %}
  | {% t cost_category %} {% input custom[category_key].accounts as:account_collection range:6,7 accounts_var:costs %}  | | |
  {% newline %}
  {{ header }}
  {% newline %}
  {% for account in costs %}
    {% assign toegewezen = toegewezen | append: account.number | append:";" %}
    | {{ account.name }}
    | {%=$11+ account.value as:currency %}
    | {% input custom[account.number].vin as:percentage placeholder:'0.00%' %}
        {% if custom[account.number].vin == blank %}
          {% assign vin = 1 %}
        {% else %}
          {% assign vin = 1-custom[account.number].vin placeholder:'' %}
        {% endif %}
        {% $12+ vin*account.value as:currency %}
    | {{ account.value-1*vin*account.value | currency }}
    {% newline %}
  {% endfor %}
  {% capture custfieldname %}vrije_lijnen_{{category_key}}{%endcapture%}
  {% fori vrije_cost_lijnen in custom.[custfieldname] %}
    | {% input vrije_cost_lijnen.omschrijving placeholder:'' %} 
    | {% $31+input vrije_cost_lijnen.value as:currency as:currency placeholder:'' %} {% assign $33 = vrije_cost_lijnen.value %}
    | {% input vrije_cost_lijnen.vin as:percentage placeholder:'0.00%' %}
        {% if vrije_cost_lijnen.vin == blank %}
          {% assign vin = 1 %}
        {% else %}
          {% assign vin = 1-vrije_cost_lijnen.vin placeholder:'' %}
        {% endif %}
        {% $32+ vin*$33 as:currency %} 
    | {{ $33-1*vin*$33 | currency }} 
    {% newline %}
    {% if forloop.last %}
      |     
      | **{% =$21+ $11+$31 as:currency %}** 
      |     
      | **{% =$22+ ($11-$12)+($31-$32) as:currency %}** 
      {% result category_key $34 %}|
  {% assign $31 = 0 %}
  {% assign $32 = 0 %}
  {% newline %}
  {% endif %}
  {% endfori %}
  {% newline %}
  {% endifi %}
{% endfor %}
{% fori vrije_cost in custom.vrije_tekst %}
  {% assign $11 = 0 %}
  {% assign $12 = 0 %}
  {% assign $13 = 0 %}
{% newline %}
  | {% input vrije_cost.titel placeholder:'titel rubriek' %} {% input vrije_cost.accounts as:account_collection range:6,7 accounts_var:vrije_costs %} | | |
  {% newline %}
  {{ header }}
  {% newline %}
  {% for account2 in vrije_costs %}
     |{{ account2.name }}
     |{%=$11+ account2.value as:currency %}
     | {% input custom[account2.number].vin as:percentage placeholder:'0.00%' %}
        {% if custom[account2.number].vin == blank %}
          {% assign vin = 1 %}
        {% else %}
          {% assign vin = 1-custom[account2.number].vin placeholder:'' %}
        {% endif %}
        {% $12+ vin*account2.value as:currency %}
     |{{ account2.value-1*vin*account2.value | currency }}
    {% newline %}
  {% endfor %}
  {% capture custfieldname2 %}vrije_lijnen2_{{vrije_cost.key}}{%endcapture%}
  {% fori vrije_cost_lijnen2 in custom.[custfieldname2] %}
    | {% input vrije_cost_lijnen2.omschrijving placeholder:'' %} {% assign $33 = vrije_cost_lijnen2.value %}
    | {% $31+input vrije_cost_lijnen2.value as:currency as:currency placeholder:'' %} 
    | {% input vrije_cost_lijnen2.vin as:percentage placeholder:'0.00%' %}
        {% if vrije_cost_lijnen2.vin == blank %}
          {% assign vin = 1 %}
        {% else %}
          {% assign vin = 1-vrije_cost_lijnen2.vin placeholder:'' %}
        {% endif %}
        {% $32+ vin*$33 as:currency %} 
    | {{ $33-1*vin*$33 | currency }} 
    {% newline %}
    {% if forloop.last %}
      |     
      | **{% =$21+ $11+$31 as:currency %}** 
      |     
      | **{% =$22+ ($11-$12)+($31-$32) as:currency %}** 
      {% result category_key $34 %}|
      {% assign $31 = 0 %}
      {% assign $32 = 0 %}
      {% newline %}
  {% endif %}
  {% endfori %}
  {% newline %}
{% endfori %}
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %}                
{% newline %}
{% endstripnewlines %}

{{ header }}
| **{% t "Totaal" %}**                  | **{{ $21 | currency }}** |  |  **{{ $22 | currency }}** 

-----------------------------------------------------------------------------------------------------------

{% endcapture %}

{{ table }}

Thanks,

Sylvie

So sorry @svalais, but it seems I gave you the wrong info :pensive:

When you check on a custom object like the accounts_var above, you need to check on empty instead of blank.

So if you change your code to {% ifi costs != empty %} it’ll work.

My apologies @svalais

Can you keep us updated if this works for you?

Sven,

I try your solution but it only work for the first category of cost and not for all the categories.

This is the input in my file:

.

This is the result in the export: Capture1.

Can you have a look?

Thanks,

Sylvie

@svalais,

I’d do it like this (my previous solution only works with a set of fixed (default) ranges (which was the case in the other post, where a default range was used for accounts) :


{% for cost_category in cost_categories %}
  {% assign $11 = 0 %}
  {% assign $12 = 0 %}
  {% assign $13 = 0 %}
  {% assign category_key = cost_keys[forloop.index0] %}  
  
  {% capture custfieldname %}vrije_lijnen_{{category_key}}{%endcapture%}

  
  {% ifi custom[category_key].accounts != blank or custom.[custfieldname] != empty %}
  {% newline %}
  | {% t cost_category %} {% input custom[category_key].accounts as:account_collection range:6,7 accounts_var:costs %}  | | |
  {% newline %}
  {{ header }}
  {% newline %}
  {% for account in costs %}
    {% assign toegewezen = toegewezen | append: account.number | append:";" %}
    | {{ account.name }}
    | {%=$11+ account.value as:currency %}
    | {% input custom[account.number].vin as:percentage placeholder:'0.00%' %}
        {% if custom[account.number].vin == blank %}
          {% assign vin = 1 %}
        {% else %}
          {% assign vin = 1-custom[account.number].vin placeholder:'' %}
        {% endif %}
        {% $12+ vin*account.value as:currency %}
    | {{ account.value-1*vin*account.value | currency }}
    {% newline %}
  {% endfor %}
  
  {% fori vrije_cost_lijnen in custom.[custfieldname] %}
    | {% input vrije_cost_lijnen.omschrijving placeholder:'' %} 
    | {% $31+input vrije_cost_lijnen.value as:currency as:currency placeholder:'' %} {% assign $33 = vrije_cost_lijnen.value %}
    | {% input vrije_cost_lijnen.vin as:percentage placeholder:'0.00%' %}
        {% if vrije_cost_lijnen.vin == blank %}
          {% assign vin = 1 %}
        {% else %}
          {% assign vin = 1-vrije_cost_lijnen.vin placeholder:'' %}
        {% endif %}
        {% $32+ vin*$33 as:currency %} 
    | {{ $33-1*vin*$33 | currency }} 
    {% newline %}
    {% if forloop.last %}
      |     
      | **{% =$21+ $11+$31 as:currency %}** 
      |     
      | **{% =$22+ ($11-$12)+($31-$32) as:currency %}** 
      {% result category_key $34 %}|
  {% assign $31 = 0 %}
  {% assign $32 = 0 %}
  {% newline %}
  {% endif %}
  {% endfori %}
  {% newline %}
  {% endifi %}
{% endfor %}

So, to recap on how the ifi-statement works :

a) I’ll check on the custom object custom[category_key].accounts

This will always have a value (that’s a string by the way), because the user either has to select accounts with the hash-tag OR give in custom descriptions (see b) )

OR

b) I’ll check on custom.[custfieldname] being empty or not

However, that last one is created by a capture :

{% capture custfieldname %}vrije_lijnen_{{category_key}}{%endcapture%}

This capture needs to be added above my ifi-statement, otherwise the object would not be created.

Hope third time’s the charm @svalais ?

Hello,

Thanks my problem is now solved.

Sylvie

Glad we could help you @svalais :+1:

Hallo,

I have an other problem with the export of the same disclosure.

On the screen all my totals for each title and the global total are correct but not in the export.

This is the result on the sreen:

.

This is the result in the export: Capture2.

The total for the 1st title is correct but not for the other titles and the global total is also incorrect.

This is the code:

{% t= "Detail van de kosten" fr:"Détails des frais" en:"Detail of all costs" %}
{% t= "Beroeps-<br />beperking" fr:"Limite professionnelle" en:"Occupational disability" %}
{% t= "Totale beperking" fr:"Limite totale" en:"Total limitation" %}
{% t= "Aftrekbaar" fr:"Déductible" en:"Deductible" %}
{% t= "Niet aftrekbaar" fr:"Non déductible" en:"Not deductible" %}
{% t= "Totaal" fr:"Total" en:"Total" %}
{% t= "Divers" fr:"Divers" en:"Miscellaneous" %}
{% t= "titel rubriek" fr:"titre rubrique" en:"title category" %}

{% if cost_categories_string == blank or cost_keys_string == blank %}
  {% assign cost_categories_string = "Personenwagens|Bedrijfswagens|Overige" %}
  {% assign cost_keys_string = "personenwagens|bedrijfswagen|soverige" %}
{% endif %}

{% t= "Personenwagens|Bedrijfswagens|Overige" en:"Vehicles passenger cars|Vehicles company cars|Other" fr:"Voitures|Véhicules d'entreprise|Autres" de:"Vehicles passenger cars|Vehicles company cars|Other" %}
{% capture cost_categories_string %} {% t "Personenwagens|Bedrijfswagens|Overige" %}{% endcapture %}

{% assign cost_categories = cost_categories_string | split:"|" %}
{% assign cost_keys = cost_keys_string | split:"|" %}

{% assign toegewezen = "" %}
{% assign count = 0 %}

{% ic %}*Release 2018-10*{% endic %}

{% capture header %}|-----------64%---------------|---------------12%-----------:|---------------12%-----------:|---------------12%-----------:+{% endcapture %}

{% capture table %}

-----------------------------------------------------------------------------------------------------------

{% stripnewlines %}
{{ header }}
{% newline %}
| **{% t "Detail van de kosten" %}**    
| **{{ period.year_end_date | date:'%Y' }}**
| **{% t "Beroeps-<br />beperking" %}**<br />**({% t "Niet aftrekbaar" %})**
| **{% t "Totale beperking" %}**    
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %}                
{% newline %}
{% for cost_category in cost_categories %}
  {% assign $11 = 0 %}
  {% assign $12 = 0 %}
  {% assign $13 = 0 %}
  {% assign category_key = cost_keys[forloop.index0] %}  
  {% capture custfieldname %}vrije_lijnen_{{category_key}}{%endcapture%}
  
  {% ifi custom[category_key].accounts != blank or custom.[custfieldname] != empty %}
  {% newline %}
  | {% t cost_category %} {% input custom[category_key].accounts as:account_collection range:6,7 accounts_var:costs %}  | | |
  {% newline %}
  {{ header }}
  {% newline %}
  {% for account in costs %}
    {% assign toegewezen = toegewezen | append: account.number | append:";" %}
    | {{ account.name }}
    | {%=$11+ account.value as:currency %}
    | {% input custom[account.number].vin as:percentage placeholder:'0.00%' %}
        {% if custom[account.number].vin == blank %}
          {% assign vin = 1 %}
        {% else %}
          {% assign vin = 1-custom[account.number].vin placeholder:'' %}
        {% endif %}
        {% $12+ vin*account.value as:currency %}
    | {{ account.value-1*vin*account.value | currency }}
    {% newline %}
  {% endfor %}
  {% fori vrije_cost_lijnen in custom.[custfieldname] %}
    | {% input vrije_cost_lijnen.omschrijving placeholder:'' %} 
    | {% $31+input vrije_cost_lijnen.value as:currency as:currency placeholder:'' %} {% assign $33 = vrije_cost_lijnen.value %}
    | {% input vrije_cost_lijnen.vin as:percentage placeholder:'0.00%' %}
        {% if vrije_cost_lijnen.vin == blank %}
          {% assign vin = 1 %}
        {% else %}
          {% assign vin = 1-vrije_cost_lijnen.vin placeholder:'' %}
        {% endif %}
        {% $32+ vin*$33 as:currency %} 
    | {{ $33-1*vin*$33 | currency }} 
    {% newline %}
    {% if forloop.last %}
      |     
      | 
      |     
      | **{% =$22+ ($11-$12)+($31-$32) as:currency %}** 
      {% result category_key $34 %}|
  {% assign $31 = 0 %}
  {% assign $32 = 0 %}
  {% newline %}
  {% endif %}
  {% endfori %}
  {% newline %}
  {% endifi %}
{% endfor %}
{% fori vrije_cost in custom.vrije_tekst %}
  {% assign $11 = 0 %}
  {% assign $12 = 0 %}
  {% assign $13 = 0 %}
{% newline %}
  | {% input vrije_cost.titel placeholder:'titel rubriek' %} {% input vrije_cost.accounts as:account_collection range:6,7 accounts_var:vrije_costs %} | | |
  {% newline %}
  {{ header }}
  {% newline %}
  {% for account2 in vrije_costs %}
     |{{ account2.name }}
     |{%=$11+ account2.value as:currency %}
     | {% input custom[account2.number].vin as:percentage placeholder:'0.00%' %}
        {% if custom[account2.number].vin == blank %}
          {% assign vin = 1 %}
        {% else %}
          {% assign vin = 1-custom[account2.number].vin placeholder:'' %}
        {% endif %}
        {% $12+ vin*account2.value as:currency %}
     |{{ account2.value-1*vin*account2.value | currency }}
    {% newline %}
  {% endfor %}
  {% capture custfieldname2 %}vrije_lijnen2_{{vrije_cost.key}}{%endcapture%}
  {% fori vrije_cost_lijnen2 in custom.[custfieldname2] %}
    | {% input vrije_cost_lijnen2.omschrijving placeholder:'' %} {% assign $33 = vrije_cost_lijnen2.value %}
    | {% $31+input vrije_cost_lijnen2.value as:currency as:currency placeholder:'' %} 
    | {% input vrije_cost_lijnen2.vin as:percentage placeholder:'0.00%' %}
        {% if vrije_cost_lijnen2.vin == blank %}
          {% assign vin = 1 %}
        {% else %}
          {% assign vin = 1-vrije_cost_lijnen2.vin placeholder:'' %}
        {% endif %}
        {% $32+ vin*$33 as:currency %} 
    | {{ $33-1*vin*$33 | currency }} 
    {% newline %}
    {% if forloop.last %}
      |     
      | 
      |     
      | **{% =$22+ ($11-$12)+($31-$32) as:currency %}** 
      {% result category_key $34 %}|
      {% assign $31 = 0 %}
      {% assign $32 = 0 %}
      {% newline %}
  {% endif %}
  {% endfori %}
  {% newline %}
{% endfori %}
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %}                
{% newline %}
{% endstripnewlines %}

{{ header }}
| **{% t "Totaal" %}**                  |  |  |  **{{ $22 | currency }}** 

-----------------------------------------------------------------------------------------------------------

{% endcapture %}

{{ table }}

Can you have a look please?

Thanks,

Sylvie

Hey @svalais,

Would you mind posting your code between the so called tildes ` ? See here for more info on how exactly to do this; otherwise the post is overfloaded with no so pretty looking code
I’ve done it now for you though; you can edit your post to see how I did it. :slightly_smiling_face:

Back on topic:

This code :


          {% fori vrije_cost_lijnen in custom.[custfieldname] %}
            | {% input vrije_cost_lijnen.omschrijving placeholder:'' %} 
            | {% $31+input vrije_cost_lijnen.value as:currency as:currency placeholder:'' %} {% assign $33 = vrije_cost_lijnen.value %}
            | {% input vrije_cost_lijnen.vin as:percentage placeholder:'0.00%' %}
              {% if vrije_cost_lijnen.vin == blank %}
                {% assign vin = 1 %}
              {% else %}
                {% assign vin = 1-vrije_cost_lijnen.vin placeholder:'' %}
              {% endif %}
            {% $32+ vin*$33 as:currency %} 
            | {{ $33-1*vin*$33 | currency }} 
          {% newline %}
          {% if forloop.last %}
            |     
            | 
            |     
            |  **{% =$22+ ($11-$12)+($31-$32) as:currency %}** 
          {% result category_key $34 %}|

This line **{% =$22+ ($11-$12)+($31-$32) as:currency %}** is the one you want to display in an export, but take a good look: this line is in an if-statement : if forloop.last . So it’s only shown if you are in the last loop of your forloop. And that forloop is this one :

{% fori vrije_cost_lijnen in custom.[custfieldname] %}

And you’d want the last loop of this one :

{% for cost_category in cost_categories %} 

Is this clear enough for you on how to fix it? Let us known if you’re stuck and I’ll add more info to this issue of course (had me looking for quite a bit there :relaxed: )

Hello,

If I change the place of the If forloop.last before the endfor of {% for cost_category in cost_categories %},
my totals on the screen and in the export are not correct anymore.

Can you help me please?

Thanks,

Sylvie

Can you post me the exact code you used @svalais ? I’ll take a look at it

Hi Sven,

This is the code after modification:

{% t= "Detail van de kosten" fr:"Détails des frais" en:"Detail of all costs" %}
{% t= "Beroeps-<br />beperking" fr:"Limite professionnelle" en:"Occupational disability" %}
{% t= "Totale beperking" fr:"Limite totale" en:"Total limitation" %}
{% t= "Aftrekbaar" fr:"Déductible" en:"Deductible" %}
{% t= "Niet aftrekbaar" fr:"Non déductible" en:"Not deductible" %}
{% t= "Totaal" fr:"Total" en:"Total" %}
{% t= "Divers" fr:"Divers" en:"Miscellaneous" %}
{% t= "titel rubriek" fr:"titre rubrique" en:"title category" %}

{% if cost_categories_string == blank or cost_keys_string == blank %}
  {% assign cost_categories_string = "Personenwagens|Bedrijfswagens|Overige" %}
  {% assign cost_keys_string = "personenwagens|bedrijfswagen|soverige" %}
{% endif %}

{% t= "Personenwagens|Bedrijfswagens|Overige" en:"Vehicles passenger cars|Vehicles company cars|Other" fr:"Voitures|Véhicules d'entreprise|Autres" de:"Vehicles passenger cars|Vehicles company cars|Other" %}
{% capture cost_categories_string %} {% t "Personenwagens|Bedrijfswagens|Overige" %}{% endcapture %}

{% assign cost_categories = cost_categories_string | split:"|" %}
{% assign cost_keys = cost_keys_string | split:"|" %}

{% assign toegewezen = "" %}
{% assign count = 0 %}

{% ic %}*Release 2018-10*{% endic %}

{% capture header %}|-----------64%---------------|---------------12%-----------:|---------------12%-----------:|---------------12%-----------:+{% endcapture %}

{% capture table %}

-----------------------------------------------------------------------------------------------------------

{% stripnewlines %}
{{ header }}
{% newline %}
| **{% t "Detail van de kosten" %}**    
| **{{ period.year_end_date | date:'%Y' }}**
| **{% t "Beroeps-<br />beperking" %}**<br />**({% t "Niet aftrekbaar" %})**
| **{% t "Totale beperking" %}**    
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %}                
{% newline %}
{% for cost_category in cost_categories %}
  {% assign $11 = 0 %}
  {% assign $12 = 0 %}
  {% assign $13 = 0 %}
  {% assign category_key = cost_keys[forloop.index0] %}  
  {% capture custfieldname %}vrije_lijnen_{{category_key}}{%endcapture%}
  
  {% ifi custom[category_key].accounts != blank or custom.[custfieldname] != empty %}
  {% newline %}
  | {% t cost_category %} {% input custom[category_key].accounts as:account_collection range:6,7 accounts_var:costs %}  | | |
  {% newline %}
  {{ header }}
  {% newline %}
  {% for account in costs %}
    {% assign toegewezen = toegewezen | append: account.number | append:";" %}
    | {{ account.name }}
    | {%=$11+ account.value as:currency %}
    | {% input custom[account.number].vin as:percentage placeholder:'0.00%' %}
        {% if custom[account.number].vin == blank %}
          {% assign vin = 1 %}
        {% else %}
          {% assign vin = 1-custom[account.number].vin placeholder:'' %}
        {% endif %}
        {% $12+ vin*account.value as:currency %}
    | {{ account.value-1*vin*account.value | currency }}
    {% newline %}
  {% endfor %}
  {% fori vrije_cost_lijnen in custom.[custfieldname] %}
    | {% input vrije_cost_lijnen.omschrijving placeholder:'' %} 
    | {% $31+input vrije_cost_lijnen.value as:currency as:currency placeholder:'' %} {% assign $33 = vrije_cost_lijnen.value %}
    | {% input vrije_cost_lijnen.vin as:percentage placeholder:'0.00%' %}
        {% if vrije_cost_lijnen.vin == blank %}
          {% assign vin = 1 %}
        {% else %}
          {% assign vin = 1-vrije_cost_lijnen.vin placeholder:'' %}
        {% endif %}
        {% $32+ vin*$33 as:currency %} 
    | {{ $33-1*vin*$33 | currency }} 
    {% newline %}
  {% endfori %}
  {% newline %}
  {% endifi %}
  {% if forloop.last %}
      |     
      | 
      |     
      | **{% =$22+ ($11-$12)+($31-$32) as:currency %}** 
      {% result category_key $34 %}|
  {% assign $31 = 0 %}
  {% assign $32 = 0 %}
  {% newline %}
  {% endif %}
{% endfor %}
{% fori vrije_cost in custom.vrije_tekst %}
  {% assign $11 = 0 %}
  {% assign $12 = 0 %}
  {% assign $13 = 0 %}
{% newline %}
  | {% input vrije_cost.titel placeholder:'titel rubriek' %} {% input vrije_cost.accounts as:account_collection range:6,7 accounts_var:vrije_costs %} | | |
  {% newline %}
  {{ header }}
  {% newline %}
  {% for account2 in vrije_costs %}
     |{{ account2.name }}
     |{%=$11+ account2.value as:currency %}
     | {% input custom[account2.number].vin as:percentage placeholder:'0.00%' %}
        {% if custom[account2.number].vin == blank %}
          {% assign vin = 1 %}
        {% else %}
          {% assign vin = 1-custom[account2.number].vin placeholder:'' %}
        {% endif %}
        {% $12+ vin*account2.value as:currency %}
     |{{ account2.value-1*vin*account2.value | currency }}
    {% newline %}
  {% endfor %}
  {% capture custfieldname2 %}vrije_lijnen2_{{vrije_cost.key}}{%endcapture%}
  {% fori vrije_cost_lijnen2 in custom.[custfieldname2] %}
    | {% input vrije_cost_lijnen2.omschrijving placeholder:'' %} {% assign $33 = vrije_cost_lijnen2.value %}
    | {% $31+input vrije_cost_lijnen2.value as:currency as:currency placeholder:'' %} 
    | {% input vrije_cost_lijnen2.vin as:percentage placeholder:'0.00%' %}
        {% if vrije_cost_lijnen2.vin == blank %}
          {% assign vin = 1 %}
        {% else %}
          {% assign vin = 1-vrije_cost_lijnen2.vin placeholder:'' %}
        {% endif %}
        {% $32+ vin*$33 as:currency %} 
    | {{ $33-1*vin*$33 | currency }} 
    {% newline %}
    {% if forloop.last %}
      |     
      | 
      |     
      | **{% =$22+ ($11-$12)+($31-$32) as:currency %}** 
      {% result category_key $34 %}|
      {% assign $31 = 0 %}
      {% assign $32 = 0 %}
      {% newline %}
  {% endif %}
  {% endfori %}
  {% newline %}
{% endfori %}
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %}                
{% newline %}
{% endstripnewlines %}

{{ header }}
| **{% t "Totaal" %}**                  |  |  |  **{{ $22 | currency }}** 

-----------------------------------------------------------------------------------------------------------

{% endcapture %}

{{ table }}

Okay @svalais, it was the if forloop.last after all that’s causing all of this, and actually, you don’t need to use it.

You want the total of every category-loop displayed, right? So you just add that total on the last (new) line of each loop through every category (but still in your original ifi-statement of course) :


{% for cost_category in cost_categories %}
  {% assign $11 = 0 %}
  {% assign $12 = 0 %}
  {% assign $13 = 0 %}
  {% assign category_key = cost_keys[forloop.index0] %}  
  {% capture custfieldname %}vrije_lijnen_{{category_key}}{%endcapture%}
  
  {% ifi custom[category_key].accounts != blank or custom.[custfieldname] != empty %}
  {% newline %}
  | {% t cost_category %} {% input custom[category_key].accounts as:account_collection range:6,7 accounts_var:costs %}  | | |
  {% newline %}
  {{ header }}
  {% newline %}
  {% for account in costs %}
    {% assign toegewezen = toegewezen | append: account.number | append:";" %}
    | {{ account.name }}
    | {%=$11+ account.value as:currency %}
    | {% input custom[account.number].vin as:percentage placeholder:'0.00%' %}
        {% if custom[account.number].vin == blank %}
          {% assign vin = 1 %}
        {% else %}
          {% assign vin = 1-custom[account.number].vin placeholder:'' %}
        {% endif %}
        {% $12+ vin*account.value as:currency %}
    | {{ account.value-1*vin*account.value | currency }}
    {% newline %}
  {% endfor %}
  {% fori vrije_cost_lijnen in custom.[custfieldname] %}
    | {% input vrije_cost_lijnen.omschrijving placeholder:'' %} 
    | {% $31+input vrije_cost_lijnen.value as:currency as:currency placeholder:'' %} {% assign $33 = vrije_cost_lijnen.value %}
    | {% input vrije_cost_lijnen.vin as:percentage placeholder:'0.00%' %}
        {% if vrije_cost_lijnen.vin == blank %}
          {% assign vin = 1 %}
        {% else %}
          {% assign vin = 1-vrije_cost_lijnen.vin placeholder:'' %}
        {% endif %}
        {% $32+ vin*$33 as:currency %} 
    | {{ $33-1*vin*$33 | currency }} 
  {% newline %}
  {% endfori %}
|     
| 
|     
| **{% =$22+ ($11-$12)+($31-$32) as:currency %}** {% result category_key $34 %}
  {% assign $31 = 0 %}
  {% assign $32 = 0 %}  
  {% endifi %}
{% endfor %}

You can do the same thing for the second (custom vrije tekst) loop.

We were too much focused on that if forloop.last thing, but we don’t actually need it, as well it caused (for me anyway) for way too many confusing in combination with the second nested fori-loop.

PS could you post your code like this please?
Because your posted code looked like this :

Not that pretty :see_no_evil:

Hallo,

My problem is solved.

Thanks for the help.

Glad to hear @svalais :+1: