Export corrections

Hallo,

We made our own export of the corrections in Excel but the sorting is nog OK.

Wat did we need to change in our code to receive first all external corrections from 1 to … and the all internal corrections from 1 to …?

This is our code:

{% stripnewlines %}
{%assign adjs = period.adjustments %}
{% for adjustment in adjs %}
{%assign lineindex = 0%}{% for transaction in adjustment.transactions %}
{%assign lineindex = lineindex+1%}
{% assign adj_number = adjustment.number %}
{%if adjustment.internal? %}
{% assign adj_type = "internal" %}
{%else%}
{% assign adj_type = "external" %}
{%endif%}
{% assign tran_account_deloitte = transaction.account.number %}
{% assign tran_account_klant = transaction.account.original_number %}
{% assign tran_account_desc_deloitte = transaction.account.name %}
{% assign tran_account_desc_klant = transaction.account.original_name %}
{% assign tran_description = transaction.description %}
{% if transaction.value > 0 %}{%assign tranval = transaction.value %}{%else%}{%assign tranval = (-1)*transaction.value %}{% endif %}
{%capture xlsdecimal%}{{ tranval | currency }}{%endcapture%}{%capture newval%}{{xlsdecimal | replace: ".", "" | replace: ",", "" | replace: " ", "" }}{%endcapture%}{%assign len =newval|size %}{%capture xlsdecimal%}{{newval  | slice: 0, (len-2)}},{{newval  | slice: -2,2}}{%endcapture%}
{%if lineindex == 1%}{{ adj_type }};#{{ adj_number }}{%newline%}{%endif%} 
{{ tran_account_deloitte }};{{ tran_account_klant }};{{ tran_account_desc_deloitte }};{{ tran_account_desc_klant }};{{ tran_description }};{% if transaction.value > 0 %}{{xlsdecimal}}{% endif %};{% if transaction.value < 0 %}{{xlsdecimal}}{% endif %}{%newline%}
{%endfor%}{%newline%}
{%endfor%}
{% endstripnewlines %}

Thanks,

Sylvie

Nice looking export @svalais :+1:

you do know we support downloading all corrections into one excel-file? see also here

But, intrigued by that code, I do want to solve it.

You could do this :

{% assign adjs = period.adjustments | sort:"number" %} 

This will automatically sort on number. However, you wish to export first the internal corrections (ordered on number) and then external (ordered as well).

You could split up your code and make 2 forloops (that loop over adjs). For each forloop, you could use an if-statement :

{%if adjustment.internal? %} 

and for the second forloop :

{%if adjustment.external? %} 

Care to give it a try?