Rollforward details with date

Hi,

Is it possible to add the following rollforward code for some details in a Silverfin template?
You know, there’s always that assistent that keeps on forgetting to adjust the dates…
when you copy your details to the next period it will change the mentioned year to year +1.
So “august 2019”, will become “august 2020” if you copy it from the previous period.

It already works with our own templates, but would be great if it’s also implemented in those of Silverfin.

{% assign fy_from = period.fiscal_year %}

{% if fy_to > fy_from %}
  {% for detail in current_account.custom.details %}
    {% capture text1 %}{{detail.custom.omschrijving}}{% endcapture %}
    {% capture text2 %}{{text1 | replace: "2029","2030"| replace: "2028","2029"| replace: "2027","2028"| replace: "2026","2027" | replace: "2025","2026" | replace: "2024","2025"| replace: "2023","2024"| replace: "2022","2023"| replace: "2021","2022"| replace: "2020","2021"| replace: "2019","2020"| replace: "2018","2019"}}{% endcapture %}
    {% rollforward text2 detail.custom.omschrijving %}
  {% endfor %}
{% endif %}

I cann't seem to change i.e. (replace: "2029","2030") into a variable function like (replace: "year0","year1")
The above is just a workaround until 2030.

Hi Pascal

thank you for your use case of the rollforward, combined with dates. In fact, you can use the rollforward together with the functionality to calculate with dates. More about this calculation here: CASE: calculate with dates

In your case you can do the following:

{% fori detail in current_account.custom.details %}
{% input detail.custom.omschrijving as:date %}
{% endfori %}

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

{% if fy_to > fy_from %}
  {% for detail in current_account.custom.details %}
  {% assign prev_date = detail.custom.omschrijving | as:date  %}
  {% assign new_date = prev_date | advance_years:1  %}
    {% rollforward new_date detail.custom.omschrijving %}
  {% endfor %}
{% endif %}

You see that the input field custom.omschrijving is a date , which allows us to calculate with it.
We assign the date entered in the field as the previous date and the date + 1 year as the new date. Like this, it will calculate without having to update the code after 2030.

Thank you for your suggestion to improve our templates. I added it to the changes for the near future to make the user experience better .

Kind regards
Sofie

Hi Sofie,

That works with dates.
Won’t argue about that.

However, detail.custom.omschrijving is plain text as i.e. “xxxtttxxd 2019 xpppxxxxxx 2020”
I won’t get the output I want if I change “xxxxxd 2019 xxxxxxx 2020” to a date variabel.

Hi Pascal

indeed, we can only calculate with dates and not with text fields.
If you know that the year is always at the end of the text, you can try to slice the string at 4 characters at the end and do the math with that piece of the string. But, I’m afraid that would lead to a more complicated code than the code you suggested.

Kind regards
Sofie