Clear nested fori-loops all at once

Hello,

In a template I noticed that I cannot clear the text that has been inputted for all fori-loops all at once.

Is there somehow a way to link these two fori-loops so I would be able to clear the entire text of both fori-loops? Thing is that when I would clear the building, the inputted data of “verhuurders” have no reason to stay in the template.

{% t= "REVALORISATIE COEFFICIENTEN" fr:"REVOLARISATION COEFFICIENTS" en:"REVOLARISATION COEFFICIENT" %}
{% t= "Gebouw" fr:"Bâtiment" en:"Building"%}
{% t= "Huurcontract" fr:"Contrat de location" en:"Rental agreement"%}
{% t= "Eigendoms-%" fr:"% de Propriété" en:"Ownership %"" %}
{% t= "Mandaat" fr:"Mandat" en:"Mandate" %}
{% t= "Ligging" fr:"Lieu" en:"Location" %}
{% t= "Periode" fr:"Période" en:"Period" %}
{% t= "Verhuurder" fr:"Propriétaire" en:"Renter" %}
{% t= "KI" fr:"RC" en:"CR" %}
{% t= "Beroeps-%" fr:"professionel %" en:"professional %" %}
{% t= "BeroepsKI" fr:"RC professionel" en:"professional CR" %}
{% t= "Eigendoms% verhuurder" fr:"% participation loueur" en:"% participation renter" %}
{% t= "niet geïndexeerd" fr:"pas indexé" en:"not indexed" %}
{% t= "Betaalde huur" fr:"Loyer payé" en:"Paid rent" %}
{% t= "Normale huur" fr:"Loyer normal" en:"normal rent" %}
{% t= "Te herkwalificeren" fr:"À requalifier" en:"for requalification" %}
{% t= "Herkwalificatie" fr:"Requalification" en:"Requalification" %}
{% t= "Grens" fr:"Limite" en:"Limit" %}
{% t= "verhuurder" fr:"propriétaire" en:"renter" %}
{% t= "adres verhuurder" fr:"adresse propriétaire" en:"address renter" %}
{% t= "herkwalificatie" fr:"requalification" en:"requalification" %}
{% t= "Herkwalificatie berekenen" fr:"Calculer la requalification" en:"Calculate requalification" %}
{% t= "Herkwalificatie toepassen" fr:"Appliquer la requalification" en:"Apply requalification" %}
{% t= "Geen herkwalificatie" fr:"Pas de requalification" en:"No requalification"%}
{% t= "ligging" fr:"lieu" en:"location" %}
{% t= "start datum" fr:"date début" en:"start date" %}
{% t= "eind datum" fr:"date fin" en:"end date" %}
{% t= "KI" fr:"RC" en:"CR" %}
{% t= "beroeps" fr:"professionel" en:"professional" %}
{% t= "eigendoms" fr:"participation" en:"property" %}
{% t= "value" fr:"valeur" en:"value" %}
{% t= "Deel bedrijfsleider:" fr:"Part du gérant" en:"Part of company director" %}
{% t= "Extra toelichting" fr:"Explication supplémentaire" en:"Additional explanation" %}
{% t= "Totaal" fr:"Total" en:"Total" %}
{% t= "Een aanpassing is nodig" fr:"Une adaptation est nécessaire" en:"A correction is needed" %}
{% t= "Extra detaillering m.b.t. betaalde huur" fr:"Détails supplémentaires concernant le loyer payé" en:"Additional details regarding paid rent" %}
{% capture tekst_betaalde_huur %}{% t "Extra detaillering m.b.t. betaalde huur" %}{% endcapture %}
{% t= "JA" fr:"OUI" en:"YES" %}
{% t= "NEE" fr:"NON" en:"NO" %}



{% comment %}{% t "REVALORISATIE COEFFICIENTEN" %} --- whenever a new year is added or updated, be sure to add the next year too, but with the same numbers as the year you just added/updated{% endcomment %}
{% assign rev_2018 = 4.39 %}
{% assign rev_2017 = 4.39 %}
{% assign rev_2016 = 4.31 %}
{% assign rev_2015 = 4.23 %}
{% assign rev_2014 = 4.23 %}
{% assign rev_2013 = 4.19 %}
{% assign rev_2012 = 4.10 %}
{% assign rev_2011 = 3.97 %}
{% assign rev_2010 = 3.87 %}

{% fori detail in custom.details %}{% assign $1 = 0 %}{% assign $2 = 0 %}{% assign $3 = 0 %}{% assign $4 = 0 %}{% assign $5 = 0 %}
{::group}

|------15%------|-----------70%-----------|------15%--------:+
| _**{% t "Gebouw" %}**_ | {% if detail.gebouw != blank %}**{% endif %}{% input detail.gebouw placeholder:"Straat & nr, Postcode & Gemeente" %}{% if detail.gebouw != blank %}**{% endif %}
|               |{% ifi detail.huurcontract.document != blank %}{% t "Huurcontract" %}: {% endifi %}{% input detail.huurcontract as:file %}
|
| _**{% t "Periode" %}**_ | {% input detail.start_datum as:date %} {% ifi detail.eind_datum != blank %}- {% input detail.eind_datum as:date %}{% endifi %}
|{% fori verhuurders in custom[detail.key] %}{% if forloop.first %}

|------15%------|---25%---|:---15%---:|:---10%---:|---20%---|------15%--------:+
||| _{% t "Eigendoms-%" %}_ | _{% t "Mandaat" %}_ || {% assign beroepsPCT == 0 %}
| _**{% t "Verhuurder" %}**_ {% else %}|{% endif %}|{% if $5 == 1 %}{% else %}{% input verhuurders.naam %}|{% $5+input verhuurders.eigendompct as:percentage placeholder:'0,00%'%}|{% input verhuurders.mandaat as:boolean%}{% if verhuurders.mandaat == 'true' %}{% nic %}{% t "JA" %}{% endnic %} {% else %}{% nic %}{% t "NEE" %}{% endnic %}{% endif %}{% if verhuurders.mandaat == 'true' %}{% assign beroepsPCT = beroepsPCT+verhuurders.eigendompct %}{% endif %}{% endif %}{% if forloop.last %}{% if $5 > 1 %}|**{% t "Eigendoms-%" %} > 100,00% => {% t "Een aanpassing is nodig" %}!**{% endif %}{% endif %}
{% endfori %}

|------15%------|-----------70%-------|------15%--------:+
| 
|_**{% t "Betaalde huur" %}**_ |{% ic %}{% input detail.betaalde_huur_tekst as:text placeholder:tekst_betaalde_huur size:mini %}{% endic %}{% nic %}{{detail.betaalde_huur_tekst | multiline_table}}{% endnic %}|**{% $2+input detail.betaalde_huur as:currency %}**{% assign $6 = $6+$2 %}
|{% ic %}{% t "Herkwalificatie berekenen" %} {% input detail.herkwtoep as:boolean %}
||{% endic %}

|------15%------|-----------20%----|------30%-------|---8%---:|------20%--------+{% assign beroeps_ki = beroepsPCT*detail.KI %}
|{% if detail.herkwtoep == "true" %}_**{% t "Herkwalificatie" %}**_  |{% t "KI" %} | {% input detail.KI as:currency %} ({% t "niet geïndexeerd" %}){% assign beroeps_ki = detail.KI*detail.beroeps %}
||{% t "Beroeps-%" %} | {% input detail.beroeps as:percentage size:mini placeholder:'0,00%'  %}  || 
||{% t "BeroepsKI" %}  |  {{ beroeps_ki | currency }} ({% t "niet geïndexeerd" %}){% assign aantaljaren = 0 %}
||{% for year in period.calendar_years %}{% assign start_date = MAX(year.start_date;detail.start_datum) %}{% if detail.eind_datum != blank %}{% assign end_date = MIN(year.end_date;detail.eind_datum) %}{% else %}{% assign end_date = year.end_date %}{% endif %}{% assign amount_of_days = end_date+1-start_date %}{% if amount_of_days > 0 %}{% capture revalorisatie_key %}rev_{{ year.end_date | date:'%Y' }}{% endcapture %}
||{% t "Grens" %} {% assign aantaljaren = aantaljaren | plus:1 %}{{ year.end_date | date:'%Y' }} | = {{ beroeps_ki | currency }} x 5/3 x {{ [revalorisatie_key] | currency }} x {{ amount_of_days | integer }}/{{ year.amount_of_days_in_full_year | integer}} =|{%=$1+ beroeps_ki*5/3*[revalorisatie_key]*amount_of_days/year.amount_of_days_in_full_year | round | currency %}{% endif %}{% endfor %} | {{period.calendar_years.count}} 

{% if aantaljaren > 1 %}|------15%------|-----------20%----|------30%-------:|---8%---:|------20%--------+
||| _{% t "Totaal" %}:_ | {{ $1 | currency }} | 
{% endif %}
||

{% if detail.betaalde_huur-$1 < 0  %}

|---15%---|---85%---+
|| **{% t "Geen herkwalificatie" %}** ({% t "Betaalde huur" %} < {% t "Grens" %} {% t "herkwalificatie" %})
||
||{% else %}

|------15%------|---30%---|---10%---:|---45%----+
|  | **_{% t "Te herkwalificeren" %}:_** | {% capture $4 %}{{detail.betaalde_huur*beroepsPCT-($1*beroepsPCT)}}{% endcapture %}|**{{$4 | currency}}** ([{{detail.betaalde_huur | currency}} - {{$1 | currency }}] x {{beroepsPCT | percentage}})     {% for verhuurders in custom[detail.key] %}
||{{verhuurders.naam}}|{% if verhuurders.mandaat == 'true' %}{{$4*verhuurders.eigendompct/beroepsPCT | currency}}{% else %}{% if verhuurders.naam != blank %}0,00{% endif %}{% endif %}{% endfor %}|
||
{% endif %}
{% endif %}

{:/group}

{% endfori %}

{% unexplained current_account.value-$6 %}

Hi @b.dalle,

Not really (unless you use the trashcan, but then your whole detail is gone).

The reason is that these 2 fori-loops are not really related to each other. In the best intrest of user experience, it’s my opinion that what the function you describe, is more exceptional than regular, no?

If you really want this to have it related to each other, then the only option is make it one fori-loop again:

| _**{% t "Periode" %}**_ | {% input detail.start_datum as:date %} {% ifi detail.eind_datum != blank %}- {% input detail.eind_datum as:date %}{% endifi %}
|

|------15%------|---25%---|:---15%---:|:---10%---:|---20%---|------15%--------:+
||| _{% t "Eigendoms-%" %}_ | _{% t "Mandaat" %}_ ||&nbsp;{% assign beroepsPCT == 0 %}{% assign count = 0 %}
| _**{% t "Verhuurder" %}**_ |{% if $5 == 1 %}{% else %}{% input detail.verhuurders_naam_1 %}|{% $5+input detail.verhuurders_eigendompct_1 as:percentage placeholder:'0,00%'%}|{% input detail.verhuurders_mandaat_1 as:boolean%}{% if verhuurders.mandaat == 'true' %}{% nic %}{% t "JA" %}{% endnic %} {% else %}{% nic %}{% t "NEE" %}{% endnic %}{% endif %}{% if verhuurders.mandaat == 'true' %}{% assign beroepsPCT = beroepsPCT+verhuurders.eigendompct %}{% endif %}{% endif %}{% if $5 > 1 %}|**{% t "Eigendoms-%" %} > 100,00% => {% t "Een aanpassing is nodig" %}!**{% endif %}{% if detail.verhuurders_naam_1 != blank %}
| _**{% t "Verhuurder" %}**_ |{% if $5 == 1 %}{% else %}{% input detail.verhuurders_naam_2 %}|{% $5+input detail.verhuurders_eigendompct_2 as:percentage placeholder:'0,00%'%}|{% input detail.verhuurders_mandaat as:boolean%}{% if verhuurders.mandaat == 'true' %}{% nic %}{% t "JA" %}{% endnic %} {% else %}{% nic %}{% t "NEE" %}{% endnic %}{% endif %}{% if verhuurders.mandaat == 'true' %}{% assign beroepsPCT = beroepsPCT+verhuurders.eigendompct %}{% endif %}{% endif %}{% if $5 > 1 %}|**{% t "Eigendoms-%" %} > 100,00% => {% t "Een aanpassing is nodig" %}!**{% endif %}{% endif %}

But in my opinion this code is not that sufficient, so is it really important that it’s all linked? Because you could use the trashcan instead, no?

Hi @sven,

I was just a though to get a better ease of use. If the full detail has been inputted (for instance 2 buildings) and I would want to delete the detail of one building, it would be nice if I could do it with one click on a trachcan. After all the second fori-loop (“Verhuurders”) is a subpart of the first fori-loop.

So it would be handy, but not really necessary. Thanks your your input!

No problem @b.dalle ! Glad to help you out, and good luck with the rest of the templates. You know where to find us :relaxed: