Let’s say we manually put in some movements regarding financial investments in year 2016:
It would be great then, when copying these details from 2016 to 2017, the amounts in column End value would be transferred to the column Begin value (so I don’t need to manually overwrite those amounts, because copying details is just a copy of one period).
With the rollforward-tag you can however! This allows to mark a certain input-object or variable to be transferred to another object or variable the next year.
Take the code of our template:
{% stripnewlines %}
| Description
| Begin value
| Purchased
| Sold
| End value
{% newline %}
|----20%----
|----20%----:
|----20%----:
|----20%----:
|-----------:+
{% fori item in custom.financial_investments %}
{% newline %}
| {% input item.description placeholder:"" %}
| {% $1+input item.begin_value as:currency %}
| {% $2+input item.purchase as:currency %}
| {% $3+input item.sold as:n_currency %}
| {% =$4+ $1+$2+$3 | currency %}
{% assign $1 = 0 %}{% assign $2 = 0 %}{% assign $3 = 0 %}
{% if forloop.last %}
{% newline %}
|
|
|
|
|^_ **{{ $4 | currency }}** _^|
{% endif %}
{% endfori %}
{% endstripnewlines %}
We want the value of $1+$2+$3
to be copied into item.begin_value
the next year.
By adding the rollforward-tag you can, like this:
{% rollforward $1+$2+$3 item.begin_value %}
If you want other fields to have 0.00 you could have this rollforward as well:
{% rollforward 0 item.purchase %}
or use nothing to fill up that field:
{% rollforward nil item.purchase %}
Here’s the complete case:
{% stripnewlines %}
| Description
| Begin value
| Purchased
| Sold
| End value
{% newline %}
|----20%----
|----20%----:
|----20%----:
|----20%----:
|-----------:+
{% fori item in custom.financial_investments %}
{% newline %}
| {% input item.description placeholder:"" %}
| {% $1+input item.begin_value as:currency %}
| {% $2+input item.purchase as:currency %}
{% comment %}reset value on zero when copying details{% endcomment %}
{% rollforward nil item.purchase %}
| {% $3+input item.sold as:n_currency %}
{% comment %}reset value on zero when copying details{% endcomment %}
{% rollforward nil item.sold %}
| {% =$4+ $1+$2+$3 | currency %}
{% comment %}the end value needs to be transferred to the next year as begin value{% endcomment %}
{% rollforward $1+$2+$3 item.begin_value %}
{% assign $1 = 0 %}{% assign $2 = 0 %}{% assign $3 = 0 %}
{% if forloop.last %}
{% newline %}
|
|
|
|
|^_ **{{ $4 | currency }}** _^|
{% endif %}
{% endfori %}
{% endstripnewlines %}