Advanced [Exercise 1 & 2: Arrays, updated_by & updated_at] (Training slides exercise)

  • Create a checklist with questions related to VAT declarations (this could be in an infotext e.g.)
  • Several columns: checkbox, the question, option to comment
  • Make sure if checkbox is not done, the template cannot get reconciled (show this with an indicator, which is a separate column)
  • Add a tick box that will display the name of the user and the time it was checked.
  • The checklist cannot be reconciled unless someone checks the template final
  • The template should be locked once the review final boolean is ticked

Solution:

{% ic %}{::infotext}This overview is a checklist needed each period for VAT declaration{:/infotext}{% endic %}
{% assign question_array = "Did the customer send all purchase invoices?|Did the customer send all sale invoices?|Are all invoices booked?|Are all financial transactions booked?|Has the VAT declaration been filed?" | split:"|" %}
{% assign key_array = "purchase|sale|invoice|transaction|declaration" | split:"|" %}

{% stripnewlines %}
| Review final?
| Final check by:
| Final check on:
{% newline %}
|------
|------
|------#
{% newline %}
| {% input custom.final.check as:boolean assign:final_check %}
{% if custom.final.check == true %}
| {{ final_check.updated_by.name }}
| {{ final_check.updated_at | localized_date:"%d/%m/%y - %H:%M" }}
{% assign sf_show_inputs = false %}
{% endif %}
{% newline %}
{% endstripnewlines %}




{% stripnewlines %}
|
|
|
| Check
| Comment
{% newline %}
|---1%---
|---5%---
|---1%---:
|--------
|--50%-+
{% newline %}
{% assign no = 0 %}
{% for item in key_array %}
| {% if custom.bool.[item] != true %}{% unreconciled 1 as:indicator unreconciled_text:'Obligated' %}{% endif %}
| {% input custom.bool.[item] as:boolean %}
| {% assign no = no+1 %}
  {{ no | integer }}.
| {{ question_array[forloop.index0] }}
| {% input custom.check.[item] as:text default:item %}
{% newline %}
{% endfor %}
{% endstripnewlines %}

Solution using HTML Tables:

{% ic %}{::infotext}This overview is a checklist needed each period for VAT declaration{:/infotext}{% endic %}
{% assign question_array = "Did the customer send all purchase invoices?|Did the customer send all sale invoices?|Are all invoices booked?|Are all financial transactions booked?|Has the VAT declaration been filed?" | split:"|" %}
{% assign key_array = "purchase|sale|invoice|transaction|declaration" | split:"|" %}

<table class="usr-width-100 usr-bordered">
  <thead>
    <tr>
      <th class="">Review final?</th>
      <th class="">Final check by:</th>
      <th class="">Final check on:</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td class="">{% input custom.final.check as:boolean assign:final_check %}</td>
      {% if custom.final.check == true %}
        <td class="">{{ final_check.updated_by.name }}</td>
        <td class="">{{ final_check.updated_at | localized_date:"%d/%m/%y - %H:%M" }}</td>
        {% assign sf_show_inputs = false %}
      {% else %}
        <td class=""></td>
        <td class=""></td>
      {% endif %}
    </tr>
  </tbody>
</table>

<table class="usr-width-100">
  <thead>
    <tr>
      <th class="usr-width-1 usr-line-bottom"></th>
      <th class="usr-width-5 usr-line-bottom"></th>
      <th class="usr-width-1 usr-line-bottom"></th>
      <th class="usr-line-bottom"><b>Check</b></th>
      <th class="usr-width-50 usr-line-bottom"><b>Comment</b></th>
    </tr>
  </thead>
  <tbody>
    {% assign no = 0 %}
    {% for item in key_array %}
      <tr>
        <td class="">{% if custom.bool.[item] != true %}{% unreconciled 1 as:indicator unreconciled_text:'Obligated' %}{% endif %}</td>
        <td class="">{% input custom.bool.[item] as:boolean %}</td>
        <td class="">{% assign no = no+1 %}{{ no | integer }}.</td>
        <td class="">{{ question_array[forloop.index0] }}</td>
        <td class="">{% input custom.check.[item] as:text default:item %}</td>
      </tr>
    {% endfor %}
  </tbody>
</table>