Control Flow Tag IF / ELSE

The if/else code isn’t working.

I would like when the result of | = Liquiditeitstest ratio
| {{ -total_value/benefit_in_kind_range3 | currency }} is bigger than 1 that the text “Uit de balansbenadering blijkt dat er na uitkering nog sprake is van een gunstige liquiditeitspositie.” appears. If smaller than 1 the warning “NIET VOLDOENDE LIQUIDITEITEN VOOR UITKERING” appears.

Is there someone who can assist me with this?

|**=**
{% assign total_value = 0 %}
{% capture code_10_parts %}
{% assign acc_range = custom.benefit_in_kind.range1 as:account_collection range:'4' accounts_var:benefit_in_kind %}
{% assign acc_value = period.accounts | range:acc_range %}
  {% assign total_value = total_value+acc_value %}
{% assign acc_range = custom.benefit_in_kind.range2 as:account_collection range:'5' accounts_var:benefit_in_kind %}
{% assign acc_value = period.accounts | range:acc_range %}
  {% assign total_value = total_value+acc_value %}
{% endcapture %}
|{{ total_value | currency }}
{% newline %}
| **/ Schulden op ten hoogste 1 jaar**
| {% input custom.benefit_in_kind.range3 as:account_collection range:'4' accounts_var:benefit_in_kind_range3 %} {{ -benefit_in_kind_range3 | currency }}**
{% newline %}
|--------|--------
{% newline %}
| **= Liquiditeitstest ratio**
| **{{ -total_value/benefit_in_kind_range3 | currency }}**
{% endstripnewlines %}


{% if -total_value/benefit_in_kind_range3 | currency > 1 %}
  Uit de balansbenadering blijkt dat er na uitkering nog sprake is van een gunstige liquiditeitspositie.
    {% else %}
  **{::warningtext}NIET VOLDOENDE LIQUIDITEITEN VOOR UITKERING{:/warningtext}**
{% endif %}```

Hi @Vanmarcke_ZKT,

It seems this part of your coding is incorrect:

{% if -total_value/benefit_in_kind_range3 | currency > 1 %}
  Uit de balansbenadering blijkt dat er na uitkering nog sprake is van een gunstige liquiditeitspositie.
    {% else %}
  **{::warningtext}NIET VOLDOENDE LIQUIDITEITEN VOOR UITKERING{:/warningtext}**
{% endif %}

as you are using a currency filter in an IF-statement, and this is causing the IF-statement not to work. You should only use actual values in an IF-statement.

So what I suggest to do, is the following:

create a variable: this would contain the real value of what needs to be checked

more info on that, can be found here eg.

in your case, this could be achieved with the following:

{% assign liq_position = -total_value/benefit_in_kind_range3 %}

and then you can use this variable (which will be either positive, negative or zero) in an IF-statement (more info on that here):

{% if liq_position > 0 %}
   ... 
{% else %}
   ... 
{% endif %}

Do you mind going through the documentation of above and adapt it on your coding? Pease, let us known if this was of any help for you too :slightly_smiling_face:

Thanks for the advice.

It works now. :+1: