Okay @svalais, it was the if forloop.last
after all that’s causing all of this, and actually, you don’t need to use it.
You want the total of every category-loop displayed, right? So you just add that total on the last (new) line of each loop through every category (but still in your original ifi-statement of course) :
{% for cost_category in cost_categories %}
{% assign $11 = 0 %}
{% assign $12 = 0 %}
{% assign $13 = 0 %}
{% assign category_key = cost_keys[forloop.index0] %}
{% capture custfieldname %}vrije_lijnen_{{category_key}}{%endcapture%}
{% ifi custom[category_key].accounts != blank or custom.[custfieldname] != empty %}
{% newline %}
| {% t cost_category %} {% input custom[category_key].accounts as:account_collection range:6,7 accounts_var:costs %} | | |
{% newline %}
{{ header }}
{% newline %}
{% for account in costs %}
{% assign toegewezen = toegewezen | append: account.number | append:";" %}
| {{ account.name }}
| {%=$11+ account.value as:currency %}
| {% input custom[account.number].vin as:percentage placeholder:'0.00%' %}
{% if custom[account.number].vin == blank %}
{% assign vin = 1 %}
{% else %}
{% assign vin = 1-custom[account.number].vin placeholder:'' %}
{% endif %}
{% $12+ vin*account.value as:currency %}
| {{ account.value-1*vin*account.value | currency }}
{% newline %}
{% endfor %}
{% fori vrije_cost_lijnen in custom.[custfieldname] %}
| {% input vrije_cost_lijnen.omschrijving placeholder:'' %}
| {% $31+input vrije_cost_lijnen.value as:currency as:currency placeholder:'' %} {% assign $33 = vrije_cost_lijnen.value %}
| {% input vrije_cost_lijnen.vin as:percentage placeholder:'0.00%' %}
{% if vrije_cost_lijnen.vin == blank %}
{% assign vin = 1 %}
{% else %}
{% assign vin = 1-vrije_cost_lijnen.vin placeholder:'' %}
{% endif %}
{% $32+ vin*$33 as:currency %}
| {{ $33-1*vin*$33 | currency }}
{% newline %}
{% endfori %}
|
|
|
| **{% =$22+ ($11-$12)+($31-$32) as:currency %}** {% result category_key $34 %}
{% assign $31 = 0 %}
{% assign $32 = 0 %}
{% endifi %}
{% endfor %}
You can do the same thing for the second (custom vrije tekst) loop.
We were too much focused on that if forloop.last thing, but we don’t actually need it, as well it caused (for me anyway) for way too many confusing in combination with the second nested fori-loop.
PS could you post your code like this please?
Because your posted code looked like this :
Not that pretty