We have this code:
{% assign cost_groups = custom.leningen %}
|-----------25%---------------|---------------25%-----------:|---------------25%-----------:|---------------25%-----------:+
||_Korte termijn_|_Lange termijn_|_TOTAAL_
|-----------25%---------------|---------------25%-----------:|---------------25%-----------:|---------------25%-----------:+{% fori aflossingstabel in custom.leningen %}
|{% input aflossingstabel.aanschaffing %}|{% if forloop.last %}_{% endif %}{% $10+input aflossingstabel.kortetermijn as:currency %}{% if forloop.last %}_{% endif %}|{% if forloop.last %}_{% endif %}{% $20+input aflossingstabel.langetermijn as:currency %}{% if forloop.last %}_{% endif %}|{% if forloop.last %}_{% endif %}{{ aflossingstabel.kortetermijn+aflossingstabel.langetermijn | currency }}{% if forloop.last %}_{% endif %}{% endfori %}
| | **{{ $10 | currency }}** | **{{ $20 | currency }}** | **{{ $10+$20 | currency }}**
To get this result:
We fill in the number of the loan on the second line for correct formatting.
This results in a 0,00 at the end.
It is possible to put an if-statement on the sum at the end so the 0,00 is not shown if short term and long terms aren’t filled in?
The end result needs to be like this:
Thanks in advance!
sven
2
Hello @Fiduciaire.Eulaers,
You can put an unless-statement around that if it’s 0.0 like this :
{% assign cost_groups = custom.leningen %}
|-----------25%---------------|---------------25%-----------:|---------------25%-----------:|---------------25%-----------:+
||_Korte termijn_|_Lange termijn_|_TOTAAL_
|-----------25%---------------|---------------25%-----------:|---------------25%-----------:|---------------25%-----------:+{% fori aflossingstabel in custom.leningen %}
|{% input aflossingstabel.aanschaffing %}|{% if forloop.last %}_{% endif %}{% $10+input aflossingstabel.kortetermijn as:currency %}{% if forloop.last %}_{% endif %}|{% if forloop.last %}_{% endif %}{% $20+input aflossingstabel.langetermijn as:currency %}{% if forloop.last %}_{% endif %}|{% if forloop.last %}_{% endif %}{% unless aflossingstabel.kortetermijn+aflossingstabel.langetermijn == 0.0 %} {{ aflossingstabel.kortetermijn+aflossingstabel.langetermijn | currency }}{% endunless %}{% if forloop.last %}_{% endif %}{% endfori %}
| | **{{ $10 | currency }}** | **{{ $20 | currency }}** | **{{ $10+$20 | currency }}**
OR
you can also have your input-field of the first column as text (size:mini) like this :
{% assign cost_groups = custom.leningen %}
|-----------25%---------------|---------------25%-----------:|---------------25%-----------:|---------------25%-----------:+
||_Korte termijn_|_Lange termijn_|_TOTAAL_
|-----------25%---------------|---------------25%-----------:|---------------25%-----------:|---------------25%-----------:+{% fori aflossingstabel in custom.leningen %}
|{% input aflossingstabel.aanschaffing as:text size:mini %}|{% if forloop.last %}_{% endif %}{% $10+input aflossingstabel.kortetermijn as:currency %}{% if forloop.last %}_{% endif %}|{% if forloop.last %}_{% endif %}{% $20+input aflossingstabel.langetermijn as:currency %}{% if forloop.last %}_{% endif %}|{% if forloop.last %}_{% endif %} {{ aflossingstabel.kortetermijn+aflossingstabel.langetermijn | currency }}{% if forloop.last %}_{% endif %}{% endfori %}
| | **{{ $10 | currency }}** | **{{ $20 | currency }}** | **{{ $10+$20 | currency }}**
The last one gives you the option to give more info about the loan.
Hope this helps you forward
Great stuff @Fiduciaire.Eulaers
Thank you for the answer! It works perfectly
The second option is even better!
Thanks a lot!
sven
4