We have a reconciliation that has been used for some time, and we’d like to add a new required field that will be needed to ensure the document flags as reconciled.
How can we release this update, without this becoming a new required field for older periods? I’m aware users should be locking their periods to prevent reconciliations from changing, but I’m also conscious that this hasn’t been happening as widely as we’d like to expect.
I suspect we would need to time-restrict the update, i.e. if the period end date > the date I hard-code for the update, then show the updated code? But I’m struggling with exactly how to write this in liquid.
Please let me know if there’s a simpler way to achieve this.
Indeed, I think your analysis is correct. In first place, users should in principle lock older periods as a general best practice in order to avoid template updates being pushed in closed periods. We also follow your concern that this may not have been generally implemented by all users in all cases.
Time restricting the update might be the best way to cope with this, and is also something we often do. However, we would rather make the update appear going forward. So instead of checking the date you updated the code, we would implement such changes as from next period/year for example. So something like period.year_start_date >= '2022-01-01' or period.fiscal_year >= 2022.
Note that comparing with dates in Liquid can be a bit tricky. If you would compare to start date or end date of a period you could do something like this:
When comparing with a fixed date, you better set the format correct first by doing something like:
{% capture date %}{{ “10/11/2021” | date:“%Y-%m-%d” }}{% endcapture %}
{% if date >= ‘2022-01-01’ %}
Finally, there could be two options on how to exactly apply the if-statement this in your code:
Apply the if-statement around the required attribute changing the required to true/false depending on the outcome (preferred option in case changes only apply on one or a few inputs).
Apply the if-statement around the entire template code in combination with smart use of the parts (preferred option in case changes apply to huge part of the code as this will improve code readability and maintainability going forward).
{% capture start_date %}{{ period.year_start_date | date:“%Y-%m-%d” }}{% endcapture %}
{% if start_date >= ‘2022-01-01’ %}
{% include “parts/as_of_2022” %}
{% else %}
{% include “parts/before_of_2022” %}
{% endif %}
Both options are often used by us in different situations.