Beroepskosten 2.0 - default accounts with categories

I’m trying to add default accounts to the cost categories in the template beroepskosten 2.0.
I tried to do this by adding an new assign with the account numbers and by adding the ‘default’ in the input custom.some.accounts.
Clearly I’m doing something wrong, 'cause it doesn’t works.
Could anyone help me with it?

  {% assign cost_categories_string = "Lokaalkosten|Bureelkosten|Commissies en erelonen|Verzekeringen|Kosten rollend materieel|Uitbatingskosten|Representatie, onthaal en publciteit|Bijdragen - sociaal statuut|Personeelskost|Afschrijvingen|Andere bedrijfskosten|Financiele kosten" %}
  {% assign cost_keys_string = "Lokaalkosten|Bureelkosten|Commissiesenerelonen|Verzekeringen|Kostenrollendmaterieel|Uitbatingskosten|Representatie|Bijdragen - sociaal statuut|Personeelskost|Afschrijvingen|Anderebedrijfskosten|Financiele kosten" %}
  {% assign cost_default_string = "61111|6124,6164|6132|6135|6116|611900|615||62|63|64|65" %}
{% endif %}

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


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

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

{% capture detailkosten %}

|-------#+385073
|{% nic %}**<font color="ffffff">{% endnic %} **Detail van de kosten** {% nic %}</font>**{% endnic %}


{% stripnewlines %} 
{{ header }}
{% newline %}
|    
|**{{ period.year_end_date | date:'%Y' }}**
| **{% t "Beroeps-<br />beperking" %}**<br />**({% t "Niet aftrekbaar" %})**
| **{% t "Fiscale beperking" %}**<br />**({% t "Niet aftrekbaar" %})**
| **{% t "Totale beperking" %}**    
| **{% t "Aftrekbaar" %}**                      
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %}                
{% newline %}
{% for cost_category in cost_categories %}
  {% assign $11 = 0 %}
  {% assign $12 = 0 %}
  {% assign $13 = 0 %}
  {% assign $14 = 0 %}
  {% assign $15 = 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 default:[cost_default]  accounts_var:costs %} |
  {% newline %}
  {{ header }}
  {% newline %}
  {% for account in costs %}
    {% assign toegewezen = toegewezen | append: account.number | append:";" %}
    | {{ account.name }}
    | {%=$11+ -1*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+ -1*vin*account.value as:currency %}
    | {% input custom[account.number].beperking as:percentage placeholder:'0.00%' %}
      {% if custom[account.number].beperking == blank %}
        {% assign beperking = 1 %}
      {% else %}
        {% assign beperking = 1-custom[account.number].beperking %}
      {% endif %}
      {% $15+ -1*vin*beperking*account.value-(1-vin)*account.value as:currency %}
    | {{ account.value-1*vin*beperking*account.value | currency }}
      {% $13+ -1*vin*beperking*account.value as:currency %}
    | {%=$14+ -1*vin*beperking*account.value as:currency %}
    {% newline %}
    {% if forloop.last %}
      |     
      | **{% =$21+ $11 as:currency %}** 
      | **{% =$22+ $11-$12 as:currency %}** 
      | **{% =$25+ $11-$15 as:currency %}** 
      | **{% =$23+ $11-$13 as:currency %}** 
      | **{% =$1+ $14 as:currency %}**
      {% result category_key $14 %}|
    {% newline %}
    {% endif %}
  {% endfor %}
  {% newline %}
    {% endifi %}
{% endfor %}
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %}                
{% newline %}
{% endstripnewlines %}

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

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

{% endcapture %}


{{ detailkosten }}```

Great case @Cedric!

Okay, here it goes, step by step:

If you do a forloop like this :

{% for cost_category in cost_categories %}
{{ cost_category }} 
{% endfor %}

gives this result :

05

Now, we use the tags from cost_keys however, and the way to link them between cost_categories and cost_keys, is using a [forloop.index0]:

{% for cost_category in cost_categories %}
{{ cost_category }} - {{ cost_keys[forloop.index0] }}
{% endfor %}

gives this result :

17

So, when you go to the first iteration of loops around your object cost_categories, you’ll also will go to the first iteration of loops of the object cost_keys.
If it’s your second iteration of loops of cost_categories, you’ll do the same for cost_keys, and so on… That’s the way to link between 2 different objects like cost_categories and cost_keys.

We can do the same now for our default-string we want to use to get the default account range:

{{ cost_default[forloop.index0] }}

So, if you add this in the forloop that generates every type of cost ( {% for cost_category in cost_categories %} ) :

{% assign category_default = cost_default[forloop.index0] %}

then you can use that category_default variable as your default account range :

{% input custom[category_key].accounts as:account_collection range:6,7 default:category_default  accounts_var:costs %}

Can you try to have a spin on this @Cedric? Great case to expand the template of “beroepskosten” :ok_hand:

@sven,

Thanks for the explanation, it makes it very clear.
I’ve added the forloop.index and it works perfectly. However, if I add this template and take an export immediately without changing anything, the accounts aren’t printed. Do I have to confirm in every category the account collection before this is printed in an export?

Just the accounts are not printed @Cedric, or the complete template?

If it’s the latter: be sure to fill in “virtual account number” on office level.

If it’s not that, better to paste the whole code here.

The accounts from the different categories aren’t printed. The ‘virtual account number’ is filled is. :wink:

After I went to the account collection en changed anything the account are printed, but I have to do this of every category before they are printed.

  {% assign cost_categories_string = "Lokaalkosten|Bureelkosten|Commissies en erelonen|Verzekeringen|Kosten rollend materieel|Uitbatingskosten|Representatie, onthaal en publciteit|Bijdragen - sociaal statuut|Personeelskost|Afschrijvingen|Andere bedrijfskosten|Financiele kosten" %}
  {% assign cost_keys_string = "Lokaalkosten|Bureelkosten|Commissiesenerelonen|Verzekeringen|Kostenrollendmaterieel|Uitbatingskosten|Representatie|Bijdragen - sociaal statuut|Personeelskost|Afschrijvingen|Anderebedrijfskosten|Financiele kosten" %}
  {% assign cost_default_string = "'611100,611110,612110,612120,612130,612140,611300,611310,611311,611312'|'616100,616200,616300,616400,616500,616600,616700,611130,611330,611331,612300,612310,612320,612400,612420'|'61310,61311,61312,613200,613210,613220,613230,613240,613250,613260,613270,613280,613290'|6135|6116|'610000,6101,6102,6103,6104,6105,6106,6107,6108,613100,611120,611190,611191,611192,611193,611194,611195,611320,611321,611322,611323,611324,611325,611326,611900,611910,611920,611930,611990,612139,612150,612210,612211,612215,612220,612225,612230,612235,612245,612246,612250,612410,612500,612510,612520,612530,612700,612720,612721,612750,613300,613305,613310,613315,613320,613325,613330,613335,613351,613352,613353,613354,613355,613356,613360,613365,613370,613375,61338,61339,6134,6136,6141,6142'|615||62|63|64|65" %}
{% endif %}

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


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

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

{% capture detailkosten %}

|-------#+385073
|{% nic %}**<font color="ffffff">{% endnic %} Detail van de kosten {% nic %}</font>**{% endnic %}


{% stripnewlines %} 
{{ header }}
{% newline %}
|    
| **{{ period.year_end_date | date:'%Y' }}**
| **{% t "Beroeps-<br />beperking" %}**<br />**({% t "Niet aftrekbaar" %})**
| **{% t "Fiscale beperking" %}**<br />**({% t "Niet aftrekbaar" %})**
| **{% t "Totale beperking" %}**    
| **{% t "Aftrekbaar" %}**                      
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %}                
{% newline %}
{% for cost_category in cost_categories %}
  {% assign $11 = 0 %}
  {% assign $12 = 0 %}
  {% assign $13 = 0 %}
  {% assign $14 = 0 %}
  {% assign $15 = 0 %}
  {% assign category_key = cost_keys[forloop.index0] %}  
  {% assign category_default = cost_default[forloop.index0] %}
  
    {% ifi custom[category_key].accounts != blank %}
{% newline %}
    {% newline %}
  {{ header }}
  {% newline %}
  | **{% t cost_category %}** {% input custom[category_key].accounts as:account_collection range:6,7 default:category_default accounts_var:costs %} |||||
  {% newline %}
  {% for account in costs %}
    {% assign toegewezen = toegewezen | append: account.number | append:";" %}
    | {{ account.name }}
    | {%=$11+ -1*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+ -1*vin*account.value as:currency %}
    | {% input custom[account.number].beperking as:percentage placeholder:'0.00%' %}
      {% if custom[account.number].beperking == blank %}
        {% assign beperking = 1 %}
      {% else %}
        {% assign beperking = 1-custom[account.number].beperking %}
      {% endif %}
      {% $15+ -1*vin*beperking*account.value-(1-vin)*account.value as:currency %}
    | {{ account.value-1*vin*beperking*account.value | currency }}
      {% $13+ -1*vin*beperking*account.value as:currency %}
    | {%=$14+ -1*vin*beperking*account.value as:currency %}
    {% newline %}
    {% if forloop.last %}
      |     
      | **{% =$21+ $11 as:currency %}** 
      | **{% =$22+ $11-$12 as:currency %}** 
      | **{% =$25+ $11-$15 as:currency %}** 
      | **{% =$23+ $11-$13 as:currency %}** 
      | **{% =$1+ $14 as:currency %}**
      {% result category_key $14 %}|
    {% newline %}
    {% endif %}
  {% endfor %}
  {% newline %}
    {% endifi %}
{% endfor %}
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %}                
{% newline %}
{% endstripnewlines %}

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

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

{% endcapture %}



{% capture detailanderebo %}

|-------#+385073
|{% nic %}**<font color="ffffff">{% endnic %} Detail van de andere opbrengsten {% nic %}</font>**{% endnic %}

{% stripnewlines %}
{{ header }}
{% newline %}
|    
|**{{ period.year_end_date | date:'%Y' }}**
| **{% t "Beroeps-<br />beperking" %}**
| **{% t "Fiscale beperking" %}**
| **{% t "Totale beperking" %}**    
| **{% t "Belast" %}**                      
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %} 
{% newline %}

{% newline %}
{{ header }}
{% newline %}
| **Andere bedrijfsopbrengsen** {% input custom.anderebo.accounts as:account_collection range:74 default:74 accounts_var:anderebo %}|||||
{% newline %}
  {% for account in anderebo %}
    {% assign toegewezen = toegewezen | append: account.number | append:";" %}
    | {{ account.name }}
    | {%=$31+ account.value*-1 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 %}
        {% $32+ -1*vin*account.value as:currency %}
    | {% input custom[account.number].beperking as:percentage placeholder:'0.00%' %}
      {% if custom[account.number].beperking == blank %}
        {% assign beperking = 1 %}
      {% else %}
        {% assign beperking = 1-custom[account.number].beperking %}
      {% endif %}
      {% $35+ -1*vin*beperking*account.value-(1-vin)*account.value as:currency %}
    | {{ account.value-1*vin*beperking*account.value | currency }}
      {% $33+ -1*vin*beperking*account.value as:currency %}
    | {%=$34+ -1*vin*beperking*account.value as:currency %}
    {% newline %}
  {% endfor %}
  {% newline %}
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %}                
{% newline %}
{% endstripnewlines %}

{{ header }}
| **{% t "Totaal" %}**                  | **{{ $31 | currency }}** |  |  | | **{{ $34 | currency }}**

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



{% endcapture %}





{% capture detailmeerminderwaarde %}


|-------#+385073
|{% nic %}**<font color="ffffff">{% endnic %} Detail van de meer- en minderwaarden {% nic %}</font>**{% endnic %}

{% stripnewlines %}
{{ header }}
{% newline %}
|    
|**{{ period.year_end_date | date:'%Y' }}**
| **{% t "Beroeps-<br />beperking" %}**
| **{% t "Fiscale beperking" %}**
| **{% t "Totale beperking" %}**    
| **{% t "Belast" %}**                      
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %} 
{% newline %}

  
{% newline %}{% ifi custom.meerwaarde.accounts != blank %}
{{ header }}
{% newline %}
| **Meerwaarde**{% input custom.meerwaarde.accounts as:account_collection range:76 default:76 accounts_var:meerwaarde %}|||||
{% newline %}
  {% for meer in meerwaarde %}
    {% assign toegewezen = toegewezen | append: account.number | append:";" %}
    | {{ meer.name }}
    | {%=$2+ -1*meer.value | currency %}
    | {% input custom[meer.number].vin as:percentage placeholder:'0.00%' %}
        {% if custom[meer.number].vin == blank %}
          {% assign vin = 1 %}
        {% else %}
          {% assign vin = 1-custom[meer.number].vin placeholder:'' %}
        {% endif %}
        {% $3+ -1*vin*meer.value as:currency %}
    | {% input custom[meer.number].beperking as:percentage placeholder:'0.00%' %}
      {% if custom[meer.number].beperking == blank %}
        {% assign beperking = 1 %}
      {% else %}
        {% assign beperking = 1-custom[meer.number].beperking %}
      {% endif %}
      {% $5+ -1*vin*beperking*meer.value-(1-vin)*meer.value as:currency %}
    | {{ meer.value-1*vin*beperking*meer.value | currency }}
      {% $6+ -1*vin*beperking*meer.value as:currency %}
    | {%=$4+ -1*vin*beperking*meer.value as:currency %}
    {% newline %}
  {% endfor %}
  {% newline %}
{% newline %}{% endifi %}


{% newline %}{% ifi custom.minderwaarde.accounts != blank %}
{{ header }}
{% newline %}
| **Minderwaarde**{% input custom.minderwaarde.accounts as:account_collection range:66 default:66 accounts_var:minderwaarde %}|
{% newline %}
  {% for account in minderwaarde %}
    {% assign toegewezen = toegewezen | append: account.number | append:";" %}
    | {{ account.name }}
    | {%=$2+ -1*account.value | 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 %}
        {% $3+ -1*vin*account.value as:currency %}
    | {% input custom[account.number].beperking as:percentage placeholder:'0.00%' %}
      {% if custom[account.number].beperking == blank %}
        {% assign beperking = 1 %}
      {% else %}
        {% assign beperking = 1-custom[account.number].beperking %}
      {% endif %}
      {% $5+ -1*vin*beperking*account.value-(1-vin)*account.value as:currency %}
    | {{ account.value-1*vin*beperking*account.value | currency }}
      {% $6+ -1*vin*beperking*account.value as:currency %}
    | {%=$4+ -1*vin*beperking*account.value as:currency %}
    {% newline %}
  {% endfor %}
  {% newline %}{% endifi %}
  
  
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %}                
{% newline %}
{% endstripnewlines %}

{{ header }}
| **{% t "Totaal" %}**                  | **{{ $2 | currency }}** |  |  | | **{{ $4 | currency }}**

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


{% endcapture %}






{% if custom.detail.goederen == blank %}{% assign goederen_range = '60'%}{% else %}{% assign goederen_range = custom.detail.goederen %}{% endif %}
{% assign goederen = period.accounts | range:goederen_range %}

{% stripnewlines %}
{% newline %}
|---------------------|-------15%-------:|-------15%-------:|-------15%-------:+
{% newline %}
| {% t "Ontvangsten/Baten" %} {% input custom.detail.omzet as:account_collection range:7 default:'70' accounts_var:omzet %}| | | {%=$10+ -1*omzet.value | currency %}
  {% for account in omzet %}
  {% assign toegewezen = toegewezen | append: account.number | append:";" %}{% $31+ account.value %}
  {% newline %}
  | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{ account.name }}|{{ -1*account.value | currency }}
  {% endfor %}
{% ifi goederen.value != 0 %}
{% newline %}
| {% t "Handelsgoederen, grond en hulpstoffen" %} {% input custom.detail.goederen as:account_collection range:6 default:'60' %}| |{{ -1*goederen.value | currency }}
  {% for account in goederen %}
  {% assign toegewezen = toegewezen | append: account.number | append:";" %}{% $32+ account.value %}
    {% newline %}
    | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{ account.name }}|{{ -1*account.value | currency }}
  {% endfor %}
{% newline %}
| {% t "Beginvoorraad" %} {% input custom.detail.beginvoorraad as:account_collection range:6,7 accounts_var:beginvoorraad %} {% input custom.beginvoorraad.doc as:file %}| | {{ -1*beginvoorraad.value | currency}}{% result 'beginvoorraad' -1*beginvoorraad.value %}
  {% for account in beginvoorraad %}
    {% assign toegewezen = toegewezen | append: account.number | append:";" %}{% $33+ account.value %}
  {% endfor %}
{% newline %}
| {% t "Eindvoorraad" %} {% input custom.detail.eindvoorraad as:account_collection range:6,7 accounts_var:eindvoorraad %} {% input custom.eindvoorraad.doc as:file %}| |_{{ -1*eindvoorraad.value | currency}}_ {% result 'eindvoorraad' -1*eindvoorraad.value %} 
  {% for account in eindvoorraad %}
    {% assign toegewezen = toegewezen | append: account.number | append:";" %}{% $34+ account.value %}
  {% endfor %}
{% newline %}
| {% t "Verkochte goederen" %}|||_{%=$10+ -1*(beginvoorraad.value+goederen.value+eindvoorraad.value) | currency %}_ 
{% newline %}
| {% t "Brutowinst / Baten" %}        ||| **{{ $10 | currency }}**{% endifi %}
{% newline %}
| {% t "Andere bedrijfsopbrengsten" %}              | | |_{% =$10+ $34 %}_
{% newline %}
| {% t "Brutowinst / Baten na andere bedrijfsopbrengsten" %}        ||| **{{ $10 | currency }}**{% ifi custom.detail.achterstallen != blank %}
{% newline %}
| {% t "Achterstallige erelonen " %} {% input custom.detail.achterstallen as:account_collection range:7 accounts_var:achterstallen %}| | | {%=$10+ -1*achterstallen.value | currency %} {% endifi %} {% ifi custom.detail.sociale_bijdrage != blank %}
  {% for account in achterstallen %}
  {% assign toegewezen = toegewezen | append: account.number | append:";" %}{% $31+ account.value %}
  {% newline %}
  | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{ account.name }}|{{ -1*account.value | currency }}
  {% endfor %}
{% newline %}
| {% t "Sociale bijdragen" %} {% input custom.detail.sociale_bijdrage as:account_collection range:6 accounts_var:sociale_bijdrage %} {% input custom.sociale_bijdrage.doc as:file %}| | | {%=$10+ -1*sociale_bijdrage.value | currency %}{% endifi %}{% result 'sociale_bijdrage' -1*sociale_bijdrage.value %}{% ifi custom.detail.echtgenote != blank %}
{% for account in sociale_bijdrage %}
{% assign toegewezen = toegewezen | append: account.number | append:";" %}{% $35+ account.value %}
    {% newline %}
    | {{ account.name }}|{{ account.value | currency }}
{% endfor %}
{% newline %}
  | {% t "Toekenning meewerkende echtgeno(o)t(e)" %} {% input custom.detail.echtgenote as:account_collection range:6 accounts_var:echtgenote %} {% input custom.echtgenoot.doc as:file %} | | | {%=$10+ -1*echtgenote.value | currency %}{% endifi %}{% result 'echtgenote' -1*echtgenote.value %}
  {% for account in echtgenote %}
    {% assign toegewezen = toegewezen | append: account.number | append:";" %}{% $36+ account.value %}
  {% endfor %}
  {% assign bruto_winst = $10 %}
{% 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:6,7 %}{% input extra_account.doc as:file %} | | |{% assign accounts = period.accounts | range:extra_account.accounts %}{%=$20+ -1*accounts.value | currency %}
  {% endfori %}
  |
{% endstripnewlines %}

{% newpage %}
{% ifi custom.anderebo.accounts != blank %}
{{ detailanderebo }}
<br>{% endifi %}
{{ detailkosten }}{% ifi #66+#76 != 0 %}
<br>
{{ detailmeerminderwaarde }}{% endifi %}```

@Cedric,

It’s this statement that decides whether or not the export will display the accounts.

Your ifi-statement is looking at the object custom.anderebo.accounts but that object will be empty by default, even if you use a default-account range!
That object will not be empty or blank, when you actually press the button # and drag some accounts in it.

It’s a very wierd thing to work with an input-tag and a default-value to it. You can clearly see the behaviour, if you do this :

{{ custom.anderebo.accounts }}

It won’t show anything.
However, if you press the # and drag an account in it, you’ll see what happens: the object now does have a value.

Why? An input-object will only have actual data in the object, only if you actualle put in data in there.
The default-value added to it, is only some sort of a layer over the object (to show in input and export mode), but it doesn’t actually input the value in the object.

I’ll admit, strange in the beginning but I have explicitly documented this in the slides of the workshops.

To get back to a solution:

You have a collection that stores all the accounts, so why not do a check on the collection anderebo?

For instance :

{% ifi anderebo != empty %}
{{ detailanderebo }}
<br>{% endifi %}

or

{% ifi anderebo.value != 0 %}
{{ detailanderebo }}
<br>{% endifi %}

Could you give it a go ?

Nice looking template by the way :+1:

The part of anderebo is working perfectly.

Problem I have is with following part. I changed the ‘ifi’ like you said above here into:

{% ifi custom[category_key].value != 0 %}

But this still isn’t printed in export mode. I’m shure there’s a simple solution for it, I just can’t find it. :slight_smile:


|-------#+385073
|{% nic %}**<font color="ffffff">{% endnic %} Detail van de kosten {% nic %}</font>**{% endnic %}


{% stripnewlines %} 
{{ header }}
{% newline %}
|    
| **{{ period.year_end_date | date:'%Y' }}**
| **{% t "Beroeps-<br />beperking" %}**<br />**({% t "Niet aftrekbaar" %})**
| **{% t "Fiscale beperking" %}**<br />**({% t "Niet aftrekbaar" %})**
| **{% t "Totale beperking" %}**    
| **{% t "Aftrekbaar" %}**                      
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %}                
{% newline %}
{% for cost_category in cost_categories %}
  {% assign $11 = 0 %}
  {% assign $12 = 0 %}
  {% assign $13 = 0 %}
  {% assign $14 = 0 %}
  {% assign $15 = 0 %}
  {% assign category_key = cost_keys[forloop.index0] %}  
  {% assign category_default = cost_default[forloop.index0] %}
  
    {% ifi custom[category_key].value != 0 %}
{% newline %}
    {% newline %}
  {{ header }}
  {% newline %}
  | **{% t cost_category %}** {% input custom[category_key].accounts as:account_collection range:6,7 default:category_default accounts_var:costs %} |||||
  {% newline %}
  {% for account in costs %}
    {% assign toegewezen = toegewezen | append: account.number | append:";" %}
    | {{ account.name }}
    | {%=$11+ -1*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+ -1*vin*account.value as:currency %}
    | {% input custom[account.number].beperking as:percentage placeholder:'0.00%' %}
      {% if custom[account.number].beperking == blank %}
        {% assign beperking = 1 %}
      {% else %}
        {% assign beperking = 1-custom[account.number].beperking %}
      {% endif %}
      {% $15+ -1*vin*beperking*account.value-(1-vin)*account.value as:currency %}
    | {{ account.value-1*vin*beperking*account.value | currency }}
      {% $13+ -1*vin*beperking*account.value as:currency %}
    | {%=$14+ -1*vin*beperking*account.value as:currency %}
    {% newline %}
    {% if forloop.last %}
      |     
      | **{% =$21+ $11 as:currency %}** 
      | **{% =$22+ $11-$12 as:currency %}** 
      | **{% =$25+ $11-$15 as:currency %}** 
      | **{% =$23+ $11-$13 as:currency %}** 
      | **{% =$1+ $14 as:currency %}**
      {% result category_key $14 %}|
    {% newline %}
    {% endif %}
  {% endfor %}
  {% newline %}
    {% endifi %}
{% endfor %}
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %}                
{% newline %}
{% endstripnewlines %}

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

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

{% endcapture %}```

Okay, let’s check it out.

But I need the complete code (the code you paste, isn’t complete and I want to be sure).

no need to paste a selection of your code (unless you are sure that the code that generates an error of course, but I won’t be able to test it completely)

Hereby the complete code.

There are still some mistakes with the code all the way at the bottom with the ‘nog niet toegewezen’ part, but I didn’t have the time yet to check it myself.

{% if cost_categories_string == blank or cost_keys_string == blank %}
  {% assign cost_categories_string = "Lokaalkosten|Bureelkosten|Commissies en erelonen|Verzekeringen|Kosten rollend materieel|Uitbatingskosten|Representatie, onthaal en publciteit|Bijdragen - sociaal statuut|Personeelskost|Afschrijvingen|Andere bedrijfskosten|Financiele kosten" %}
  {% assign cost_keys_string = "Lokaalkosten|Bureelkosten|Commissiesenerelonen|Verzekeringen|Kostenrollendmaterieel|Uitbatingskosten|Representatie|Bijdragen - sociaal statuut|Personeelskost|Afschrijvingen|Anderebedrijfskosten|Financiele kosten" %}
  {% assign cost_default_string = "'611100,611110,612110,612120,612130,612140,611300,611310,611311,611312'|'616100,616200,616300,616400,616500,616600,616700,611130,611330,611331,612300,612310,612320,612400,612420'|'61310,61311,61312,613200,613210,613220,613230,613240,613250,613260,613270,613280,613290'|6135|6116|'610000,6101,6102,6103,6104,6105,6106,6107,6108,613100,611120,611190,611191,611192,611193,611194,611195,611320,611321,611322,611323,611324,611325,611326,611900,611910,611920,611930,611990,612139,612150,612210,612211,612215,612220,612225,612230,612235,612245,612246,612250,612410,612500,612510,612520,612530,612700,612720,612721,612750,613300,613305,613310,613315,613320,613325,613330,613335,613351,613352,613353,613354,613355,613356,613360,613365,613370,613375,61338,61339,6134,6136,6141,6142'|615||62|63|64|65" %}
{% endif %}

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


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

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

{% capture detailkosten %}

|-------#+385073
|{% nic %}**<font color="ffffff">{% endnic %} Detail van de kosten {% nic %}</font>**{% endnic %}


{% stripnewlines %} 
{{ header }}
{% newline %}
|    
| **{{ period.year_end_date | date:'%Y' }}**
| **{% t "Beroeps-<br />beperking" %}**<br />**({% t "Niet aftrekbaar" %})**
| **{% t "Fiscale beperking" %}**<br />**({% t "Niet aftrekbaar" %})**
| **{% t "Totale beperking" %}**    
| **{% t "Aftrekbaar" %}**                      
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %}                
{% newline %}
{% for cost_category in cost_categories %}
  {% assign $11 = 0 %}
  {% assign $12 = 0 %}
  {% assign $13 = 0 %}
  {% assign $14 = 0 %}
  {% assign $15 = 0 %}
  {% assign category_key = cost_keys[forloop.index0] %}  
  {% assign category_default = cost_default[forloop.index0] %}
  
    {% ifi custom[category_key].value != 0 %}
{% newline %}
    {% newline %}
  {{ header }}
  {% newline %}
  | **{% t cost_category %}** {% input custom[category_key].accounts as:account_collection range:6,7 default:category_default accounts_var:costs %} |||||
  {% newline %}
  {% for account in costs %}
    {% assign toegewezen = toegewezen | append: account.number | append:";" %}
    | {{ account.name }}
    | {%=$11+ -1*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+ -1*vin*account.value as:currency %}
    | {% input custom[account.number].beperking as:percentage placeholder:'0.00%' %}
      {% if custom[account.number].beperking == blank %}
        {% assign beperking = 1 %}
      {% else %}
        {% assign beperking = 1-custom[account.number].beperking %}
      {% endif %}
      {% $15+ -1*vin*beperking*account.value-(1-vin)*account.value as:currency %}
    | {{ account.value-1*vin*beperking*account.value | currency }}
      {% $13+ -1*vin*beperking*account.value as:currency %}
    | {%=$14+ -1*vin*beperking*account.value as:currency %}
    {% newline %}
    {% if forloop.last %}
      |     
      | **{% =$21+ $11 as:currency %}** 
      | **{% =$22+ $11-$12 as:currency %}** 
      | **{% =$25+ $11-$15 as:currency %}** 
      | **{% =$23+ $11-$13 as:currency %}** 
      | **{% =$1+ $14 as:currency %}**
      {% result category_key $14 %}|
    {% newline %}
    {% endif %}
  {% endfor %}
  {% newline %}
    {% endifi %}
{% endfor %}
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %}                
{% newline %}
{% endstripnewlines %}

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

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

{% endcapture %}



{% capture detailanderebo %}

|-------#+385073
|{% nic %}**<font color="ffffff">{% endnic %} Detail van de andere opbrengsten {% nic %}</font>**{% endnic %}

{% stripnewlines %}
{{ header }}
{% newline %}
|    
|**{{ period.year_end_date | date:'%Y' }}**
| **{% t "Beroeps-<br />beperking" %}**
| **{% t "Fiscale beperking" %}**
| **{% t "Totale beperking" %}**    
| **{% t "Belast" %}**                      
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %} 
{% newline %}

{% newline %}
{{ header }}
{% newline %}
| **Andere bedrijfsopbrengsen** {% input custom.anderebo.accounts as:account_collection range:74 default:74 accounts_var:anderebo %}|||||
{% newline %}
  {% for account in anderebo %}
    {% assign toegewezen = toegewezen | append: account.number | append:";" %}
    | {{ account.name }}
    | {%=$31+ account.value*-1 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 %}
        {% $32+ -1*vin*account.value as:currency %}
    | {% input custom[account.number].beperking as:percentage placeholder:'0.00%' %}
      {% if custom[account.number].beperking == blank %}
        {% assign beperking = 1 %}
      {% else %}
        {% assign beperking = 1-custom[account.number].beperking %}
      {% endif %}
      {% $35+ -1*vin*beperking*account.value-(1-vin)*account.value as:currency %}
    | {{ account.value-1*vin*beperking*account.value | currency }}
      {% $33+ -1*vin*beperking*account.value as:currency %}
    | {%=$34+ -1*vin*beperking*account.value as:currency %}
    {% newline %}
  {% endfor %}
  {% newline %}
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %}                
{% newline %}
{% endstripnewlines %}

{{ header }}
| **{% t "Totaal" %}**                  | **{{ $31 | currency }}** |  |  | | **{{ $34 | currency }}**

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



{% endcapture %}





{% capture detailmeerminderwaarde %}


|-------#+385073
|{% nic %}**<font color="ffffff">{% endnic %} Detail van de meer- en minderwaarden {% nic %}</font>**{% endnic %}

{% stripnewlines %}
{{ header }}
{% newline %}
|    
|**{{ period.year_end_date | date:'%Y' }}**
| **{% t "Beroeps-<br />beperking" %}**
| **{% t "Fiscale beperking" %}**
| **{% t "Totale beperking" %}**    
| **{% t "Belast" %}**                      
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %} 
{% newline %}

  
{% newline %}{% ifi custom.meerwaarde.accounts != blank %}
{{ header }}
{% newline %}
| **Meerwaarde**{% input custom.meerwaarde.accounts as:account_collection range:76 default:76 accounts_var:meerwaarde %}|||||
{% newline %}
  {% for meer in meerwaarde %}
    {% assign toegewezen = toegewezen | append: account.number | append:";" %}
    | {{ meer.name }}
    | {%=$2+ -1*meer.value | currency %}
    | {% input custom[meer.number].vin as:percentage placeholder:'0.00%' %}
        {% if custom[meer.number].vin == blank %}
          {% assign vin = 1 %}
        {% else %}
          {% assign vin = 1-custom[meer.number].vin placeholder:'' %}
        {% endif %}
        {% $3+ -1*vin*meer.value as:currency %}
    | {% input custom[meer.number].beperking as:percentage placeholder:'0.00%' %}
      {% if custom[meer.number].beperking == blank %}
        {% assign beperking = 1 %}
      {% else %}
        {% assign beperking = 1-custom[meer.number].beperking %}
      {% endif %}
      {% $5+ -1*vin*beperking*meer.value-(1-vin)*meer.value as:currency %}
    | {{ meer.value-1*vin*beperking*meer.value | currency }}
      {% $6+ -1*vin*beperking*meer.value as:currency %}
    | {%=$4+ -1*vin*beperking*meer.value as:currency %}
    {% newline %}
  {% endfor %}
  {% newline %}
{% newline %}{% endifi %}


{% newline %}{% ifi custom.minderwaarde.accounts != blank %}
{{ header }}
{% newline %}
| **Minderwaarde**{% input custom.minderwaarde.accounts as:account_collection range:66 default:66 accounts_var:minderwaarde %}|
{% newline %}
  {% for account in minderwaarde %}
    {% assign toegewezen = toegewezen | append: account.number | append:";" %}
    | {{ account.name }}
    | {%=$2+ -1*account.value | 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 %}
        {% $3+ -1*vin*account.value as:currency %}
    | {% input custom[account.number].beperking as:percentage placeholder:'0.00%' %}
      {% if custom[account.number].beperking == blank %}
        {% assign beperking = 1 %}
      {% else %}
        {% assign beperking = 1-custom[account.number].beperking %}
      {% endif %}
      {% $5+ -1*vin*beperking*account.value-(1-vin)*account.value as:currency %}
    | {{ account.value-1*vin*beperking*account.value | currency }}
      {% $6+ -1*vin*beperking*account.value as:currency %}
    | {%=$4+ -1*vin*beperking*account.value as:currency %}
    {% newline %}
  {% endfor %}
  {% newline %}{% endifi %}
  
  
{% newline %}                
{% newline %}
-----------------------------------------------------------------------------------------------------------
{% newline %}                
{% newline %}
{% endstripnewlines %}

{{ header }}
| **{% t "Totaal" %}**                  | **{{ $2 | currency }}** |  |  | | **{{ $4 | currency }}**

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


{% endcapture %}






{% if custom.detail.goederen == blank %}{% assign goederen_range = '60'%}{% else %}{% assign goederen_range = custom.detail.goederen %}{% endif %}
{% assign goederen = period.accounts | range:goederen_range %}

{% stripnewlines %}
{% newline %}
|---------------------|-------15%-------:|-------15%-------:|-------15%-------:+
{% newline %}
| {% t "Ontvangsten/Baten" %} {% input custom.detail.omzet as:account_collection range:7 default:'70' accounts_var:omzet %}| | | {%=$10+ -1*omzet.value | currency %}
  {% for account in omzet %}
  {% assign toegewezen = toegewezen | append: account.number | append:";" %}{% $31+ account.value %}
  {% newline %}
  | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{ account.name }}|{{ -1*account.value | currency }}
  {% endfor %}
{% ifi goederen.value != 0 %}
{% newline %}
| {% t "Handelsgoederen, grond en hulpstoffen" %} {% input custom.detail.goederen as:account_collection range:6 default:'60' %}| |{{ -1*goederen.value | currency }}
  {% for account in goederen %}
  {% assign toegewezen = toegewezen | append: account.number | append:";" %}{% $32+ account.value %}
    {% newline %}
    | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{ account.name }}|{{ -1*account.value | currency }}
  {% endfor %}
{% newline %}
| {% t "Beginvoorraad" %} {% input custom.detail.beginvoorraad as:account_collection range:6,7 accounts_var:beginvoorraad %} {% input custom.beginvoorraad.doc as:file %}| | {{ -1*beginvoorraad.value | currency}}{% result 'beginvoorraad' -1*beginvoorraad.value %}
  {% for account in beginvoorraad %}
    {% assign toegewezen = toegewezen | append: account.number | append:";" %}{% $33+ account.value %}
  {% endfor %}
{% newline %}
| {% t "Eindvoorraad" %} {% input custom.detail.eindvoorraad as:account_collection range:6,7 accounts_var:eindvoorraad %} {% input custom.eindvoorraad.doc as:file %}| |_{{ -1*eindvoorraad.value | currency}}_ {% result 'eindvoorraad' -1*eindvoorraad.value %} 
  {% for account in eindvoorraad %}
    {% assign toegewezen = toegewezen | append: account.number | append:";" %}{% $34+ account.value %}
  {% endfor %}
{% newline %}
| {% t "Verkochte goederen" %}|||_{%=$10+ -1*(beginvoorraad.value+goederen.value+eindvoorraad.value) | currency %}_ 
{% newline %}
| {% t "Brutowinst / Baten" %}        ||| **{{ $10 | currency }}**{% endifi %}
{% newline %}
| {% t "Andere bedrijfsopbrengsten" %}              | | |_{% =$10+ $34 %}_
{% newline %}
| {% t "Brutowinst / Baten na andere bedrijfsopbrengsten" %}        ||| **{{ $10 | currency }}**{% ifi custom.detail.achterstallen != blank %}
{% newline %}
| {% t "Achterstallige erelonen " %} {% input custom.detail.achterstallen as:account_collection range:7 accounts_var:achterstallen %}| | | {%=$10+ -1*achterstallen.value | currency %} {% endifi %} {% ifi custom.detail.sociale_bijdrage != blank %}
  {% for account in achterstallen %}
  {% assign toegewezen = toegewezen | append: account.number | append:";" %}{% $31+ account.value %}
  {% newline %}
  | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{ account.name }}|{{ -1*account.value | currency }}
  {% endfor %}
{% newline %}
| {% t "Sociale bijdragen" %} {% input custom.detail.sociale_bijdrage as:account_collection range:6 accounts_var:sociale_bijdrage %} {% input custom.sociale_bijdrage.doc as:file %}| | | {%=$10+ -1*sociale_bijdrage.value | currency %}{% endifi %}{% result 'sociale_bijdrage' -1*sociale_bijdrage.value %}{% ifi custom.detail.echtgenote != blank %}
{% for account in sociale_bijdrage %}
{% assign toegewezen = toegewezen | append: account.number | append:";" %}{% $35+ account.value %}
    {% newline %}
    | {{ account.name }}|{{ account.value | currency }}
{% endfor %}
{% newline %}
  | {% t "Toekenning meewerkende echtgeno(o)t(e)" %} {% input custom.detail.echtgenote as:account_collection range:6 accounts_var:echtgenote %} {% input custom.echtgenoot.doc as:file %} | | | {%=$10+ -1*echtgenote.value | currency %}{% endifi %}{% result 'echtgenote' -1*echtgenote.value %}
  {% for account in echtgenote %}
    {% assign toegewezen = toegewezen | append: account.number | append:";" %}{% $36+ account.value %}
  {% endfor %}
  {% assign bruto_winst = $10 %}
{% 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:6,7 %}{% input extra_account.doc as:file %} | | |{% assign accounts = period.accounts | range:extra_account.accounts %}{%=$20+ -1*accounts.value | currency %}
  {% endfori %}
  |
{% endstripnewlines %}

{% newpage %}
{% ifi anderebo.value != 0 %}
{{ detailanderebo }}
<br>{% endifi %}
{{ detailkosten }}{% ifi #66+#76 != 0 %}
<br>
{{ detailmeerminderwaarde }}{% endifi %}



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

{% assign accounts = period.accounts | range:'6,7' %}{% assign count_6_7 = 0 %}
{% for acc in accounts %}
  {% assign count_6_7 = count_6_7 | plus:1 %}
{% endfor %}

{% assign count_toegewezen = toegewezen | split:";" %}
{% for acc in count_toegewezen %}
  {% assign count = count | plus:1 %}
{% endfor %}

{% assign niet_toegewezen = #6+#7+(bruto_winst+$21+$20-+$2) %}

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

{% stripnewlines %}
  {% if count == count_6_7 %}
    *<font color="00a30e">{% t "Alle rekeningen zijn opgenomen" %}</font >*
  {% elsif count > count_6_7 %}
    *<font color="CC0000">{% t "Eén of meerdere rekeningen werden meermaals toegewezen" %}</font >*
  {% else %}
    {% assign show_niet_toegewezen = true %}
    *<font color="AAAAAA">{% t "Niet alle rekeningen zijn opgenomen" %}</font >*
  {% endif %}
{% endstripnewlines %}<br>

{% if show_niet_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 %}```

@Cedric,

Same issue: you do an ifi-statement on this object {% ifi custom[category_key].value != 0 %}

but

  1. that custom object custom[category_key].accounts will be empty, if you don’t use the # and drag some accounts around.

  2. custom[category_key].value is not defined (it doesn’t exist). I think you confuse it with a collection? Because with a collection, you can indeed add .value to it.

I erased that ifi-statement and the code worked fine.

Hopefully, you can adapt your code with this? Almost there :blush:

@sven,

I added the ifi-statement because I want the category not to be printed in Export Mode if there is no account added to it. F.i. with ‘Bureelkosten’, if there are no accounts or costs added to this category I want this not to be printed.
At first I used {% ifi custom[category_key].accounts != blank %} but this didn’t work as explained earlier, the reason why is already clear to me.
But I still want to make sure an empty category won’t be printed in export mode.

@sven,

Like explained above, the account range is empty, even with the default filled in, untill you confirm with the #
Would you have found any solution so this won’t be any issue?

So, if I take an export without confirming the account ranges, notting is printed. I want this to be printed without need of any confirm. Any suggestion?

Hello @Cedric,

You could solve it by using following code :


  {% if custom[category_key].accounts != blank %}
    {% assign cat_range = custom[category_key].accounts %}
    {% assign cat_accounts = period.accounts | range:cat_range %}
  {% else %}  
    {% assign cat_range = category_default %}
    {% assign cat_accounts = period.accounts | range:cat_range %}
  {% endif %} 

So,

{% if custom[category_key].accounts != blank %}
means if the hast-tag has been clicked and some accounts have been moved around.

When that is done, you create a variable acc_range that’s the same as the string of custom[category_key].accounts
You can then create a variable that equals period.accounts but selected on that range variable acc_range :

    {% assign cat_range = custom[category_key].accounts %}
    {% assign cat_accounts = period.accounts | range:cat_range %} 

If the hash-tag hasn’t been clicked yet, it means that we need to define the same variables but then with the default range. That’s the variable category_defaultby the way.

If this is done (inside your for-loop, you could use this ifi-statement :

{% ifi cat_accounts.value != 0 or cat_accounts != empty %} 

If all period.accounts, selected on a specific range, has a value other than zero
OR
if there are no accounts to be found in the collection cat_accounts.

This should work; mind to try it out?

Works great! Thank you very much @sven. :smiley:

My pleasure @Cedric :+1: