Shareholer automatic completion

Hi!

I’d like to have an automatic system where the possible shareholders appear (some kind of boolean maybe) and depending on the name that is selected, the name and number of shares of the selected person should be completed automatically (if multiple shareholders selected, the text should be unavailable). I already spent hours and hours on this, but can’t seem to figure it out. Do you have any advice?

{% comment %}Aandeelhouders{% endcomment %}
{% ic %}
{::infotext}
Kies de betreffende aandeelhouder:
{% for shareholder in period.shareholders %}
{% capture name_id %}{{ shareholder.name | replace: ‘.’,’’ | replace: ’ ‘,’’ | remove:’-’}}{% endcapture %}
{% ic %}{% input period.custom.[name_id].shareholder as:boolean default:true %}{% endic %}{% assign name_shareholder = period.custom.[name_id].shareholder | default:true %}{% if name_shareholder %}{% nic %}{% endnic %} {{ shareholder.name }}{% else %}{% assign not_all_present = true %}{% ic %}{{ name }}*{% endic %}{% capture not_present_var %}no shareholders in Silverfin{{ forloop.index }}{% endcapture %}{% capture [not_present_var] %}{{ name }}{% endcapture %}{% endif %}
{% endfor %}
{:/infotext}
{% endic %}

Ondergetekende {{ shareholder.name }}, houder van {{ shareholder.amount_of_shares }} aandelen van de {{ full_company_form | strip }} "{{ company.name | strip }}”, met zetel te {{ company.street | strip }}, {{ company.city | strip }}, {{ company.country | strip }}, ingeschreven in het {{ rpr_naam }} onder nummer {{company.vat_identifier | strip}},

@lieels01

Please find below the code, which displays the list of all shareholders with options to select (enable).

For selected shareholders the following information will be displayed:

  • Full name
  • Number of shares
  • Nature of shares
  • Class of shares (if applicable)
  • Number of votes (if applicable)

Please take a look and let me know if you need help to adjust the code for your cases.

Kind regards,
Jelena

{% stripnewlines %}
{% for shareholder in period.shareholders %}
  {% if shareholder.persisted %}

    {% comment %}Assigning the type of the shareholder - "legal" or "nature"{% endcomment %}
    {% assign default_type = "" %}
    {% if shareholder.custom.represented_by_name != blank %}
      {% assign default_type = "legal" %}
    {% else %}
      {% assign default_type = "nature" %}
    {% endif %}
    {% assign type = shareholder.custom.type | default:default_type %}
    
    {% if type == "nature" %}
      {% assign words = shareholder.name | split: ' ' %}
      {% assign lastname = "" %}
      {% assign shareholder_first_name = "" %}
      {% for word in words %}
        {% if forloop.last %} {% comment %}correct for syncs like adminis{% endcomment %}
          {% assign shareholder_first_name = word %}
        {% else %}
          {% assign lastname = lastname | append:" " | append:word %}
        {% endif %}
      {% endfor %}
      {% capture shareholder_last_name %}{{ lastname | strip }}{% endcapture %}
      {% assign first_name = shareholder.custom.first_name | default:shareholder_first_name %}
      {% assign last_name = shareholder.custom.last_name | default:shareholder_last_name %}
      {% capture full_name %}{{ first_name }} {{ last_name }}{% endcapture %}
    {% else %}
      {% capture full_name %}{{ shareholder.name }}{% endcapture %}
    {% endif %}
  
    {% capture display %}display_{{ shareholder.id }}{% endcapture %}
    {% ic %}{% input custom.[display].to_display as:boolean %}{% endic %}
    {% if custom.[display].to_display != true  %}
      {% ic %}*Enable {{ full_name }}*{% newline %}{% endic %}
    {% else %}
      
      {{ full_name }}{% newline %}
      
      **{% t "Number of shares" %}**	{{ shareholder.amount_of_shares | integer }}{% newline %}
      
      {% assign stock_type_from_sync = shareholder.custom.stock_type %}
      {% assign def_stock_type = "" %}
      {% case stock_type_from_sync %}
      {% when 1 %}
        {% assign def_stock_type = "Full ownership" %}
      {% when 2 %}
        {% assign def_stock_type = "Bare ownership" %}
      {% when 3 %}
        {% assign def_stock_type = "Usufruct" %}
      {% when 4 %}
        {% assign def_stock_type = "Indivisibility" %}
      {% endcase %}
    
      {% assign kind_of_shares = shareholder.custom.kind_of_shares | default:def_stock_type %}
       **{% t "Nature of shares" %}** {{ kind_of_shares }}{% newline %}
    
      {% if shareholder.custom.shares_classes != blank %}
        **{% t "Class of shares" %}** {{ shareholder.custom.shares_classes }}{% newline %}
      {% endif %}
    
      {% if shareholder.amount_of_votes != blank %}
        **{% t "Number of votes" %}** {{ shareholder.amount_of_votes }}{% newline %}
      {% endif %}
  
      <br/>
    {% endif %}
  {% endif %}
{% endfor %}
{% endstripnewlines %}

Hi @Jelena_Sutova

This is amaziing :slight_smile:
I have one additional question: I’d like to have the result with the names of shareholders in a dropdown instead of a boolean. Is this somehow possible?

So instead of {% input custom.[display].to_display as:boolean%}

I’d need to use something like this, so the question is how do I et the actual names from the shareholders in the dropdown menu?
{% input custom.[display].to_display as:select options:"name | replace: ‘.’,’’ | replace: ’ ‘,’’ | remove:’-’ " %}

@lieels01

I have updated the code:

Part 1: Creating the list of shareholders
In this part - a list of shareholders is created: names and ids.

Part 2: Selecting shareholder from dropdown

Part 3: Display of data for selected shareholder
Displaying data for selected shareholder based on id.

Please let us know if this works for your case.

{% comment %}Part 1: Creating the list of shareholders{% endcomment %}
{% for shareholder in period.shareholders %}
  {% if shareholder.persisted %}

    {% comment %}Assigning the type of the shareholder - "legal" or "nature"{% endcomment %}
    {% assign default_type = "" %}
    {% if shareholder.custom.represented_by_name != blank %}
      {% assign default_type = "legal" %}
    {% else %}
      {% assign default_type = "nature" %}
    {% endif %}
    {% assign type = shareholder.custom.type | default:default_type %}
    
    {% if type == "nature" %}
      {% assign words = shareholder.name | split: ' ' %}
      {% assign lastname = "" %}
      {% assign shareholder_first_name = "" %}
      {% for word in words %}
        {% if forloop.last %} {% comment %}correct for syncs like adminis{% endcomment %}
          {% assign shareholder_first_name = word %}
        {% else %}
          {% assign lastname = lastname | append:" " | append:word %}
        {% endif %}
      {% endfor %}
      {% capture shareholder_last_name %}{{ lastname | strip }}{% endcapture %}
      {% assign first_name = shareholder.custom.first_name | default:shareholder_first_name %}
      {% assign last_name = shareholder.custom.last_name | default:shareholder_last_name %}
      {% capture full_name %}{{ first_name }} {{ last_name }}{% endcapture %}
    {% else %}
      {% capture full_name %}{{ shareholder.name }}{% endcapture %}
    {% endif %}
  
    {% comment %}Creating list of shareholders to display in dropdown{% endcomment %}
    {% assign shareholders_options = shareholders_options | append:full_name | append:"|" %}
    {% assign shareholders_option_values = shareholders_option_values | append:shareholder.id | append:"|" %}
  
  {% endif %}
{% endfor %}




{% comment %}Part 2: Selecting shareholder from dropdown{% endcomment %}
{% input custom.shareholders_option.to_select as:select options:shareholders_options option_values:shareholders_option_values %}

{% comment %}Part 3: Display of data for selected shareholder{% endcomment %}

{% if custom.shareholders_option.to_select != blank %}
  {% stripnewlines %}
  {% for shareholder in period.shareholders %}
    {% if shareholder.persisted %}
        {% if shareholder.id == custom.shareholders_option.to_select %}
  
          **{% t "Number of shares" %}**	{{ shareholder.amount_of_shares | integer }}{% newline %}
          
          {% assign stock_type_from_sync = shareholder.custom.stock_type %}
          {% assign def_stock_type = "" %}
          {% case stock_type_from_sync %}
          {% when 1 %}
            {% assign def_stock_type = "Full ownership" %}
          {% when 2 %}
            {% assign def_stock_type = "Bare ownership" %}
          {% when 3 %}
            {% assign def_stock_type = "Usufruct" %}
          {% when 4 %}
            {% assign def_stock_type = "Indivisibility" %}
          {% endcase %}
        
          {% assign kind_of_shares = shareholder.custom.kind_of_shares | default:def_stock_type %}
           **{% t "Nature of shares" %}** {{ kind_of_shares }}{% newline %}
        
          {% if shareholder.custom.shares_classes != blank %}
            **{% t "Class of shares" %}** {{ shareholder.custom.shares_classes }}{% newline %}
          {% endif %}
        
          {% if shareholder.amount_of_votes != blank %}
            **{% t "Number of votes" %}** {{ shareholder.amount_of_votes }}{% newline %}
          {% endif %}
        
      {% endif %}
    {% endif %}
  {% endfor %}
  {% endstripnewlines %}
{% endif %}

Hi @Jelena_Sutova

This is perfect! thank you so much :slight_smile: