Sometimes we need to have default accounts selected in our templates other than the accounts we are going to add. For example, in our Verworpen Uitgaven template we assign the accounts collection defining a range using
{% assign accounts_a = period.accounts | range: custom_accounts.a %}
and then for our "Niet aftrekbare belastingen” using
{% input custom.accounts.a as:account_collection range:6,7 %}
we get to select from a collection of accounts starting with 6 and 7.
What if we have to add a default account? In order to achieve that, we should use the following if statement.
{% if custom.accounts.a == blank %}{% assign custom_accounts_a = “645000,603000"%}{% else %}{% assign custom_accounts_a = custom.accounts.a %}{% endif %}
If the account collection (custom.account.a) is empty, it will assign an account collection (custom_account_a) which is going to be our default collection of accounts.
We also need to change our range to
{% assign accounts_a = period.accounts | range: custom_accounts_a %}
in order to match with our assign and be able to fill the values and not give us a blank result.
Finally, our input has to be like this
{% input custom.accounts.a as:account_collection range:6,7 default:custom_accounts_a %}
adding the default parameter for the account collection we assigned before.
Just to make it easier for you to understand how this works, I will post both codes below. Without the default account our code will look like this (just for the Niet aftrekbare belastingen):
{% assign accounts_a = period.accounts | range: custom_accounts.a %}
{% ifi accounts_a != empty%}
{{ title_header }}
| **{% t "Niet aftrekbare belastingen" %}** {% input custom.accounts.a as:account_collection range:6,7 %}{% assign $1 = 0 %}
{{ accounts_header }}{% for account in accounts_a %}
|| {{ account.number }} {{ account.name }} | {%=$1+ account.value %}{% endfor %}{% fori extra in custom.a %}
|| {% input extra.description %} | {%=$1+input extra.value as:currency %} {% endfori %}
|| | *{{ $1 | currency }}* | 100% | **{%=$0+ $1 | round | currency %}**{% endifi %}
This is our output
And with our default account, the code will be like this:
{% if custom.accounts.a == blank %}{% assign custom_accounts_a = "645000,603000"%}{% else %}{% assign custom_accounts_a = custom.accounts.a %}{% endif %}
{% assign accounts_a = period.accounts | range: custom_accounts_a %}
{% ifi accounts_a != empty%}
{{ title_header }}
| **{% t "Niet aftrekbare belastingen" %}** {% input custom.accounts.a as:account_collection range:6,7 default:custom_accounts_a %}{% assign $1 = 0 %}
{{ accounts_header }}{% for account in accounts_a %}
|| {{ account.number }} {{ account.name }} | {%=$1+ account.value %}{% endfor %}{% fori extra in custom.a %}
|| {% input extra.description %} | {%=$1+input extra.value as:currency %} {% endfori %}
|| | *{{ $1 | currency }}* | 100% | **{%=$0+ $1 | round | currency %}**{% endifi %}
This is our output
If you have any questions, please dont hesitate to ask.