Hi @Flora,
Thanks for your question. You actually are halfway there, as I see you are familiar with the include_zeros
method.
Now, you created a collection of accounts in additional_items
, and that collection will look at all accounts having a value (different than zero) in the current period. So if an account doesn’t have a value different than zero (but it does in previous year/periods), it won’t be taken into your logic and simply won’t show up.
How to fix this? Well, you’ll need to make sure all accounts of current period are taken into consideration, including the ones with a value zero. And you can do that with adding the method include_zeros
into your collection:
{% for additional in additional_items.include_zeros %}
...
{% endfor %}
Hope this helps?
PS do note it is better to use the mapped_number
variable instead of the number
, as that number can be different than you’d expect.
More info here:
I also fine-tuned your code a bit for the value of the account in current period, as you don’t need to create that with a filter on the period.accounts drop.
You can just do:
{% assign additional_cy_end = additional.value %}
Here it is completed:
{% stripnewlines %}
{% for additional in additional_items.include_zeros %}
{% ic %}|{% endic %}
|{% capture additional_account_link %}{% linkto additional %}{{ additional.original_number }} {{ additional.name }}{% endlinkto %}{% endcapture %}
{{ additional_account_link }}
{% assign additional_cy_end = additional.value %}
{% assign additional_py_end = period.minus_1y.accounts | range:additional.mapped_number %}
**{{ additional_account_name }}**
|**{{ additional_cy_end | currency:0 }}**
|**{{ additional_py_end | currency:0 }}**
{% newline %}
{% endfor %}
{% endstripnewlines %}