CASE rollforward: copy details with destination period

Let’s take this case again:

We might want to be able to tell when the roll-forward function has to be executed.
For instance: if you copy details between periods within the same book year, it might not be needed to have the roll forward function be executed; only when we have a new book year, we want the function to be executed.

From now on, we can do this by choosing a destination-period. Just like you would use a regular period-drop and its methods, you can do this for the rollforward function as well:

rollforward.period

Although it actually has a difference, where the rollforward.period will only have a “value” during the actual copying of the data. So this isn’t something you can’t print (although you could use a workaround for that, but that would be stretching it for now).

Let’s take the code of previously mentioned case, and implement that the roll-forward function only can be executed when copying to a period of a new book year:

{% assign fy_to = rollforward.period.fiscal_year %}
{% assign fy_from = period.fiscal_year %}

I’ll create a variable fy_from which is the fiscal year of the period I’m copying from
(so if I copy details from Q4 2017 in a normal book year, the outcome of that var is 2018).

Now, I want my destination period to be part of a new fiscal year, so I can create some logic for it: rollforward.period.fiscal_year is the fiscal year of the period I’m copying to (so the outcome of the var fy_to is 2019 when I copy details from Q4 2017 to Q4 2018 f.i.)

Now, we can use the outcome of these local variables to use around our roll-forward code:

{% if fy_to > fy_from %} 
   {% rollforward nil item.purchase %}
   {% rollforward nil item.sold %}
   {% rollforward $1+$2+$3 item.begin_value %}
{% endif %} 

meaning the rollforward will only be done if we copy details to a period that has a larger fiscal year than the fiscal year of the period we copy from.

You see that the rollforward.period can be used like the regular period-drop:

  • rollforward.period.year_end_date
  • rollforward.period.minus_1p
  • rollforward.period.minus_1y

Implemented in the code of the case:

{% comment %}check whether or not a new fiscal year is the case when copying data through roll forward function{% endcomment %}
{% assign fy_to = rollforward.period.fiscal_year %}
{% assign fy_from = period.fiscal_year %}

<table class="usr-width-100">
  <thead>
    <tr>
      <th class="usr-width-20 usr-line-bottom"><b>Description</b></th>
      <th class="usr-width-20 usr-line-bottom usr-align-right"><b>Begin value</b></th>
      <th class="usr-width-20 usr-line-bottom usr-align-right"><b>Purchased</b></th>
      <th class="usr-width-20 usr-line-bottom usr-align-right"><b>Sold</b></th>
      <th class="usr-width-20 usr-line-bottom usr-align-right"><b>End value</b></th>
    </tr>
  </thead>
  <tbody>
    {% fori item in custom.financial_investments %}
      <tr>
        <td>
          {% input item.description placeholder:"" %}  
        </td>
        <td class="usr-align-right">
          {% $1+input item.begin_value as:currency %}
        </td>
        <td class="usr-align-right">
          {% $2+input item.purchase as:currency %}
        </td>
        <td class="usr-align-right">
          {% $3+input item.sold as:n_currency %}
        </td>
        <td class="usr-align-right">
          {% =$4+ $1+$2+$3 | currency  %}
        </td>
        
        {% comment %}execute roll forward when new fiscal year is the case{% endcomment %}
        {% if fy_to > fy_from %}
          {% rollforward nil item.purchase %}
          {% rollforward nil item.sold %}
          {% rollforward $1+$2+$3 item.begin_value %}
        {% endif %}
        {% comment %}reset each register for next loop{% endcomment %}
        {% assign $1 = 0 %}{% assign $2 = 0 %}{% assign $3 = 0 %}
      </tr>
      {% if forloop.last %}
      <tr>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td class="usr-line-top usr-line-bottom usr-align-right"><b>{{ $4 | currency }}</b></td>
      </tr>
      {% endif %}
    {% endfori %}
  </tbody>
</table>

This case has been updated on 03/10/2022 to include HTML tables.

1 Like

Hi Sven,

Thank you for your article.
I have an issue with the rollforward-function I hope someone might be able to help me with.

I am trying to ensure that a number calculated during FY18 is rollforwarded as the beginning value of FY19. However, when I try to, no value is shown in FY19.

My code is as follows:

`{% assign fy_to = rollforward.period.fiscal_year %}
{% assign fy_from = period.fiscal_year %}´

Further down in my code when the calculation is performed:

`|{{ max_tax_dep-tax_adjustment | currency: 0 }}
{% comment %}execute rollforward when new fiscal year is the case{% endcomment %}
{% if fy_to > fy_from %}
{% rollforward max_tax_dep-tax_adjustment item.begin_value %}
{% endif %}´

But when i use the printsyntax for item.begin_value, its empty.

What am I doing wrong? I have also tried to assign max_tax_dep-tax_adjustment as tax_dep_cy but that made no difference.

Thank you in advance.

Hi Emmy,

Please make sure you have tried the following:

  • Copy data from previous period via actions --> copy data
  • Variables subject to rollforward should always be custom variables from an {% input %} tag/obtained via a fori loop

Please let us know if you need more help with how to copy data from a previous period. This is a prerequisite for your rollforward tags to work.

If this does not work, please send us more pieces of code so we can have a look.

Hi Melle,

Thank you for your quick reply.

I have used the action to rollforward the information from FY18 to FY19 and included the variable to be forwarded in an input-tag now.

I currently have the following code in the following order:


{% assign fy_to = rollforward.period.fiscal_year %}
{% assign fy_from = period.fiscal_year %}


| {{ item.begin_value }}


|{{ basis_for_dep*0.25 | currency: 0 }} 
{% assign max_tax_dep = basis_for_dep*0.25 %}
{% newline %}
|{% t "tax_adjustment" %}
|{% input custom.tax.adjustment as:currency precision:0 default:0 assign:tax_adjustment %}
{% newline %}
{% t "tax_dep" %} {% ic %}{::infotext as='hover'}{% t "infotext_tax_dep" %}{:/infotext}{% endic %}
  {% assign tax_dep = max_tax_dep-tax_adjustment %}
|{% input custom.tax.dep as:currency precision:0 default:tax_dep assign:custom.tax_dep_cy%} 
  {% comment %}execute rollforward when new fiscal year is the case{% endcomment %}
      {% if fy_to > fy_from %}
        {% rollforward custom.tax.dep_cy item.begin_value %}
      {% endif %}
{% newline %}

´´´

I have tried removing default:tax_dep assign:custom.tax_dep_cy to only have the variable custom.tax.dep but that did not help either, and the goal is to have the value of tax_dep as default.

KR 
Emmy

Hi Emmy,

Remember that rollforward only works with custom variables, i.e. which are obtained via a fori loop and/or by user input.

item.begin_value from Sven his example, is named this way because it concerns such a custom variable. Its value is, in his example, obtained via a fori loop which includes input tags:

{% fori item in custom.financial_investments %}
   {% input item.begin_value as:currency %}
{% endfori %}

Here, item resembles one item within the custom collection custom.financial_investments. The input tag therefore works about the same as {% input custom.financial_investments.begin_value %} would.

In your example, custom variable item.begin_value is printed but there is no fori loop or input tag where it is provided a value.

First, you could change your print to an input field: {% input custom.tax.begin_value as:currency %} You can leave it empty. If you don’t want this to be an input field, add some control flow logic:

  {% if custom.tax.begin_value == blank %}
      {% input item.begin_value as:currency %}
  {% else %}
     {{ custom.tax.begin_value }}
  {% endif %}

Doing so, only in case no value is rollforwarded, it will be an input field.

Finally, do not forget to change the variable name in your rollforward tag. Don’t hesitate to contact us if your problem remains.

1 Like

Hi Melle,

Thank you so much! Now my code is working, such a great start of the day :slight_smile:

KR
Emmy

Hi again,

I have a follow up question with regard to rollforward and would like to have the community’s input.

I am currently looking into best practice to obtain not last years values in a template, but values from two, three and four years back. It is values that has been calculated in the relevant reconiciliation template (i.e. not values on accounts).

For example:
Let say the user calculated the value X during 2017, the value “8” during 2018 and we are now working in the same reconciliation template but it is 2019. By using rollforward as described above, I am able to obtain “8” from 2018 (in 2019). But how do I print X from 2017 when I am in 2019?

The goal for 2019 is to have a table showing the calculated values from four years back as in the attached picture.

My issue is to understand if I should change the logic, or the variables, and how.
KR,
Emmy

Hi Emmy

We always access values from previous years using period.minus_1y , period.minus_2y , etc. from the period drop.

A simple example of this would be to get the value of an input for previous years using this method:

{% input period.custom.some.thing %}
{% assign something = period.custom.some.thing as:currency %}
{% assign something_from_last_year = period.minus_1y.custom.some.thing %}
{% assign something_from_two_years_ago = period.minus_2y.custom.some.thing %}

something from this year: {{ something }}

something from last year: {{ something_from_last_year }}

something from two years ago: {{ something_from_two_years_ago }}

From there on, you can calculate further with the value you get from the period.minus_xy.custom, or
you can read more about all the things you can access through the period.minus_xy if you want to target something other than a custom: https://developer.silverfin.com/docs/period

Feel free to share you code in case you would like some help to look into your specific use case.

Kind regards
Wouter