CASE: add extra column to the Silverfin standard template

There’s some feedback from users who want to change the view of the Silverfin standard template, which looks like this:

Perhaps you want to pimp this standard template a little bit with additional columns?

Here’s the code of our template:

{% comment %}Translations{% endcomment %}
{% t= "titel" fr:"titre" en:"Item" %}
{% t= "waarde" fr:"valeur" en:"Value" %}
{% t= "extra info" fr:"extra info" en:"Description" %}


{% stripnewlines %}
{% fori detail in current_account.details %}{% if forloop.first %}
{% newline %}
|-----25%-----
|-----45%-----
|-----10%-----
|-----20%-----:+
{% endif %}
{% newline %}
| {% input detail.custom.title placeholder:'titel' %}
| {% ic %}
    {% input detail.custom.text as:text size:mini placeholder:'extra info' %}
  {% endic %}
  {% nic %}
    {{ detail.custom.text | multiline_table}}
  {% endnic %}
| {% input detail.custom.doc as:file %}
| {% if current_account.liability_or_income %}
    {% $0+input detail.custom.value as:n_currency placeholder:'waarde' %}
  {% else %}
    {% $0+input detail.custom.value as:currency placeholder:'waarde' %}
  {% endif %}
  {% ic %}
    {% if forloop.last %}
      {% newline %} 
        |               
        |   
        |    
        | **{% if current_account.liability_or_income %}{{ -1*$0 | currency }}{% else %}{{ $0 | currency }}{% endif %}**
    {% endif %}
  {% endic %}
{% endfori %}
{% endstripnewlines %}

Let’s examine this, before we get to updating this template.

{% newline %}
|-----25%-----
|-----45%-----
|-----10%-----
|-----20%-----:+

This code above defines how many columns you want, and how width they need to be (the width is fixed in this case, by using percentages).
The sum of all these can’t be over 100%.

{% newline %}
| {% input detail.custom.title placeholder:'titel' %}
| {% ic %}
    {% input detail.custom.text as:text size:mini placeholder:'extra info' %}
  {% endic %}
  {% nic %}
    {{ detail.custom.text | multiline_table}}
  {% endnic %}
| {% input detail.custom.doc as:file %}
| {% if current_account.liability_or_income %}
    {% $0+input detail.custom.value as:n_currency placeholder:'waarde' %}
  {% else %}
    {% $0+input detail.custom.value as:currency placeholder:'waarde' %}
  {% endif %}

This is the second line of code, that actually defines the input of our template. Each column start with an | (a so-called pipe).

So the first column is (just an input box really):

| {% input detail.custom.title placeholder:'titel' %}

The second (input box defined as text box, which makes it able to put in more lines of text):

| {% ic %}
    {% input detail.custom.text as:text size:mini placeholder:'extra info' %}
  {% endic %}
  {% nic %}
    {{ detail.custom.text | multiline_table}}
  {% endnic %}

Third (the option to add attachments):

| {% input detail.custom.doc as:file %}

Last column (inputing the to reconciled values):

| {% if current_account.liability_or_income %}
    {% $0+input detail.custom.value as:n_currency placeholder:'waarde' %}
  {% else %}
    {% $0+input detail.custom.value as:currency placeholder:'waarde' %}
  {% endif %}

So we have 4 columns defined in the second line of code, and this has to be the same of course as the first line of code. If not, it’ll break your table!

Then there’s a third line of coding (with also 4 columns in it):

  {% ic %}
    {% if forloop.last %}
      {% newline %} 
        |               
        |   
        |    
        | **{% if current_account.liability_or_income %}{{ -1*$0 | currency }}{% else %}{{ $0 | currency }}{% endif %}**
    {% endif %}
  {% endic %}

This is actually the last line that displays the total amount of the fourth column, but this will only be shown in input-mode (will not be displayed in export, because there the total shows up somewhere else).

Let’s say I want to add make the first column less width, and also add an extra column where I can put in a date (like document date f.i.).

How can we do this?

First:
copy the code of the standard Silverfin template (you cannot make changes to a Silverfin template) on firm level (where you see all templates).
Click on the option to add a new account template and choose “New blank template”, fill in the needed boxes and paste the code in the editor at the bottom:

Let’s change the width of the first column into something smaller:

{% newline %}
|-----10%-----
|-----45%-----
|-----10%-----
|-----20%-----:+ 

Save the template, and try it out in a client file; you’ll see this:

So that’s good; all we need to do is change the percentage of the first column.

Let’s add an extra column, and set it as the second column. This will have an impact on all other lines of code!

Let’s update the headers first:

{% newline %}
|-----10%-----
|-----15%-----
|-----45%-----
|-----10%-----
|-----20%-----:+ 

We’ve added an extra column and defined the width as 15%.

Let’s add the extra column in the second line of coding:

{% newline %}
| {% input detail.custom.title placeholder:'titel' %}
| {% input detail.custom.date as:date placeholder:"datum" %}

What I did here, was adding a new input-tag (which allows me to input data) and set that as a date-format: {% input detail.custom.date as:date placeholder:“datum” %}

Always respect the structure of such database variables (that’s how we call them), meaning only the last part can be called something you can choose for yourself.
The as:date part allows you to put in data with a date-picker, while the placeholder:“datum” part gives the name of the database variable (so users knows what has to be filled in exactly).

Don’t forget adding the | before your code!

Then the last line of coding has to be changed as well with the extra column:

      {% newline %} 
        | 
        |
        |   
        |    
        | **{% if current_account.liability_or_income %}{{ -1*$0 | currency }}{% else %}{{ $0 | currency }}{% endif %}** 

So it now has 5 columns.

Now the template has this kind of view:

If you wish to use this as a standard template when no specific template has been chosen, you can do so in the advanced settings on firm level: