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