For loop: accounts do not appear

Hey, I adapted one of your templates. However, one of the for-loops (financiële opbrengsten) does not give the desired result: no accounts are shown, neither is the result.

the code is shown below:

{% t= "Rekening. Nr." fr:"Num.Compte" en:"Account number" %}
{% t= "Detail van de kosten" fr:"Les Détails des frais" en:"Detail of all costs" %}
{% t= "Beroeps-<br />beperking" fr:"La limite professionnelle" en:"Occupational disability" %}
{% t= "Fiscale beperking" fr:"La limite fiscale" en:"Fiscal limitation" %}
{% t= "Totale beperking" fr:"La limite totale" en:"Total limitation" %}
{% t= "Aftrekbaar" fr:"Déductible" en:"Deductible" %}
{% t= "aftrekbaar" fr:"déductible" en:"deductible" %}
{% t= "Niet aftrekbaar" fr:"Non déductible" en:"Not deductible" %}
{% t= "Ontvangsten/Baten" fr:"Le chiffre d'affaires" en:"Revenues" %}
{% t= "Werken in uitvoering" fr:"Travaux en cours" en:"Work in progress" %}
{% t= "Voorraadwijziging" fr:"Changement de stock" en:"Afficher le stock initial - le stock final de l'exercice" en:"Show intial - final stock for the financial year" %}
{% t= "Beginvoorraad" fr:"Stock initial" en:"Initial stock" %}
{% t= "Eindvoorraad" fr:"Stock final" en:"Final stock" %}
{% t= "Verkochte voorraad" fr:"Le stock vendu" en:"Stock sold" %}
{% t= "Brutowinst" fr:"Le résultat brut" en:"Gross profit" %}
{% t= "Semibrutowinst" fr:"Le résultat semi-brut" en:"Provisional Gross profit" %}
{% t= "Sociale bijdragen" fr:"Les cotisations sociales" en:"Social contributions" %}
{% t= "Toekenning meewerkende echtgeno(o)t(e)" fr:"L'Octroi époux/-ouse cooperative" en:"Allocation helping spous" %}
{% t= "Kosten" fr:"Les frais" en:"costs" %}
{% t= "Nettoresultaat" fr:"Le résultat net" en:"Net result" %}
{% t= "Niet toegewezen bedrag" fr:"Le montant non affectués" en:"Unassigned amount" %}
{% t= "Alle rekeningen zijn opgenomen" fr:"Tous des comptes sont inclus" en:"All accounts are selected" %}
{% t= "Eén of meerdere rekeningen werden meermaals toegewezen" fr:"Un ou plusieurs comptes ont été attribués plusieurs fois" en:"One or more accounts were selected more than once" %}
{% t= "Niet alle rekeningen zijn opgenomen" fr:"Tous les comptes ne sont pas inclus" en:"Not all accounts are selected" %}
{% t= "Handelsgoederen, grond en hulpstoffen" fr:"Les marchandises, matières premières et matières consommables" en:"Goods for resale, raw materials and additives" %}
{% t= "Verkochte goederen" fr:"Les biens vendus" en:"Sold goods" %}
{% t= "Diensten en diverse goederen" fr:"Services et biens divers " en:"General and administrative expenses" %}
{% t= "Personeelskosten" fr:"Frais de personnel" en:"Staff costs" %}
{% t= "Afschrijvingen, waardeverminderingen en voorzieningen" fr:"Amortissements, réductions de valeur et provisons" en:"Depreciatons and provisions" %}
{% t= "Diverse" fr:"Divers" en:"Miscellaneous" %}
{% t= "Andere bedrijfsopbrengsten" fr:"Autre produits d'exploitation" en:"Other operating income" %}
{% t= "Totaal" fr:"Le Total" en:"Total" %}
{% t= "Financiële kosten" fr:"Charges financiers" en:"Financial costs" %}
{% t= "Financiële opbrengsten" fr:"Produits financiers" en:"Financial income" %}
{% t= "Extra toelichting" fr:"Explication supplémentaire" en:"Additional explanation" %}
{% t= "Nr." fr:"N°" en:"No." %}
{% t= "Bedrag" fr:"Montant" en:"Amount" %}

{% if cost_categories_string == blank %}
  {% assign cost_categories_string = "Diensten en diverse goederen|Personeelskosten|Afschrijvingen, waardeverminderingen en provisies|Diverse|Financiële kosten" %}
  {% assign cost_keys_string = "diensten|personeel|afschrijvingen|diverse|financieel" %}
{% endif %}

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

{% if cost_keys_string != blank %}
  {% assign cost_keys = cost_keys_string | split:"|" %}
{% endif %}

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

{% for cost_category in cost_categories %}
  {% if cost_keys_string != blank %}
    {% assign category_key = cost_keys[forloop.index0] %}
  {% else %}
    {% assign category_key = cost_category | replace:" ","_" | downcase %}
  {% endif %}
  
  {% assign costs_range = custom[category_key].selected | default:custom[category_key].accounts %}
  
  {% assign costs = period.accounts | range:costs_range %}
  {% for account in costs %}
    {% assign toegewezen = toegewezen | append: account.number | append:";" %}
  {% endfor %}
{% endfor %}

{% assign omzet_range = custom.detail.omzet | default:"70" %}
{% assign omzet = period.accounts.include_zeros| range:omzet_range %}
{% for account in omzet %}
  {% assign toegewezen = toegewezen | append:account.number | append:";" %}
{% endfor %}

{% assign WIU_range = custom.detail.WIU | default:"71" %}
{% assign WIU = period.accounts.include_zeros| range:WIU_range %}
{% for account in WIU %}
  {% assign toegewezen = toegewezen | append:account.number | append:";" %}
{% endfor %}

{% assign goederen_range = custom.detail.goederen | default:"600,601,602,603,604,605,606,607,608" %}
{% assign goederen = period.accounts | range:goederen_range %}
{% for account in goederen %}
  {% assign toegewezen = toegewezen | append:account.number | append:";" %}
{% endfor %}

{% assign voorraadwijziging_range = custom.detail.voorraadwijziging | default:"609" %}
{% assign voorraadwijziging= period.accounts.include_zeros| range:voorraadwijziging_range %}
{% for account in voorraadwijziging %}
  {% assign toegewezen = toegewezen | append:account.number | append:";" %}
{% endfor %}

{% assign sociale_bijdrage = period.accounts | range:custom.detail.sociale_bijdrage %}
{% for account in sociale_bijdrage %}
{% assign toegewezen = toegewezen | append:account.number | append:";" %}
{% endfor %}

{% assign andere_bedrijfsopbrengsten = period.accounts | range:custom.detail.andere_bedrijfsopbrengsten | default:"74" %}
{% for account in andere_bedrijfsopbrengsten %}
{% assign toegewezen = toegewezen | append:account.number | append:";" %}
{% endfor %}

{% assign financiële_opbrengsten = period.accounts | range:custom.detail.financiële_opbrengsten | default:"75"%}
{% for account in financiële_opbrengsten %}
{% assign toegewezen = toegewezen | append:account.number | append:";" %}
{% endfor %}


{% assign echtgenote = period.accounts | range:custom.detail.echtgenote %}
{% for account in echtgenote %}
  {% assign toegewezen = toegewezen | append:account.number | append:";" %}
{% endfor %}

{% for extra_kost in custom.extra_kosten %}
  {% assign accounts = period.accounts | range:extra_kost.accounts %}
  {% for account in accounts %}
  {% assign toegewezen = toegewezen | append:account.number | append:";" %}
  {% endfor %}
{% endfor %}

{% for extra_account in custom.extra_accounts %}
  {% assign accounts = period.accounts | range:extra_account.accounts %}
  {% for account in accounts %}
  {% assign toegewezen = toegewezen | append:account.number | append:";" %}
  {% endfor %}
{% endfor %}
  
{% assign global_6_range = "" %}
{% assign accounts = period.accounts | range:'6' %}
{% for account in accounts %}
  {% unless toegewezen contains account.number %}
    {% unless global_6_range == blank %}{% assign global_6_range = global_6_range | append:"," %}{% endunless %}
    {% assign global_6_range = global_6_range | append:account.number %}
  {% endunless%}
{% endfor %}

{% assign global_7_range = "" %}
{% assign accounts = period.accounts | range:'7' %}
{% for account in accounts %}
  {% unless toegewezen contains account.number %}
    {% unless global_7_range == blank %}{% assign global_7_range = global_7_range | append:"," %}{% endunless %}
    {% assign global_7_range = global_7_range | append:account.number %}
  {% endunless%}
{% endfor %}

{% assign global_range = global_6_range | append:"," | append:global_7_range %}


{% capture header %}|--10%-|-----------30%---------------|---------------15%-----------:|---------------15%-----------:|---------------15%-----------:|---------------15%-----------:+{% endcapture %}

{% capture table %}

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

{% stripnewlines %}
{{ header }}
{% newline %}
| **{% t "Rekening. Nr." %}**
| **{% t "Detail van de kosten" %}**    
| **{{ period.year_end_date | date:'%Y' }}**
| **{% t "Beroeps-<br />beperking" %}**<br />**({% t "aftrekbaar" %})**
| **{% t "Fiscale beperking" %}**<br />**({% t "aftrekbaar" %})**
| **{% t "Aftrekbaar" %}**                      
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %}                
{% newline %}
{% for cost_category in cost_categories %}
  {% assign $11 = 0 %}
  {% assign $12 = 0 %}
  {% assign $13 = 0 %}
    {% if cost_keys_string != blank %}
    {% assign category_key = cost_keys[forloop.index0] %}
  {% else %}
    {% assign category_key = cost_category | replace:" ","_" | downcase %}
  {% endif %}
  
  {% assign costs_range = custom[category_key].selected | default:custom[category_key].accounts %}

    {% ifi costs_range != blank %}
{% newline %}
  |   | **{% t cost_category %}** {% input custom[category_key].accounts as:account_collection range:global_range %} |

  
  
  {% assign costs = period.accounts | range:costs_range %}
  
  {% newline %}
  {{ header }}
  {% newline %}
  {% for account in costs %}
    {% assign vin_old = 1-custom[account.number].vin %}
    {% assign beperking_old = 1-custom[account.number].beperking %}
    {% assign vin_new = custom[account.number].vin_new | default:vin_old %}
    {% if vin_new == blank %}
      {% assign vin = 0 %}
    {% else %}
      {% assign vin = vin_new %}
    {% endif %}
    
    {% assign beperking_new = custom[account.number].beperking_new | default:beperking_old %}
    {% if beperking_new == blank %}
      {% assign beperking = 0 %}
    {% else %}
      {% assign beperking = beperking_new %}
    {% endif %}
    
    | {{ account.number}} 
    | {{ account.name }}
    | {%=$11+ -1*account.value as:currency %}
    | {% ifi custom[account.number].vin_new != 100% %}{% input custom[account.number].vin_new as:percentage placeholder:'0.00%' default:vin_old %}{% endifi %}
    | {% ifi custom[account.number].beperking_new != 100% %}{% input custom[account.number].beperking_new as:percentage placeholder:'0.00%' default:beperking_old %}{% endifi %}
    | {{ -1*vin*beperking*account.value | currency }}
      {% $13+ -1*vin*beperking*account.value as:currency %}
    {% newline %}
    {% if forloop.last %}
      |     
      |
      | **{% =$21+ $11 as:currency %}** 
      |
      |
      | **{% =$23+ $13 as:currency %}** {% $1+ $13 as:currency %}
      {% result category_key $13 %}|
    {% newline %}
    {% endif %}
  {% endfor %}
  {% newline %}
    {% endifi %}
{% endfor %}
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %}                
{% newline %}
{% endstripnewlines %}

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

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

{% endcapture %}

{% stripnewlines %}
{% newline %}
|--7%--|--------------------|-------15%-------:|-------15%-------:|-------15%-------:+
{% newline %}
| |{% t "Ontvangsten/Baten" %} {% input custom.detail.omzet as:account_collection range:global_7_range default:'70' %}| | | {%=$10+ -1*omzet.value | currency %}
{% assign omzet = period.accounts | range:omzet_range %}
{% for account in omzet %}
  {% $31+ account.value %}
  {% newline %}
  |{{ account.number }}|{{ account.name }}|{{ -1*account.value | currency }}
{% endfor %}
{% newline %}
| | {% t "Werken in uitvoering" %} {% input custom.detail.WIU as:account_collection range:global_7_range default:'71' %} {% input custom.WIU.doc as:file %}|  || {%=$10+ WIU.value | currency %}{% result 'WIU'+ WIU.value %}
{% for account in WIU %}
  {% $33+ account.value %}
  {% newline %}
  |{{ account.number }}|{{ account.name }}|{{ -1*account.value | currency }}
{% endfor %}
{% assign goederen = period.accounts | range:goederen_range %}
{% ifi goederen.value != 0 %}
{% newline %}
| |{% t "Handelsgoederen, grond en hulpstoffen" %} {% input custom.detail.goederen as:account_collection range:global_6_range default:'60' %}| | |{{ -1*goederen.value | currency }}  
{% for account in goederen %}
  {% $32+ account.value %}
  {% newline %}
  |{{ account.number }}|{{ account.name }}|{{ -1*account.value | currency }}| | 
{% endfor %}
{% newline %}
| | {% t "Voorraadwijziging" %} {% input custom.detail.voorraadwijziging as:account_collection range:global_6_range default:'609' %} {% input custom.voorraadwijziging.doc as:file %}| |  || {%=$14+ voorraadwijziging.value | currency %}{% result 'voorraadwijziging'+ voorraadwijziging.value %}
{% for account in voorraadwijziging %}
  {% $10+ account.value %}
  {% newline %}
  |{{ account.number }}|{{ account.name }}|{{ -1*account.value | currency }}
{% endfor %}
{% newline %}
| | {% t "Verkochte goederen" %}| |||_{%=$10+ (-1*goederen.value+voorraadwijziging) | currency %}_
{% newline %}
| | **{% t "Semi-Brutowinst" %}**        | ||| **{{ $10 | currency }}**{% endifi %}{% ifi custom.detail.sociale_bijdrage != blank %}
{% newline %}
| | {% t "Sociale bijdragen" %} {% input custom.detail.sociale_bijdrage as:account_collection range:global_6_range %} {% input custom.sociale_bijdrage.doc as:file %}| |  || {%=$10+ -1*sociale_bijdrage.value | currency %}{% result 'sociale_bijdrage' -1*sociale_bijdrage.value %}
{% for account in sociale_bijdrage %}
  {% $34+ account.value %}
  {% newline %}
  |{{ account.number }}|{{ account.name }}|{{ -1*account.value | currency }}
{% endfor %}{% endifi %}
  {% newline %}
| |{% t "Andere bedrijfsopbrengsten" %} {% input custom.detail.andere_bedrijfsopbrengsten as:account_collection range:global_7_range default:'74' %}| | | |{%=$10+ -1*andere_bedrijfsopbrengsten.value | currency }{% result 'Andere bedrijfsopbrengsten' -1*andere_bedrijfsopbrengsten.value %}
{% for account in andere_bedrijfsopbrengsten %}
  {% $35+ account.value %}
  {% newline %}  
  |{{ account.number }}|{{ account.name }}|{{ -1*account.value | currency }}| | 
 {% endfor %}
{% newline %}
| |{% t "Financiële opbrengsten" %} {% input custom.detail.financiële_opbrengsten as:account_collection range:global_7_range default:'75' %}| | | |{%=$10+ -1*financiële_opbrengsten.value | currency }{% result 'Financiële opbrengsten'-1*financiële_opbrengsten.value %}
{% for account in financiële_opbrengsten %}
  {% $36+ account.value %}
  {% newline %}  
  |{{ account.number }}|{{ account.name }}|{{ -1*account.value | currency }}| | 
 {% endfor %}
   {% ifi custom.detail.echtgenote != blank %}
  {% newline %}
 | | {% t "Toekenning meewerkende echtgeno(o)t(e)" %} {% input custom.detail.echtgenote as:account_collection range:global_6_range %} {% input custom.echtgenoot.doc as:file %} | | | | {%=$19+ -1*echtgenote.value | currency %}{% result 'echtgenote' -1*echtgenote.value %}
  {% endifi %}
  {% assign bruto_winst = $19 %}
  | {% fori extra_kost in custom.extra_kosten %}
    {% newline %}
   |  |{% input extra_kost.name %} {% input extra_kost.accounts as:account_collection range:global_range %}{% input extra_kost.doc as:file %} | | | |{% assign accounts = period.accounts | range:extra_kost.accounts %}{% if extra_kost.accounts != blank %}{% =$10+ accounts.value*-1 %}{% else %}{% $10+input extra_kost.value as:currency default:-1*accounts.value %}{% endif %}
  {% endfori %}
{% newline %}
|   | {% t "Kosten" %}              | || |_{% =$10+ $1 %}_
{% newline %}
 |  | **{% t "Nettoresultaat" %}**      | | | | **{{ $10 | currency }}**
{% newline %}
  |
  | {% fori extra_account in custom.extra_accounts %}
    {% newline %}
   | |{% input extra_account.name %} {% input extra_account.accounts as:account_collection range:global_range %}{% input extra_account.doc as:file %} | | | |{% assign accounts = period.accounts | range:extra_account.accounts %}{% if extra_account.accounts != blank %}{% =$10+ accounts.value*-1 %}{% else %}{% $10+input extra_account.value as:currency default:-1*accounts.value %}{% endif %}
  {% endfori %}
  |
{% endstripnewlines %}

{% newpage %}

{{ table }}

<!----------------------------------------- check to see if all accounts have been used JUST ONCE ----------------------------------------->

{% assign accounts = period.accounts | range:'6,7' %}
{% assign count_6_7 = accounts.count %}

{% assign count_toegewezen = toegewezen | split:";" %}
{% assign toegewezen_range = count_toegewezen | join:"," %}
{% assign count_toegewezen = count_toegewezen.size %}

{% assign toegewezen_bedrag = period.accounts | range:toegewezen_range %}

{% assign niet_toegewezen = #6+#7-toegewezen_bedrag.value %}

{% ic %}
*{% t "Niet toegewezen bedrag" %} {{ niet_toegewezen | currency }}* {% unexplained niet_toegewezen as:indicator %}

{% if count_6_7 > count_toegewezen %}

{% stripnewlines %}
| *{% t "Nr." %}* | *{% t "Naam" %}* | *{% t "Bedrag" %}*
{% newline %}
|--7%--|----|----:#+
{% newline %}
{% for account in accounts %}
  {% unless toegewezen contains account.number %}
           | *{{ account.number }}* | *{{ account.name }}* | *{%=$30+ account.value | currency %}*
    {% newline %}
      {% if forloop.last %}
      |                      |                      | _*{{ $30 | currency }}*_ 
      {% endif %}
  {% endunless %}
{% endfor %}
{% endstripnewlines %}
{% endif %}

{% endic %}

<!------------------------------------------------------------------------------ END -------------------------------------------------------------------------------->

{% ifi custom.extra.bijlage.document or custom.extra.toelichting != blank %}<br>

{% stripnewlines %}
|------
|------
{% newline %}
| **{% t "Extra toelichting" %}**
| {% input custom.extra.bijlage as:file placeholder:'' %}
{% endstripnewlines %}

{% input custom.extra.toelichting as:text size:mini placeholder:'' %}
{% endifi %}

Hi @fbeirens,

The reason for this, is because you database variable custom.detail.financiële_opbrengsten is actually empty.
This is explained here how to work around it, and why it’s empty:

Now, you could use the solution above (assign the default range into a new variable), but you could use the method accounts_var instead:

{% input custom.detail.financiële_opbrengsten as:account_collection range:global_7_range default:'75' accounts_var:fin_opbrengsten %} 

What this does, is actually fill the accounts_var (which is sort of a custom collection that can gather all accounts of a certain range you select, or a default range) with all the accounts. That accounts_var is called fin_opbrengsten f.i. and you can loop over this collection to display all the selected accounts (whether or not a default range was used or not):

{% for acc in fin_opbrengsten %}
{{ acc.value }} {{ acc.name }}
{% endfor %}

or even display the end-value of that collection with the attribute value: {{ fin_opbrengsten.value }}

I hope this clarifies it for you? If not, (or it does), let us know please!

Dear Sven,

it works fine now. However, after all my adjustments, I get an error message:

Liquid error: undefined method `end_with?’ for [“value”, -0.1e5]:Array

What does it mean?

Could you post your code again @fbeirens? First time I see this error…

{% t= "Rekening. Nr." fr:"Num.Compte" en:"Account number" %}
{% t= "Detail van de kosten" fr:"Les Détails des frais" en:"Detail of all costs" %}
{% t= "Beroeps-<br />beperking" fr:"La limite professionnelle" en:"Occupational disability" %}
{% t= "Fiscale beperking" fr:"La limite fiscale" en:"Fiscal limitation" %}
{% t= "Totale beperking" fr:"La limite totale" en:"Total limitation" %}
{% t= "Aftrekbaar" fr:"Déductible" en:"Deductible" %}
{% t= "aftrekbaar" fr:"déductible" en:"deductible" %}
{% t= "Niet aftrekbaar" fr:"Non déductible" en:"Not deductible" %}
{% t= "Ontvangsten/Baten" fr:"Le chiffre d'affaires" en:"Revenues" %}
{% t= "Werken in uitvoering" fr:"Travaux en cours" en:"Work in progress" %}
{% t= "Voorraadwijziging" fr:"Changement de stock" en:"Afficher le stock initial - le stock final de l'exercice" en:"Show intial - final stock for the financial year" %}
{% t= "Beginvoorraad" fr:"Stock initial" en:"Initial stock" %}
{% t= "Eindvoorraad" fr:"Stock final" en:"Final stock" %}
{% t= "Verkochte voorraad" fr:"Le stock vendu" en:"Stock sold" %}
{% t= "Brutowinst" fr:"Le résultat brut" en:"Gross profit" %}
{% t= "Semibrutowinst" fr:"Le résultat semi-brut" en:"Provisional Gross profit" %}
{% t= "Sociale bijdragen" fr:"Les cotisations sociales" en:"Social contributions" %}
{% t= "Toekenning meewerkende echtgeno(o)t(e)" fr:"L'Octroi époux/-ouse cooperative" en:"Allocation helping spous" %}
{% t= "Kosten" fr:"Les frais" en:"costs" %}
{% t= "Nettoresultaat" fr:"Le résultat net" en:"Net result" %}
{% t= "Niet toegewezen bedrag" fr:"Le montant non affectués" en:"Unassigned amount" %}
{% t= "Alle rekeningen zijn opgenomen" fr:"Tous des comptes sont inclus" en:"All accounts are selected" %}
{% t= "Eén of meerdere rekeningen werden meermaals toegewezen" fr:"Un ou plusieurs comptes ont été attribués plusieurs fois" en:"One or more accounts were selected more than once" %}
{% t= "Niet alle rekeningen zijn opgenomen" fr:"Tous les comptes ne sont pas inclus" en:"Not all accounts are selected" %}
{% t= "Handelsgoederen, grond en hulpstoffen" fr:"Les marchandises, matières premières et matières consommables" en:"Goods for resale, raw materials and additives" %}
{% t= "Verkochte goederen" fr:"Les biens vendus" en:"Sold goods" %}
{% t= "Diensten en diverse goederen" fr:"Services et biens divers " en:"General and administrative expenses" %}
{% t= "Personeelskosten" fr:"Frais de personnel" en:"Staff costs" %}
{% t= "Afschrijvingen, waardeverminderingen en voorzieningen" fr:"Amortissements, réductions de valeur et provisons" en:"Depreciatons and provisions" %}
{% t= "Diverse" fr:"Divers" en:"Miscellaneous" %}
{% t= "Andere bedrijfsopbrengsten" fr:"Autre produits d'exploitation" en:"Other operating income" %}
{% t= "Totaal" fr:"Le Total" en:"Total" %}
{% t= "Financiële kosten" fr:"Charges financiers" en:"Financial costs" %}
{% t= "Financiële opbrengsten" fr:"Produits financiers" en:"Financial income" %}
{% t= "Extra toelichting" fr:"Explication supplémentaire" en:"Additional explanation" %}
{% t= "Nr." fr:"N°" en:"No." %}
{% t= "Bedrag" fr:"Montant" en:"Amount" %}

{% if cost_categories_string == blank %}
  {% assign cost_categories_string = "Diensten en diverse goederen|Personeelskosten|Afschrijvingen, waardeverminderingen en provisies|Diverse|Financiële kosten" %}
  {% assign cost_keys_string = "diensten|personeel|afschrijvingen|diverse|financieel" %}
{% endif %}

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

{% if cost_keys_string != blank %}
  {% assign cost_keys = cost_keys_string | split:"|" %}
{% endif %}

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

{% for cost_category in cost_categories %}
  {% if cost_keys_string != blank %}
    {% assign category_key = cost_keys[forloop.index0] %}
  {% else %}
    {% assign category_key = cost_category | replace:" ","_" | downcase %}
  {% endif %}
  
  {% assign costs_range = custom[category_key].selected | default:custom[category_key].accounts %}
  
  {% assign costs = period.accounts | range:costs_range %}
  {% for account in costs %}
    {% assign toegewezen = toegewezen | append: account.number | append:";" %}
  {% endfor %}
{% endfor %}

{% assign omzet_range = custom.detail.omzet | default:"70" %}
{% assign omzet = period.accounts.include_zeros| range:omzet_range %}
{% for account in omzet %}
  {% assign toegewezen = toegewezen | append:account.number | append:";" %}
{% endfor %}

{% assign WIU_range = custom.detail.WIU | default:"71" %}
{% assign WIU = period.accounts.include_zeros| range:WIU_range %}
{% for account in WIU %}
  {% assign toegewezen = toegewezen | append:account.number | append:";" %}
{% endfor %}

{% assign goederen_range = custom.detail.goederen | default:"600,601,602,603,604,605,606,607,608" %}
{% assign goederen = period.accounts | range:goederen_range %}
{% for account in goederen %}
  {% assign toegewezen = toegewezen | append:account.number | append:";" %}
{% endfor %}

{% assign voorraadwijziging_range = custom.detail.voorraadwijziging | default:"609" %}
{% assign voorraadwijziging= period.accounts.include_zeros| range:voorraadwijziging_range %}
{% for account in voorraadwijziging %}
  {% assign toegewezen = toegewezen | append:account.number | append:";" %}
{% endfor %}

{% assign sociale_bijdrage = period.accounts | range:custom.detail.sociale_bijdrage %}
{% for account in sociale_bijdrage %}
{% assign toegewezen = toegewezen | append:account.number | append:";" %}
{% endfor %}

{% assign andere_bedrijfsopbrengsten = period.accounts | range:custom.detail.andere_bedrijfsopbrengsten | default:"74" %}
{% for account in andere_bedrijfsopbrengsten %}
{% assign toegewezen = toegewezen | append:account.number | append:";" %}
{% endfor %}

{% assign financiële_opbrengsten = period.accounts | range:custom.detail.financiële_opbrengsten | default:"75"%}
{% for account in financiële_opbrengsten %}
{% assign toegewezen = toegewezen | append:account.number | append:";" %}
{% endfor %}


{% assign echtgenote = period.accounts | range:custom.detail.echtgenote %}
{% for account in echtgenote %}
  {% assign toegewezen = toegewezen | append:account.number | append:";" %}
{% endfor %}

{% for extra_kost in custom.extra_kosten %}
  {% assign accounts = period.accounts | range:extra_kost.accounts %}
  {% for account in accounts %}
  {% assign toegewezen = toegewezen | append:account.number | append:";" %}
  {% endfor %}
{% endfor %}

{% for extra_account in custom.extra_accounts %}
  {% assign accounts = period.accounts | range:extra_account.accounts %}
  {% for account in accounts %}
  {% assign toegewezen = toegewezen | append:account.number | append:";" %}
  {% endfor %}
{% endfor %}
  
{% assign global_6_range = "" %}
{% assign accounts = period.accounts | range:'6' %}
{% for account in accounts %}
  {% unless toegewezen contains account.number %}
    {% unless global_6_range == blank %}{% assign global_6_range = global_6_range | append:"," %}{% endunless %}
    {% assign global_6_range = global_6_range | append:account.number %}
  {% endunless%}
{% endfor %}

{% assign global_7_range = "" %}
{% assign accounts = period.accounts | range:'7' %}
{% for account in accounts %}
  {% unless toegewezen contains account.number %}
    {% unless global_7_range == blank %}{% assign global_7_range = global_7_range | append:"," %}{% endunless %}
    {% assign global_7_range = global_7_range | append:account.number %}
  {% endunless%}
{% endfor %}

{% assign global_range = global_6_range | append:"," | append:global_7_range %}


{% capture header %}|--10%-|-----------30%---------------|---------------15%-----------:|---------------15%-----------:|---------------15%-----------:|---------------15%-----------:+{% endcapture %}

{% capture table %}

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

{% stripnewlines %}
{{ header }}
{% newline %}
| **{% t "Rekening. Nr." %}**
| **{% t "Detail van de kosten" %}**    
| **{{ period.year_end_date | date:'%Y' }}**
| **{% t "Beroeps-<br />beperking" %}**<br />**({% t "aftrekbaar" %})**
| **{% t "Fiscale beperking" %}**<br />**({% t "aftrekbaar" %})**
| **{% t "Aftrekbaar" %}**                      
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %}                
{% newline %}
{% for cost_category in cost_categories %}
  {% assign $11 = 0 %}
  {% assign $12 = 0 %}
  {% assign $13 = 0 %}
    {% if cost_keys_string != blank %}
    {% assign category_key = cost_keys[forloop.index0] %}
  {% else %}
    {% assign category_key = cost_category | replace:" ","_" | downcase %}
  {% endif %}
  
  {% assign costs_range = custom[category_key].selected | default:custom[category_key].accounts %}

    {% ifi costs_range != blank %}
{% newline %}
  |   | **{% t cost_category %}** {% input custom[category_key].accounts as:account_collection range:global_range %} |

  
  
  {% assign costs = period.accounts | range:costs_range %}
  
  {% newline %}
  {{ header }}
  {% newline %}
  {% for account in costs %}
    {% assign vin_old = 1-custom[account.number].vin %}
    {% assign beperking_old = 1-custom[account.number].beperking %}
    {% assign vin_new = custom[account.number].vin_new | default:vin_old %}
    {% if vin_new == blank %}
      {% assign vin = 0 %}
    {% else %}
      {% assign vin = vin_new %}
    {% endif %}
    
    {% assign beperking_new = custom[account.number].beperking_new | default:beperking_old %}
    {% if beperking_new == blank %}
      {% assign beperking = 0 %}
    {% else %}
      {% assign beperking = beperking_new %}
    {% endif %}
    
    | {{ account.number}} 
    | {{ account.name }}
    | {%=$11+ -1*account.value as:currency %}
    | {% ifi custom[account.number].vin_new != 100% %}{% input custom[account.number].vin_new as:percentage placeholder:'0.00%' default:vin_old %}{% endifi %}
    | {% ifi custom[account.number].beperking_new != 100% %}{% input custom[account.number].beperking_new as:percentage placeholder:'0.00%' default:beperking_old %}{% endifi %}
    | {{ -1*vin*beperking*account.value | currency }}
      {% $13+ -1*vin*beperking*account.value as:currency %}
    {% newline %}
    {% if forloop.last %}
      |     
      |
      | **{% =$21+ $11 as:currency %}** 
      |
      |
      | **{% =$23+ $13 as:currency %}** {% $1+ $13 as:currency %}
      {% result category_key $13 %}|
    {% newline %}
    {% endif %}
  {% endfor %}
  {% newline %}
    {% endifi %}
{% endfor %}
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %}                
{% newline %}
{% endstripnewlines %}

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

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

{% endcapture %}

{% stripnewlines %}
{% newline %}
|--7%--|--------------------|-------15%-------:|-------15%-------:|-------15%-------:+
{% newline %}
| |{% t "Ontvangsten/Baten" %} {% input custom.detail.omzet as:account_collection range:global_7_range default:'70' %}| |  | {%=$10+ -1*omzet.value | currency %}
{% assign omzet = period.accounts | range:omzet_range %}
{% for account in omzet %}
  {% $31+ account.value %}
  {% newline %}
  |{{ account.number }}|{{ account.name }}|{{ -1*account.value | currency }}
{% endfor %}
{% newline %}
| | {% t "Werken in uitvoering" %} {% input custom.detail.WIU as:account_collection range:global_7_range default:'71' %} {% input custom.WIU.doc as:file %}| |  | {%=$10+ WIU.value | currency %}{% result 'WIU'+ WIU.value %}
{% for account in WIU %}
  {% $33+ account.value %}
  {% newline %}
  |{{ account.number }}|{{ account.name }}|{{ -1*account.value | currency }}
{% endfor %}
{% assign goederen = period.accounts | range:goederen_range %}
{% ifi goederen.value != 0 %}
{% newline %}
| |{% t "Handelsgoederen, grond en hulpstoffen" %} {% input custom.detail.goederen as:account_collection range:global_6_range default:'60' %}|  |{{ -1*goederen.value | currency }}  
{% for account in goederen %}
  {% $32+ account.value %}
  {% newline %}
  |{{ account.number }}|{{ account.name }}|{{ -1*account.value | currency }}| | 
{% endfor %}
{% newline %}
| | {% t "Voorraadwijziging" %} {% input custom.detail.voorraadwijziging as:account_collection range:global_6_range default:'609' %} {% input custom.voorraadwijziging.doc as:file %}|   | {%=$14+ voorraadwijziging.value | currency %}{% result 'voorraadwijziging'+ voorraadwijziging.value %}
{% for account in voorraadwijziging %}
  {% $10+ account.value %}
  {% newline %}
  |{{ account.number }}|{{ account.name }}|{{ -1*account.value | currency }}
{% endfor %}
{% newline %}
| | {% t "Verkochte goederen" %}| ||_{%=$10+ (-1*goederen.value+voorraadwijziging) | currency %}_
{% newline %}
| | **{% t "Semi-Brutowinst" %}**        |  |  | **{{ $10 | currency }}**{% endifi %}{% ifi custom.detail.sociale_bijdrage != blank %}
{% newline %}
| | {% t "Sociale bijdragen" %} {% input custom.detail.sociale_bijdrage as:account_collection range:global_6_range %} {% input custom.sociale_bijdrage.doc as:file %}| |  | {%=$10+ -1*sociale_bijdrage.value | currency %}{% result 'sociale_bijdrage' -1*sociale_bijdrage.value %}
{% for account in sociale_bijdrage %}
  {% $34+ account.value %}
  {% newline %}
  |{{ account.number }}|{{ account.name }}|{{ -1*account.value | currency }}
{% endfor %}{% endifi %}
  {% newline %}
| |{% t "Andere bedrijfsopbrengsten" %} {% input custom.detail.andere_bedrijfsopbrengsten as:account_collection range:global_7_range default:'74' %}|  | |{%=$10+ -1*andere_bedrijfsopbrengsten.value | currency }{% result 'Andere bedrijfsopbrengsten' -1*andere_bedrijfsopbrengsten.value %}
{% for account in andere_bedrijfsopbrengsten %}
  {% $35+ account.value %}
  {% newline %}  
  |{{ account.number }}|{{ account.name }}|{{ -1*account.value | currency }}| | 
 {% endfor %}
{% newline %}
| |{% t "Financiële opbrengsten" %} {% input custom.detail.financiële_opbrengsten as:account_collection range:global_7_range default:'75' accounts_var:fin_opbrengsten %} | | |{%=$10+ -1*fin_opbrengsten.value | currency }{% result 'Financiële opbrengsten'-1*fin_opbrengsten.value %}
{% for account in fin_opbrengsten %}
  {% $36+ account.value %}
  {% newline %}  
  |{{ account.number }}|{{ account.name }}|{{ -1*account.value | currency }}| | 
 {% endfor %}
    {% assign bruto_winst = $19 %}
    | {% fori extra_kost in custom.extra_kosten %}
    {% newline %}
   |  |{% input extra_kost.name %} {% input extra_kost.accounts as:account_collection range:global_range %}{% input extra_kost.doc as:file %} | | |{% assign accounts = period.accounts | range:extra_kost.accounts %}{% if extra_kost.accounts != blank %}{% =$10+ accounts.value*-1 %}{% else %}{% $10+input extra_kost.value as:currency default:-1*accounts.value %}{% endif %}
  {% endfori %}
 {% newline %}
 |  | **{% t "Totale brutowinst" %}**      | | | **{{ $10 | currency }}**
 {% ifi custom.detail.echtgenote != blank %}
  {% newline %}
 | | {% t "Toekenning meewerkende echtgeno(o)t(e)" %} {% input custom.detail.echtgenote as:account_collection range:global_6_range %}  | | | {% if custom.detail.echtgenote.accounts != blank %}{% =$19+ custom.detail.echtgenote.value*-1 %}{% else %}{% $10+input custom.detail.echtgenote.value as:currency default:-1*custom.detail.echtgenote.value %}{% endif %}
  {% endifi %}
{% newline %}
|   | {% t "Kosten" %}              | | |_{% =$10+ $1 %}_
{% newline %}
 |  | **{% t "Nettoresultaat" %}**      | | | **{{ $10 | currency }}**
{% newline %}
  |
  | {% fori extra_account in custom.extra_accounts %}
    {% newline %}
   | |{% input extra_account.name %} {% input extra_account.accounts as:account_collection range:global_range %}{% input extra_account.doc as:file %} | | |{% assign accounts = period.accounts | range:extra_account.accounts %}{% if extra_account.accounts != blank %}{% =$10+ accounts.value*-1 %}{% else %}{% $10+input extra_account.value as:currency default:-1*accounts.value %}{% endif %}
  {% endfori %}
  |
{% endstripnewlines %}

{% newpage %}

{{ table }}

<!----------------------------------------- check to see if all accounts have been used JUST ONCE ----------------------------------------->

{% assign accounts = period.accounts | range:'6,7' %}
{% assign count_6_7 = accounts.count %}

{% assign count_toegewezen = toegewezen | split:";" %}
{% assign toegewezen_range = count_toegewezen | join:"," %}
{% assign count_toegewezen = count_toegewezen.size %}

{% assign toegewezen_bedrag = period.accounts | range:toegewezen_range %}

{% assign niet_toegewezen = #6+#7-toegewezen_bedrag.value %}

{% ic %}
*{% t "Niet toegewezen bedrag" %} {{ niet_toegewezen | currency }}* {% unexplained niet_toegewezen as:indicator %}

{% if count_6_7 > count_toegewezen %}

{% stripnewlines %}
| *{% t "Nr." %}* | *{% t "Naam" %}* | *{% t "Bedrag" %}*
{% newline %}
|--7%--|----|----:#+
{% newline %}
{% for account in accounts %}
  {% unless toegewezen contains account.number %}
           | *{{ account.number }}* | *{{ account.name }}* | *{%=$30+ account.value | currency %}*
    {% newline %}
      {% if forloop.last %}
      |                      |                      | _*{{ $30 | currency }}*_ 
      {% endif %}
  {% endunless %}
{% endfor %}
{% endstripnewlines %}
{% endif %}

{% endic %}

<!------------------------------------------------------------------------------ END -------------------------------------------------------------------------------->

{% ifi custom.extra.bijlage.document or custom.extra.toelichting != blank %}<br>

{% stripnewlines %}
|------
|------
{% newline %}
| **{% t "Extra toelichting" %}**
| {% input custom.extra.bijlage as:file placeholder:'' %}
{% endstripnewlines %}

{% input custom.extra.toelichting as:text size:mini placeholder:'' %}
{% endifi %}

@fbeirens,

I can’t reproduce the liquid error, but I’ve taken a closer look the code and I have a few remarks:

  • we need to check if the selected accounts are chosen or not, so in the end we can display which accounts are not chosen at all
  • you can’t use ë in the name of a database variable of a normal variable.

So I would suggest the following:

{% assign range_fin_opbr = custom.detail.fin_opbrengsten | default:"75" %}
{% assign fin_opbrengsten = period.accounts | range:range_fin_opbr %}
{% for account in fin_opbrengsten %}
{% assign toegewezen = toegewezen | append:account.number | append:";" %}
{% endfor %} 

I’ve added this part (and renamed the ‘ë’ of course): {% assign range_fin_opbr = custom.detail.fin_opbrengsten | default:“75” %}

The value of range_fin_opbr will be default “75” unless you click on the hashtag and manually select the needed accounts (only then the database variable custom.detail.fin_opbrengsten will have a value - if not, we’ll take the default value “75” ! )

{% for account in fin_opbrengsten %}
{% assign toegewezen = toegewezen | append:account.number | append:";" %}
{% endfor %}

This is important to list all selected accounts in every hashtag (if you look at the other hasttags, you’ll see the same logic) so at the very end of our template, we can list not used accounts.

| |{% t “Financiële opbrengsten” %} {% input custom.detail.fin_opbrengsten as:account_collection range:global_7_range %} | | |{%=$10+ -1fin_opbrengsten.value | currency }{% result ‘Financiële opbrengsten’-1fin_opbrengsten.value %}
{% for account in fin_opbrengsten %}
{% $36+ account.value %}
{% newline %}
|{{ account.number }}|{{ account.name }}|{{ -1*account.value | currency }}| |
{% endfor %}

We use not the accounts_var but the variable fin_opbrengsten (which is the same as the accounts_var though).

this should display the values properly.

Could you retry your code?

Sorry for the misunderstanding; so we shouldn’t use accounts_var here at all because we check the accounts everywhere to list an overview of not selected accounts.
So this could all be avoided in your original code if you left the letter ‘ë’ out of the name of any variable.

Hope this is clear to you; if not, let me know.

Dear Sven,
It’s clear, but the error message keeps appearing. I’ve noticed that it happens whenever I manually add an amount in one of the boxes where I can add these:

  • {% ifi custom.detail.echtgenote != blank %} {% newline %} | | {% t "Toekenning meewerkende echtgeno(o)t(e)" %} {% input custom.detail.echtgenote as:account_collection range:global_6_range %} | | | {% if custom.detail.echtgenote.accounts != blank %}{% =$19+ custom.detail.echtgenote.value*-1 %}{% else %}{% $10+input custom.detail.echtgenote.value as:currency default:-1*custom.detail.echtgenote.value %}{% endif %} {% endifi %}
  • | {% fori extra_account in custom.extra_accounts %} {% newline %} | |{% input extra_account.name %} {% input extra_account.accounts as:account_collection range:global_range %}{% input extra_account.doc as:file %} | | |{% assign accounts = period.accounts | range:extra_account.accounts %}{% if extra_account.accounts != blank %}{% =$10+ accounts.value*-1 %}{% else %}{% $10+input extra_account.value as:currency default:-1*accounts.value %}{% endif %} {% endfori %}

Okay @fbeirens,

You’ll need to change your code into this better:

 {% ifi custom.detail.echtgenote_value != 0 or echtgenote.value != 0 %}
  {% newline %}
 | | {% t "Toekenning meewerkende echtgeno(o)t(e)" %} {% input custom.detail.echtgenote as:account_collection range:global_6_range %}  | | | {% $10+input custom.detail.echtgenote_value as:currency default:-1*echtgenote.value %}
  {% endifi %} 

What is changed?

First of all, the database variable custom.detail.echtgenote has only one value, and that’s a string-value with all the selected accounts (if you select any through the hashtag).
you could see this very clearly after you select some accounts, by this code f.i. :

output = {{ custom.detail.echtgenote }}

and you’ll see this 61260$,61020$,61300$ for instance.

We use the value of this particular database variable to create a variable or custom collection with accounts later on.
But you cannot do this: custom.detail.echtgenote.value

The attribute value will only work to a variable or custom collection that is atually “filled” with accounts.

{% $10+input custom.detail.echtgenote_value as:currency default:-1*echtgenote.value %}

I’ve added this, and remove your if-statement as well. What you want here, is an input database variable (called custom.detail.echtgenote_value here) that displays the value of our collection echtgenote
It is that variable or collection that has the accounts in it - therefor, you can add the attribute value to it, as a default: default:-1*echtgenote.value

This should work, but you’ll need to do it for the second part (extra accounts) as well.

Let me know if you’re okay with it.