The thing that I would do, is to create an additional reconciliation template that can then be used for all kinds of queries. Because the amount of shareholders, can be accessed in any template by doing this:
{{ period.shareholders.count }}
but you cannot access that directly in Insights. So a workaround is needed, where you create a specific template (or add the code in another template, as what we’ll do is in the background anyway so no user will ever notice it), and then take that value into a result-tag:
{% comment %}value shareholders needed for SF INSIGHTS{% endcomment %}
{% result 'amount_shareholders' period.shareholders.count %}
That way, you can access that result tag with the filter “Reconciliation data”.
Can I also filter on shareholders who are natural persons?
In some cases, all of the shareholders are legal persons, f.e. in holding companies. I don’t want those companies in my result.
Yes, but then you need to loop over all shareholders where the type is set on “natural” (more info here how those database vars are called)
In each loop, you can then do this eg:
{% for person in period.people %}
{% comment %}check what type has been set in BEDRIJFSPARAMETERS by the db var "person.custom.type"{% endcomment %}
{% if person.custom.represented_by_name != blank %}
{% assign default_type = "legal" %}
{% else %}
{% assign default_type = "nature" %}
{% endif %}
{% assign type = person.custom.type | default:default_type %}
{% if type != "legal" and person.shareholder == true %}
{% assign count_nat_shareholders = count_nat_shareholders | plus:1 %}
{% endif %}
{% endfor %}
The dropdown for type of person (legal or not) is with a default. So even if you see “legal” selected, that can mean the database variable can be in fact empty.