Rounding differences

Is it possible to limit the numbers to 2 digits after the comma because now we have some rounding differences in our templates.

Can you post the code @Fiduciaire.Eulaers?

Because we do round to 2 digits after the comma, but only in the end result (not for calculations in between, which is the correct way I think)

This is the code

{% if custom.detail.accounts == blank %}{% assign account_range = '61' %}{% else %}{% assign account_range = custom.detail.accounts %}{% endif %}

| **KOSTEN WEERHOUDEN NIET-BEDRIJFSMATIG** {% input custom.detail.accounts as:account_collection range:6,7 default:account_range %} | Totaal rekening | % niet-bedrijfsmatig | Te verwerpen {% assign accounts = period.accounts | range:account_range %}
|-----------40%---------------|---------------15%-----------:|---------------25%-----------:|---------------15%-----------:+{% for account in accounts %}
|{% if forloop.last %}_{% endif %}{{ account.name }}{% if forloop.last %}_{% endif %}|{% if forloop.last %}_{% endif %}{%=$0+ account.value %}{% if forloop.last %}_{% endif %}|{% if forloop.last %}_{% endif %}{% input custom[account.number].nietbedrijfsmatig as:percentage %}{% if forloop.last %}_{% endif %}|{% if forloop.last %}_{% endif %}{% if custom[account.number].nietbedrijfsmatig == blank %}{% assign nietbedrijfsmatig = 0 %}{% else %}{% assign nietbedrijfsmatig = custom[account.number].nietbedrijfsmatig %}{% endif %}{%=$1+ 1*nietbedrijfsmatig*account.value %}{% if forloop.last %}_{% endif %}{% endfor %}

|-----------40%---------------|---------------15%-----------:|---------------25%-----------:|---------------15%-----------:+{%fori explanation in custom.verklaringen %}
|_{% input explanation.description %}_|_{% $2+input explanation.value as:currency %}_|{% if forloop.last %}_{% endif %}{% input explanation.verworpen as:percentage %}{% if forloop.last %}_{% endif %}|{% if forloop.last %}_{% endif %}{% if explanation.verworpen == blank %}{% assign verworpen = 0 %}{% else %}{% assign verworpen = explanation.verworpen %}{% endif %}{%=$1+ 1*explanation.value*explanation.verworpen %}{% if forloop.last %}_{% endif %}{%endfori %}


|-----------40%----------|------------15%------:|-----------25%-------:|-----------15%-------:+
|                   |  {{ $0 | currency }} |  | **{{ $1 | currency }}{% result 'te_verwerpen' $1 %}**
{% endcapture %}

{% result 'the_form' the_form %}
{% if custom.detail.goederen == blank %}{% assign goederen_range = '60'%}{% else %}{% assign goederen_range = custom.detail.goederen %}{% endif %}
{% assign goederen = period.accounts | range:goederen_range %}
{% assign period.custom.some.thing = $1 %}

{{ table }}

We would like alle the values to be limited to 2 digits because if you make the sum, there are little rounding differences

Did you already had the time to look at this one?

Hello @Fiduciaire.Eulaers,

If you put the variable that shouldn’t be rounded, you can use the as:currency. What this does, is display a value rounded at 2 decimals (which is what everyone want to see); however, the value that is calculated with (for a later use for instance), is not rounded.

So if I calculate a value that has the value of 1,237 then it will show 1,24. But if I use that value later on (in a sum f.i.), then it will calculate with that 1,237 (and not 1,24). Your end result though, will always be rounded to 2 decimals.

Can you try this?

So you need something like {%=$1+ 1*nietbedrijfsmatig*account.value as:currency %}

Should give the result desired (because we use that also in templates like “Verworpen uitgaven”).

When I change the code to this:

{% capture table 'the_form' %}
{% if custom.detail.accounts == blank %}{% assign account_range = '61' %}{% else %}{% assign account_range = custom.detail.accounts %}{% endif %}

| **KOSTEN WEERHOUDEN NIET-BEDRIJFSMATIG** {% input custom.detail.accounts as:account_collection range:6,7 default:account_range %} | Totaal rekening | % niet-bedrijfsmatig | Te verwerpen {% assign accounts = period.accounts | range:account_range %}
|-----------40%---------------|---------------15%-----------:|---------------25%-----------:|---------------15%-----------:+{% for account in accounts %}
|{% if forloop.last %}_{% endif %}{{ account.name }}{% if forloop.last %}_{% endif %}|{% if forloop.last %}_{% endif %}{%=$0+ account.value %}{% if forloop.last %}_{% endif %}|{% if forloop.last %}_{% endif %}{% input custom[account.number].nietbedrijfsmatig as:percentage %}{% if forloop.last %}_{% endif %}|{% if forloop.last %}_{% endif %}{% if custom[account.number].nietbedrijfsmatig == blank %}{% assign nietbedrijfsmatig = 0 %}{% else %}{% assign nietbedrijfsmatig = custom[account.number].nietbedrijfsmatig %}{% endif %}{%=$1+ 1*nietbedrijfsmatig*account.value %}{% if forloop.last %}_{% endif %}{% endfor %}

{% ifi custom.verklaringen != empty %}
|-----------40%---------------|---------------15%-----------:|---------------25%-----------:|---------------15%-----------:+{%fori explanation in custom.verklaringen %}
|_{% input explanation.description %}_|_{% $2+input explanation.value as:currency %}_|{% if forloop.last %}_{% endif %}{% input explanation.verworpen as:percentage %}{% if forloop.last %}_{% endif %}|{% if forloop.last %}_{% endif %}{% if explanation.verworpen == blank %}{% assign verworpen = 0 %}{% else %}{% assign verworpen = explanation.verworpen %}{% endif %}{%=$1+ 1*explanation.value*explanation.verworpen %}{% if forloop.last %}_{% endif %}{%endfori %}
{% endifi %}

|-----------40%----------|------------15%------:|-----------25%-------:|-----------15%-------:+
|                   |  {{ $0 | currency }} |  | **{%=$1+ 1*nietbedrijfsmatig*account.value as:currency %}{% result 'te_verwerpen' $1 %}**
{% endcapture %}

{% result 'the_form' the_form %}
{% if custom.detail.goederen == blank %}{% assign goederen_range = '60'%}{% else %}{% assign goederen_range = custom.detail.goederen %}{% endif %}
{% assign goederen = period.accounts | range:goederen_range %}
{% assign period.custom.some.thing = $1 %}

{{ table }}

The template doens’t make an endresult anymore.
So there will always be rounding differences? It is shown with 2 decimals, but it will always count with 3?

Hello @Fiduciaire.Eulaers,

To make sure something is calculated rounded with 2 decimals instead of 3, you can add a round-filter :

{%=$0+ $1 | round | currency %} : this will show it rounded and aslo let’s you calculate with the rounded number

{%=$0+ $1 | currency %} : this will show the amount rounded, but the value that will be calculated with, will be with the total amount (so 4,568 instead of 4,57).

We use this with our template of “Verworpen uitgaven” by the way.

hope this helps you forward

It’s working! Thanks!