Export disclosure in style

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: