Export: some lines do not get exported

I adapted the template ‘beroepskosten’ somewhat and in the export, a number of detail lines do not get exported.

this is the code that I added. It looks fine on screen, but disappears when exported:

{% for account in sociale_bijdrage %}
{% $10+ account.value %}
{% newline %}
|      {{ account.name }}|{{ -1*account.value | currency }}
{% endfor %}
{% newline %}

image
image

Hi @fbeirens,

There seems to be nothing wrong with your for-loop which can explain the fact that the detail lines are not included in your export.

Would it be possible to copy the entire code so we can have a more detailled look?

Please make sure you copy-paste your code between block quotes ‘>’ in order to avoid copy-paste errors.

Thank you!

Kind regards,
Robin

Dear Robin,

see below. I used Silverfin’s template for ‘beroepskosten’ and I changed/removed a few things. I still have 2 issues:

  • account numbers regarding ‘sociale bijdrage’ do not appear when exporting
  • Is it possible to exclude accounts with a zero balance from the exports?

The code:


{% 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= "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= "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= "Totaal" fr:"Le Total" en:"Total" %}
{% t= "Financieel resultaat" fr:"Résultat financier" en:"Financial Result" %}
{% 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|Financieel resultaat" %}
  {% 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.include_zeros | 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 goederen_range = custom.detail.goederen | default:"60" %}
{% assign goederen = period.accounts.include_zeros| range:goederen_range %}
{% for account in goederen %}
  {% assign toegewezen = toegewezen | append:account.number | append:";" %}
{% endfor %}

{% comment %} voorraadwijziging {% endcomment %}

{% assign beginvoorraad = period.accounts.include_zeros | range:custom.detail.beginvoorraad %} 
{% for account in beginvoorraad %}
  {% assign def_beginvoorraad = def_beginvoorraad | append:account.number %}
  {% unless forloop.last %}
    {% assign def_beginvoorraad = def_beginvoorraad | append:"," %}
  {% endunless %}
{% endfor %}

{% assign eindvoorraad = period.accounts.include_zeros| range:custom.detail.eindvoorraad %}
{% for account in eindvoorraad %}
  {% assign def_eindvoorraad = def_eindvoorraad  | append: account.number %}
  {% unless forloop.last %}
    {% assign def_eindvoorraad = def_eindvoorraad | append:"," %}
  {% endunless %}
{% endfor %}

{% assign def_voorraadwijziging = def_beginvoorraad  | append:"," | append:def_eindvoorraad %}

{% assign acccounts_begin = period.accounts | range:custom.begin_eind.range %}
{% assign beginvoorraad = custom.voorraad.begin | default:acccounts_begin.value %}

{% assign acccounts_eind = period.minus_1y.accounts | range:custom.begin_eind.range %}
{% assign eindvoorraad = custom.voorraad.eind | default:acccounts_eind.value %}

{% assign voorraadwijziging_range = custom.detail.voorraadwijziging | default:def_voorraadwijziging %}
{% assign voorraadwijziging = period.accounts.include_zeros | range:voorraadwijziging_range %}
{% capture voorraadwijziging_rows %}{% input custom.wijziging.voorraad as:currency default:-1*voorraadwijziging.value %} {% assign wijziging_in_voorraad = custom.wijziging.voorraad | default:-1*voorraadwijziging.value %}{% result 'voorraadwijziging' wijziging_in_voorraad %}
{% for account in voorraadwijziging %}
    {% assign toegewezen = toegewezen | append:account.number | append:";" %}
{% endfor %}
{% endcapture %}

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

{% assign echtgenote = period.accounts.include_zeros| 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.include_zeros | 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.include_zeros | 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.include_zeros | 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.include_zeros | 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.include_zeros | 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 %}
    | {% input custom[account.number].vin_new as:percentage placeholder:'0.00%' default:vin_old %}
    | {% input custom[account.number].beperking_new as:percentage placeholder:'0.00%' default:beperking_old %}
    | {{ -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 %}
{% 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_range default:def_voorraadwijziging %} {% input custom.eindvoorraad.doc as:file %}| | |{{voorraadwijziging_rows}}
{% newline %}
| | {% t "Verkochte goederen" %}| |||_{%=$10+ (-1*goederen.value+wijziging_in_voorraad) | currency %}_
{% newline %}
| | **{% t "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 %}{% endifi %}{% ifi custom.detail.echtgenote != blank %}
{% for account in sociale_bijdrage %}
  {% $10+ account.value %}
  {% newline %}
  |{{ account.number }}|{{ account.name }}|{{ -1*account.value | currency }}
{% endfor %}
 {% 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 %} | | | | {%=$10+ -1*echtgenote.value | currency %}{% result 'echtgenote' -1*echtgenote.value %}
  {% endifi %}
  {% assign bruto_winst = $10 %}

  | {% 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.include_zeros | 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.include_zeros | 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.include_zeros | 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 %}

Hello @fbeirens,

I’ve changed your topic so your code is a little more visible (by using ``` this around your code - just FYI)

Regarding your questions:

  • account numbers regarding ‘sociale bijdrage’ do not appear when exporting

They don’t. The reason why, is because of this ifi-statement around the code of showing the accounts:

{% ifi custom.detail.sociale_bijdrage != blank %} 
list of accounts... 
{% endifi %} 

However, your code of showing the accounts, is in another ifi-statement (not related to sociale bijdrage at all IMO):

{% ifi custom.detail.echtgenote != blank %}
{% for account in sociale_bijdrage %}
  {% $10+ account.value %}
  {% newline %}
  |{{ account.number }}|{{ account.name }}|{{ -1*account.value | currency }}
{% endfor %} 
{% endifi %}

You’ll need to adapt your code and looping over your accounts should be in the original ifi-statement:

{% ifi custom.detail.sociale_bijdrage != blank %}  

which means that this checks whether or not you selected accounts though the hasttag.

  • Is it possible to exclude accounts with a zero balance from the exports?

Yes, you can. Take the accounts from sociale bijdrage for instance:

{% assign sociale_bijdrage = period.accounts.include_zeros| range:custom.detail.sociale_bijdrage %} 

The method include_zeros means a custom collection will be created with all the selected accounts, including the zero-accounts.
If you don’t need them, you can exclude that part:

{% assign sociale_bijdrage = period.accounts | range:custom.detail.sociale_bijdrage %} 

Let me know if this works for you please.

Sven,

it works fine this way. Thanks for the input.