Intermediate [Exercise 4: Account collection] (Training slides exercise)

Create an input field with a data type account_collection that allows selecting a range for all accounts in the trial balance beginning with 1 and 3 . Then create a table underneath that will show the account link and account value (with the numeric filter currency ) of the accounts selected. Using the variable created via accounts_var, display the total value of the accounts on the last row of the table with an upper border and in bold.

The final output should look like this:

Screenshot 2020-04-07 at 14.31.10

Solution:

{% input custom.exercise.accounts_to_select as:account_collection range:1,3 accounts_var:exercise_collection %}

{% stripnewlines %}
| Account name
| Account value
{% newline %}
|--------
|--------
{% newline %}
{% for account in exercise_collection %}
  | {{ account.link }}
  | {{ account.value | currency }}
  {% newline %}
{% endfor %}
|^ **Total** ^
|^ **{{ exercise_collection | currency }}** ^
{% endstripnewlines %}

Solution using HTML Tables:

{% input custom.exercise.accounts_to_select as:account_collection range:1,3 accounts_var:exercise_collection %}

<table class="">
  <thead>
    <tr>
      <th class="usr-line-bottom"><b>Account name</b></th>
      <th class="usr-line-bottom"><b>Account value</b></th>
    </tr>
  </thead>
  <tbody>
    {% for account in exercise_collection %}
      <tr>
        <td class="">{{ account.link }}</td>
        <td class="">{{ account.value | currency }}</td>
      </tr>
    {% endfor %}
    <tr>
      <td class="usr-line-top"><b>Total</b></td>
      <td class="usr-line-top"><b>{{ exercise_collection | currency }}</b></td>
    </tr>
  </tbody>
</table>