CASE: Retrieve comments from a reconciliation/account template

Let’s say we want to create a document or reconciliation template that shows the notes/comments of the different account/reconciliation templates we have in place.

In order to accomplish this, we can place a footer in all of our templates with an input variable that we’ll use for our comments. For example:

{% assign show_footer = show_footer | default:'hide' %}
{% assign show_footer_export = show_footer_export | default:'show' %}

{% if show_footer == 'show' %}
{% ifi show_footer_export == 'show' %}

Additional comments:
{% input custom.footer.description as:text placeholder:'Description' %}

{% endifi %}
{% endif %}

image

Note: I used the words ‘show’ and ‘hide’ but this is just an example and you can use any words, just remember you must enclose them on either single or double quotation marks.

In the case above, I have created a footer that is hidden by default on all our templates so that it can be activated individually via the configuration field using (remember to enclose the words show and hide with quotation marks, otherwise it won’t work):

{% assign show_footer = 'show' %}

The same applies for the export mode. We might want to see the comments on the preview of our templates but not print them when we export them, so to do that I enclosed the comment box on an ifi statement that does precisely that. To hide the comments from the export mode we have to write the following in our configuration field:

{% assign show_footer_export = 'hide' %}

After this we can go to our document or reconciliation template in which we want to retrieve the comments and create a table like this:

Comments in accounts

{% assign accounts = period.accounts | range:'1__9' %} 

{% for account_comments in accounts %}
{% if account_comments.custom.footer.description != blank %}
{% stripnewlines %}
|:--------30%------
|:--------70%------+
{% newline %}
|{{ account_comments.link }}
|{{ account_comments.custom.footer.description }}
{% newline %}
{% endstripnewlines %}
{% endif %}
{% endfor %}

So the key points from the code above are:

▸ I create the range of accounts from which I want to retrieve the comments:

{% assign accounts = period.accounts | range:'1__9' %} 

▸ Then I create a table that loops only the accounts with comments using an if statement that checks that the input variable on the footer is different from blank:

{% if account_comments.custom.footer.description != blank %}

The result is shown below:

This example was to retrieve comments from an account template, but the same can be done to get notes from a specific reconciliation template using the handle like in the example below:

{% stripnewlines %}
|:--------30%------
|:--------70%------+
{% newline %}
|Comments from reconciliation template
|{{ period.reconciliations.handle.custom.footer.description }}
{% newline %}
{% endstripnewlines %}

Note: just substitute the word ‘handle’ in the above code for the specific handle of the reconciliation template we want to retrieve the comments from.

1 Like