Rounding problem

Hi,

I’m working for Fintrax and while creating a template i had some rounding problems. I wanted to round the accounts to a thousand and not al the accounts were always correctly rounded to the nearest thousand.

.

{% assign [tangible_fixed_assets_24_thousand] = tangible_fixed_assets_24_thousand_accounts %}
{% assign tangible_fixed_assets_24_accounts = period.[year_period].accounts | range:tangible_fixed_assets_24_accounts_default %}
{% capture tangible_fixed_assets_24 %}tangible_fixed_assets_24_{{ year }}{% endcapture %}
{% assign [tangible_fixed_assets_24] = tangible_fixed_assets_24_accounts %}

{% assign tangible_fixed_assets_24_thousand_accounts = period.[year_period].accounts.return_values_in_thousands | range:tangible_fixed_assets_24_thousand_accounts_default %}
{% capture tangible_fixed_assets_24_thousand %}tangible_fixed_assets_24_thousand_{{ year }}{% endcapture %}

Hi @jsavat

welcome to our community. I see that some of the fixed assets, like tangible_fixed_assets_26 and tangible fixed_assets_thousand don’t really match what is expected.

Can you provide some more of your code, where you do the rounding? Because now, unless my mistake, I don’t really see that part.

Kind regards
Sofie

Hi Sofie

Here’s another example, where the rounding isn’t correct. I placed the code that I used underneath it.

{% assign tangible_fixed_assets_24_accounts = period.accounts | range:“24” %}
{% assign tangible_fixed_assets_24_thousand_accounts = period.accounts.return_values_in_thousands | range:“24” %}

{{ tangible_fixed_assets_24_accounts }}
{{ tangible_fixed_assets_24_thousand_accounts }}

Kind regards
Joachim

Hi @jsavat

The syntax is working as should however this is not the result you wish to obtain. The use of period.accounts.return_values_in_thousands will round for each account within the range prior to making the sum of your range. See below example:

{% assign accounts = period.accounts | range:"13" %}
{% assign accounts_rounded = period.accounts.return_values_in_thousands | range:"13" %}

accounts:

{% stripnewlines %}
|------
|------
{% for account in accounts %}
{% newline %}
| {{ account.number }}
| {% =$0+ account.value as:currency %}
{% endfor %}
{% newline %}
|^ Total ^
|^ {{ accounts }} ^
{% endstripnewlines %}

----------------------------

accounts_rounded:

{% stripnewlines %}
|------
|------
{% for account in accounts_rounded %}
{% newline %}
| {{ account.number }}
| {% =$1+ account.value as:currency %}
{% endfor %}
{% newline %}
|^ Total ^
|^ {{ accounts_rounded }} ^
{% endstripnewlines %}

result:
Schermafbeelding 2020-03-13 om 15.44.34 Schermafbeelding 2020-03-13 om 15.44.40

In your case I would suggest printing the variable and using a print-option to round:

{{ tangible_fixed_assets_24_accounts  | currency:-3 }}

Best regards
Kevin