Adding variables inside different loops depending on the iteration

Hello,

I am trying to create a custom fixed asset note which loops over the account codes for values depending on if the items are selected (line 42). I am having a problem with the column total (lines 113 - 115). I am trying to capture the first iteration value as a variable (line 90) to add to the second loops same iteration (line 105) and then call the value in another loop (line 115).

{% comment %}

Recording variables

{% endcomment %}

{% assign fixed_assets = "Land and buildings | Leasehold improvements | Investment property | Assets under construction | Plant and machinery | Vehicles | Fixtures and fittings | Tools and equipment | Office equipment | Other property plant and equipment" | split:"|" %}
{% comment %}Costs/Valuation{% endcomment %}
{% assign asset_opening_cost =        "Dummy;110000;110100;110960;110200;110300;110400;110500;110600;110700;110800" | split:";" %}
{% assign asset_additions_cost =      "Dummy;110001;110101;110961;110201;110301;110401;110501;110601;110701;110801" | split:";" %}
{% assign asset_disposals_cost =      "Dummy;110002;110102;110962;110202;110302;110402;110502;110602;110702;110802" | split:";" %}
{% assign asset_revaluation_cost =    "Dummy;110003;110103;110963;110203;110303;110403;110503;110602;110703;110803" | split:";" %}

{% comment %}

Start display

{% endcomment %}


{% stripnewlines %}
{% ic %}{::infotext}{% newline %}
Additions and disposals are populated from the {% linkto period.reconciliations.fixed_assets_reconciliation %}{{ period.reconciliations.fixed_assets_reconciliation.name }}{% endlinkto %}{% newline %}
{:/infotext}{% endic %}

{% endstripnewlines %}


{% ic %}{% stripnewlines %}
| Show/Hide


{% newline %}
|--
  {% for select_lines in fixed_assets %}
    |--
  {% endfor %}
|--#

{% newline %}
  {% for asset_select in fixed_assets %}
    |{% input custom.[forloop.index].box as:boolean %} <br> {{ asset_select }}
  {% endfor %}

{% endstripnewlines %}

<br><br>

{% endic %}{% stripnewlines %}
| 
{% for asset_headers in fixed_assets %}
  {% if custom.[forloop.index].box %}
  |{{ asset_headers }}
  {% endif %}
{% endfor %}
| Total

{% newline %}
|--------
{% for main_table_lines in fixed_assets %}
  {% if custom.[forloop.index].box %}
  |---10%---:
  {% endif %}
{% endfor %}
|--------:+

{% newline %}
| 
  {% for pound_sign in fixed_assets %}
   {% if custom.[forloop.index].box %}
   | £
   {% endif %}
  {% endfor %}
| £

{% comment %}Cost/valuation{% endcomment %}
{% comment %}Cost/valuation{% endcomment %}
{% comment %}Cost/valuation{% endcomment %}

{% newline %}
| **Cost / valuation**

{% newline %}
|At {{ period.year_start_date | date:"%d %B %Y"}}
  {% for asset_cost in  fixed_assets %}
   {% if custom.[forloop.index].box %}
   {% assign opening_cost = period.accounts | range:asset_opening_cost[forloop.index] %}
   |{{ opening_cost | currency }} {% $1+ opening_cost %}
   
   {% capture asset_cost[forloop.index] %}{{ opening_cost }}{% endcapture %}
   
   {% endif %}
  {% endfor %}
| {{ $1 | currency }}

{% comment %}Disposals{% endcomment %}

{% newline %}
|Disposals
  {% for asset_disposals in  fixed_assets %}
   {% if custom.[forloop.index].box %}
   {% assign disposals_cost = period.accounts | range:asset_disposals_cost[forloop.index] %}
   |{{ disposals_cost | currency }} {% $4+ disposals_cost %}
   
   {% capture total_cost[forloop.index] %} asset_cost[forloop.index]+ disposal_cost{% endcapture %}
   
   {% endif %}
  {% endfor %}
| {{ $4 | currency }}

{% newline %}
|**At {{ period.year_end_date | date:"%d %B %Y"}}**
  {% for asset_disposals in  fixed_assets %}
   {% if custom.[forloop.index].box %}
   |{{ total_cost.[forloop.index] | currency }} 
   {% endif %}
  {% endfor %}
|
{% endstripnewlines %}

Hi Shellldon

I have added 5 lines of code wich should fix your issue with the totals.

Best regards

{% comment %}

Recording variables

{% endcomment %}

{% assign fixed_assets = “Land and buildings | Leasehold improvements | Investment property | Assets under construction | Plant and machinery | Vehicles | Fixtures and fittings | Tools and equipment | Office equipment | Other property plant and equipment” | split:"|" %}
{% comment %}Costs/Valuation{% endcomment %}
{% assign asset_opening_cost = “Dummy;110000;110100;110960;110200;110300;110400;110500;110600;110700;110800” | split:";" %}{% assign asset_opening_cost = “Dummy;81;82;83;84;110300;110400;110500;110600;110700;110800” | split:";" %}
{% assign asset_additions_cost = “Dummy;10;10;10;110201;110301;110401;110501;110601;110701;110801” | split:";" %}
{% assign asset_disposals_cost = “Dummy;10;10;10;110202;110302;110402;110502;110602;110702;110802” | split:";" %}
{% assign asset_revaluation_cost = “Dummy;110003;110103;110963;110203;110303;110403;110503;110602;110703;110803” | split:";" %}

{% comment %}

Start display

{% endcomment %}

{% stripnewlines %}
{% ic %}{::infotext}{% newline %}
Additions and disposals are populated from the {% linkto period.reconciliations.fixed_assets_reconciliation %}xxx{% endlinkto %}{% newline %}
{:/infotext}{% endic %}

{% endstripnewlines %}

{% ic %}{% stripnewlines %}
| Show/Hide

{% newline %}
|–
{% for select_lines in fixed_assets %}
|–
{% endfor %}
|–#

{% newline %}
{% for asset_select in fixed_assets %}
|{% input custom.[forloop.index].box as:boolean %}
{{ asset_select }}
{% endfor %}

{% endstripnewlines %}



{% endic %}{% stripnewlines %}
|
{% for asset_headers in fixed_assets %}
{% if custom.[forloop.index].box %}
|{{ asset_headers }}
{% endif %}
{% endfor %}
| Total

{% newline %}
|--------
{% for main_table_lines in fixed_assets %}
{% if custom.[forloop.index].box %}
|—10%—:
{% endif %}
{% endfor %}
|--------:+

{% newline %}
|
{% for pound_sign in fixed_assets %}
{% if custom.[forloop.index].box %}
| £
{% endif %}
{% endfor %}
| £

{% comment %}Cost/valuation{% endcomment %}
{% comment %}Cost/valuation{% endcomment %}
{% comment %}Cost/valuation{% endcomment %}

{% newline %}
| Cost / valuation

{% newline %}
|At {{ period.year_start_date | date:"%d %B %Y"}}
{% for asset_cost in fixed_assets %}
{% if custom.[forloop.index].box %}
{% assign opening_cost = period.accounts | range:asset_opening_cost[forloop.index] %}
|{{ opening_cost | currency }} {% $1+ opening_cost %}

{% capture asset_cost[forloop.index] %}{{ opening_cost }}{% endcapture %}
{% capture total_col %}total_{{ asset_cost }}{% endcapture %}
{% assign [total_col] = [total_col]+opening_cost %}
{% endif %}
{% endfor %}
| {{ $1 | currency }}

{% comment %}Disposals{% endcomment %}

{% newline %}
|Disposals
{% for asset_disposals in fixed_assets %}
{% if custom.[forloop.index].box %}
{% assign disposals_cost = period.accounts | range:asset_disposals_cost[forloop.index] %}
|{{ disposals_cost | currency }} {% $4+ disposals_cost %}

{% capture total_cost[forloop.index] %} asset_cost[forloop.index]+ disposal_cost{% endcapture %}
{% capture total_col %}total_{{ asset_disposals }}{% endcapture %}
{% assign [total_col] = [total_col]+disposals_cost %}

{% endif %}
{% endfor %}
| {{ $4 | currency }}

{% newline %}
|At {{ period.year_end_date | date:"%d %B %Y"}}
{% for asset_disposals in fixed_assets %}
{% if custom.[forloop.index].box %}
|{% capture total_col %}total_{{ asset_disposals }}{% endcapture %}{{ [total_col] | currency }}

{% endif %}
{% endfor %}
|
{% endstripnewlines %}