Issue with case statement

Hi,

I am using following code taken from the Silverfin meeting minutes:

{% assign opt_in_date = "2019-05-01" | date:"%Y-%m-%d" %}
{% assign date_p = period.end_date | date:"%Y-%m-%d" %}
{% assign last_date_old_comp_law = "2019-12-31" | date:"%Y-%m-%d" %}
{% comment %}date legal doc will be empty first, so fall back on date period as date legal doc will never be before date period{% endcomment %}
{% assign date_legal_doc = period.custom.mod.datum | default:date_p %}
{% assign date_legal_doc = date_legal_doc | date:"%Y-%m-%d"  %}
{% comment %}establishment date is rarely filled in, so we set it on default date first when blank{% endcomment %}
{% assign establishment_date = company.custom.establishment.date | default:"1900-01-01" %}
{% assign establishment_date = establishment_date | date:"%Y-%m-%d" %}
{% assign default_creation_after_1_may = false %}
{% assign new_company_law = false %}

{% comment %}create local var "new_company_law" - this activates everything{% endcomment %}
{% if date_p > last_date_old_comp_law or date_legal_doc > last_date_old_comp_law %}
  {% comment %}no need to check date legal doc, as the period date is already after 31/12/2019 we presume{% endcomment %}
  {% assign new_company_law = true %}
{% else %}
  {% if establishment_date >= opt_in_date %}
    {% assign default_creation_after_1_may = true %}
  {% endif %}
  {% comment %}in this situation we always show the option to activate WVV{% endcomment %}
  {% assign new_company_law = company.custom.check.new_company_law | default:default_creation_after_1_may %}
{% endif %}

{% comment %}create local var for company form{% endcomment %}
{% capture company_form %}{{ company.company_form | replace: '.','' | replace: ' ','' | remove:'-' | upcase }}{% endcapture %}
{% case company_form %}
  {% when 'NV' or 'SA' %}
    {% assign NV = true %}
    {% assign full_company_form = "Société anonyme" %}
  {% when 'CVBA' or 'SCRL' %}
    {% assign improper_cvba = false %}
    {% if date_legal_doc > last_date_old_comp_law %}
      {% assign improper_cvba = true %}
    {% else %}
      {% assign CVBA = true %}
    {% endif %}
    {% assign full_company_form = "Société coopérative à responsabilité Limitée" %}
  {% when 'CVOA' or 'SCRI' %}
    {% assign CVOA = true %}
    {% assign full_company_form = "Société coopérative à responsabilité Iillimitée" %}
  {% when 'VZW' or 'ASBL' %}
    {% assign VZW = true %}
    {% assign full_company_form = "Association sans but lucratif" %}
  {% when 'BVBA' or 'EBVBA' or 'SBVBA' or 'SPRL' or 'SPRLU' %}
    {% assign BVBA = true %}
    {% assign full_company_form = "Société privée à responsabilité limitée" %}
  {% when 'BV' or 'SRL' %}
    {% assign BV = true %}
    {% assign full_company_form = "Société à responsabilité limitée" %}
  {% when 'CV' or 'SC' %}
    {% assign CV = true %}
    {% assign full_company_form = "Société coopérative" %}
  {% when 'COMMV' or 'SCOMM' %}
    {% assign COMMV = true %}
    {% assign full_company_form = "Société en commandite" %}
  {% when 'COMMVA' or 'SCA' %}
    {% comment %}After 1/1/2020 the minutes support the COMMVA, starting from the minutes for the NV{% endcomment %}
    {% if date_legal_doc > last_date_old_comp_law %}
      {% assign NV = true %}
    {% endif %}
    {% assign COMMVA = true %}
    {% assign supported_commva = false %}
    {% if NV and COMMVA %}
      {% assign supported_commva = true %}
    {% endif %}
    {% assign full_company_form = "Société en commandite par actions" %}
  {% when 'VOF' or 'SNC'  %}
    {% assign VOF = true %}
    {% assign full_company_form = "Société en nom collectif" %}
{% endcase %}

<!-- create "drop" (array) with period.directors and begin- and enddate mandats check with date AV or date uitstel AV --> 
 
{% assign date_start = period.start_date | date:"%Y-%m-%d" %}

{% if period.custom.postponement.date_known == true %} 
  {% assign date_av = period.custom.uitstel.datum | default:date_default %}
{% else %}
  {% if period.custom.artikels.uitstel == true %} 
    {% if date_start <= end_2020 %}
      {% assign date_av = period.custom.av.uitsteldatum | default:date_default %}
    {% else %}
      {% assign date_av = period.custom.notulen.datum | default:date_default %}
    {% endif %}
  {% else %}
    {% assign date_av = period.custom.av.datum | default:date_default %}
  {% endif %}
{% endif %}
{% assign date_av = date_av | date:"%Y-%m-%d" %}

{% assign names = "" %}
{% assign keys = "" %}

{% comment %}boolean to show option signature auditor{% endcomment %}
{% for person in period.people %}
{% assign show_option_auditor_signature = false %}
{% if person.custom.function == 61 %}
{% assign show_option_auditor_signature = true %}
{% break %}
{% endif %}

{% assign default_type = "" %}
{% if person.custom.represented_by_name != blank %}
  {% assign default_type = "legal" %}
{% else %}
  {% assign default_type = "nature" %}
{% endif %}
{% comment %}look at the dropdown to check whether someone is LEGAL or not{% endcomment %}
{% assign type = person.custom.type | default:default_type %} 

  {% assign show_begin_mandat = false %}
  {% assign show_end_mandat = false %}
  {% assign begin_mandat = person.director_start_date | date:"%Y-%m-%d" %}
  {% assign end_mandat = person.director_end_date | date:"%Y-%m-%d" %}
    {% if date_av >= begin_mandat or begin_mandat == blank %}
      {% assign show_begin_mandat = true %}
    {% endif %}
    {% if date_av <= end_mandat or end_mandat == blank %}
      {% assign show_end_mandat = true %}
    {% endif %}
      {% if show_begin_mandat and show_end_mandat %}
          {% assign names = names | append:person.name %}
        {% if person.custom.represented_by_name != blank and type == "legal" %}
          {% assign names = names | append:" représentée par " | append:person.custom.represented_by_name %}
        {% endif %}
        {% unless forloop.last %}
          {% assign names = names | append:"|" %}
        {% endunless %}
          {% assign keys = keys | append:person.id %}
        {% unless forloop.last %}
          {% assign keys = keys | append:"|" %}
        {% endunless %}
      {% endif %}
{% endfor %}

{% assign count_zkv = 0 %}

{% for person in period.directors %}
  {% assign show_begin_mandat = false %}
  {% assign show_end_mandat = false %}
  {% assign begin_mandat = person.director_start_date | date:"%Y-%m-%d" %}
  {% assign end_mandat = person.director_end_date | date:"%Y-%m-%d" %}
    {% if date_av >= begin_mandat or begin_mandat == blank %}
      {% assign show_begin_mandat = true %}
    {% endif %}
    {% if date_av <= end_mandat or end_mandat == blank %}
      {% assign show_end_mandat = true %}
    {% endif %}
      {% if show_begin_mandat and show_end_mandat %}
        {% assign count_zkv = count_zkv | plus:1 %}
      {% endif %}
{% endfor %}

{% for person in period.shareholders %}
  {% assign count_shareh = count_shareh | plus:1 %}
{% endfor %}

{% comment %}count for kwijting{% endcomment %}

{% assign end_prev_per = period.minus_1y.end_date %}

{% assign count_kwijting = 0 %}

{% for person in period.directors %}
  {% assign show_begin_mandat = false %}
  {% assign show_end_mandat = false %}
  {% assign begin_mandat = person.director_start_date | date:"%Y-%m-%d" %}
  {% assign end_mandat = person.director_end_date | date:"%Y-%m-%d" %}
    {% if date_av >= begin_mandat or begin_mandat == blank %}
      {% assign show_begin_mandat = true %}
    {% endif %}
    {% if INT(end_prev_per) < INT(end_mandat) or end_mandat == blank %}
      {% assign show_end_mandat = true %}
    {% endif %}
      {% if show_begin_mandat and show_end_mandat %}
        {% assign count_kwijting = count_kwijting | plus:1 %}
      {% endif %}
{% endfor %}

{% if new_company_law %}

{% case company_form %}
{% when 'VZW' or 'ASBL' %}
  {% assign director_type = 'board_of_directors' %}
  {% assign shareholder_type = 'shareholders' %}
{% when 'MAATSCHAP' or 'VOF' or 'COMMV' or 'SDC' or 'SCOMM' or 'SNC' or 'SCA' or 'COMMVA' %}
{% if count_zkv == 1 %}
    {% assign director_type = 'manager' %}
  {% else %}
    {% assign director_type = 'managers' %}
  {% endif %}
    {% assign shareholder_type = 'partners' %}
{% else %}
  {% if count_zkv == 1 %}
    {% assign director_type = 'director' %}
  {% else %}
    {% if company.custom.artikels.college %}
      {% assign director_type = 'collegiate_body' %}
    {% else %}
      {% assign director_type = 'directors' %}
    {% endif %}
  {% endif %}
  {% assign shareholder_type = 'shareholders' %}
{% endcase %}

{% else %}

{% case company_form %}
{% when 'NV' or 'SA' %}
  {% assign director_type = 'bestuurders' %}
  {% assign shareholder_type = 'actionnaires' %}
{% when 'CVBA' or 'CVOA' or 'SCRL' or 'SCRI' %}
    {% if count_zkv == 1 %}
        {% assign director_type = 'bestuurder' %}
      {% else %}
        {% assign director_type = 'bestuurders' %}
     {% endif %}
  {% assign shareholder_type = 'associés' %}
{% when 'VZW' or 'ASBL' %}
  {% assign director_type = 'bestuurders' %}
  {% assign shareholder_type = 'associés' %}
{% else %}
  {% if count_zkv == 1 %}
    {% assign director_type = 'zaakvoerder' %}
  {% else %}
    {% assign director_type = 'zaakvoerders' %}
  {% endif %}
{% endcase %}

{% endif %}

{% if company.custom.notulen.office_options == blank %}
  {% if default_office_options == 1 %}
    {% if new_company_law %}
      {% assign kantoor_opties = "cabinet d’expert-comptable" %}
    {% else %}
      {% assign kantoor_opties = "cabinet d'audit" %}
    {% endif %}
  {% else %}
    {% assign kantoor_opties = "bureau de comptabilité" %}
  {% endif %}
{% else %}
  {% if company.custom.notulen.office_options == 1 %}
    {% if new_company_law %}
      {% assign kantoor_opties = "cabinet d’expert-comptable" %}
    {% else %}
      {% assign kantoor_opties = "cabinet d'audit" %}
    {% endif %}
  {% else %}
    {% assign kantoor_opties = "bureau de comptabilité" %}
  {% endif %}
{% endif %}

{% assign pluralize_stemopnemers = false %}
{% assign count_stemopnemers = 0 %}
{% for opn in period.custom.stemopnemers %}
  {% if opn.name != blank %}
    {% assign show_opn = true %}
    {% assign count_stemopnemers = count_stemopnemers+1 %}
    {% if count_stemopnemers == 2 %}
      {% assign pluralize_stemopnemers = true %}
      {% break %}
    {% endif %}
  {% endif %}
{% endfor %}

{% comment %}shareholder type var{% endcomment %}
{% if shareholder_type == 'partners' %}
  {% assign single_shareholder_type = "associé" %}
  {% assign multiple_shareholder_type = "associés" %}
{% else %}
  {% assign single_shareholder_type = "actionnaire" %}
  {% assign multiple_shareholder_type = "actionnaires" %}
{% endif %}

{% comment %}Director titles{% endcomment %}
{% if new_company_law %}
  {% case director_type %}
    {% when 'manager' %}
      {% assign single_neutral_director = "gérant(e)" %}
      {% assign multiple_neutral_director = "gérant(es)" %}
      {% assign single_neutral_preposition = "le/la" %}
      {% assign neutral_article_preposition_article = "au/à la" %}
      {% if female_director %}
        {% assign director_title_with_article = "la gérante" %}
        {% assign single_director_title = "gérante" %}   
        {% assign multiple_directors_title = "gérantes" %}
      {% else %}
        {% assign director_title_with_article = "le gérant" %}
        {% assign single_director_title = "gérant" %}
        {% assign multiple_directors_title = "gérants" %}
      {% endif %}
    {% when 'managers' %}
      {% assign multiple_neutral_director = "gérant(es)" %}
      {% assign multiple_neutral_preposition = "les" %}
      {% if female_director %}
        {% assign director_title_with_article = "les gérantes" %}
        {% assign single_director_title = "gérante" %}
        {% assign multiple_directors_title = "gérantes" %}
      {% else %}
        {% assign director_title_with_article = "les gérants" %}
        {% assign single_director_title = "gérant" %}
        {% assign multiple_directors_title = "gérants" %}
      {% endif %}
    {% else %}
      {% assign director_title_with_article = "l'organe d'administration" %}
      {% assign single_director_title = "administrateur" %}
  {% endcase %}
{% else %}
  {% case director_type %}
    {% when 'zaakvoerder' %}
      {% assign director_title_with_article = "le gérant" %}
      {% assign single_director_title = "gérant" %}
    {% when 'zaakvoerders' %}
      {% if college %}
        {% assign director_title_with_article = "le conseil d'administration" %}
        {% assign single_director_title = "administrateur" %}
      {% else %}
        {% assign director_title_with_article = "les gérants" %}
        {% assign single_director_title = "gérant" %}
      {% endif %}
    {% when 'bestuurder' %}
      {% assign director_title_with_article = "l'administrateur" %}
      {% assign single_director_title = "administrateur" %}
    {% else %}
    {% if CVBA or CVOA %}
      {% if college %}
        {% assign director_title_with_article = "le conseil d'administration" %}
        {% assign single_director_title = "administrateur" %}
      {% else %}
        {% assign director_title_with_article = "les administrateurs" %}
        {% assign single_director_title = "administrateur" %}
      {% endif %}
    {% else %}
      {% assign director_title_with_article = "le conseil d'administration" %}
      {% assign single_director_title = "administrateur" %}
    {% endif %}
  {% endcase %}
{% endif %}

When I want to see which value is to be found under var director_type with following code:

director_type var: {{ director_type }}
director_type case: {% case director_type %}{% when director %}director{% when directors %}directors{% else %}collegiate_body{% endcase %}

I get 2 different answers:

Screenshot 2021-06-06 at 23.08.52

Is there something wrong with the code or is this a liquid issue?

Thanks !

Hi @Gianluca ,

when you want to compare a local variable with a string, make sure to use quotation marks. Your case statement needs to change to:

{% case director_type %}
{% when "director" %}
  director
{% when "directors" %}
  directors
{% else %}
  collegiate_body
{% endcase %}

Kind regards,

Michiel

Hi @Michiel ,

My bad, stupid mistake. Thanks !