sven
August 8, 2018, 3:35pm
1
There’s a new method you can use to display the value of accounts rounded:
{{ #61 | currency: 0 }}
and it’ll round up without decimals:
Doing this will round to the nearest 10 f.i.:
{{ #61 | currency: -1 }}
Doing this, will show 3 decimals for example:
{{ #61 | currency: 3 }}
This only works for now to present these values this way; it won’t work to calculate with (but will be available in the near future)
Also a round
method has been added, which you can use the same way:
{{ #6 | round: -3 }}
Hi Sven,
I read your post and wonder if it now is possible to calculate with the above method? I.e. would Silverfin calculate with the rounded numbers, or with the decimals?
KR
Emmy
Hi Emmy
When calculating with a rounded variable, Silverfin will calculate further on top of the rounded variable. If you still need to calculate with all the original decimals, it’s best to round the number on the end of the road.
For example
This code:
{% assign account_range = #6 %}
{% assign round_to = -3 %}
{% assign unrounded_costs = account_range %}
{% assign costs = account_range | round:round_to %}
{% assign costs_currency = account_range | currency:round_to %}
**Unrounded**: {{ unrounded_costs | currency }}
**Rounded**: {{ costs | currency }}
**Currency Rounded**: {{ costs_currency }}
<hr>
{% assign increment_with = 5 %}
**Unrounded calculation**
{{ unrounded_costs | currency }} + {{ increment_with }} = {{ unrounded_costs+increment_with | currency }}
**Rounded calculation**
{{ costs }} + {{ increment_with }} = {{ costs+increment_with }}
**Currency Rounded calculation**
{{ costs_currency }} + {{ increment_with }} = {{ costs_currency+increment_with }}
will give you the following output:
Kind regards
Wouter
1 Like