Copy input text with boolean

Hi,

I’m trying to make a template where you could put in the professional loans and the private loans. So far no issue.
But, when a loan is partly proffesional and partly private, I don’t want to put in the same informatie two times. I had the idea, it may be possible to put in a boolean next to the professional loans, and whenever this boolean is marked, the inputed information is copied to bollow the prive loans.

Anybody who could help me out?

| Datum    | Duur   |   Bank  | Geleend        | Afgelost boekjaar                              | Saldo op         
|          |        | Omschrijving                | bedrag         |  {{ period.year_start_date | date:'%d/%m/%Y' }} - {{ period.year_end_date | date:'%d/%m/%Y' }}   | {{ period.year_end_date | date:'%d/%m/%Y' }}
|          |        |                             |                | waarvan                                       | 



|:--10%----|:--5%---|:--------25%-----------|-----10%------:|:------15%----:|:---15%-------:|---20%------:+
|          |        |                       |               |  kapitaal      | intresten      |           |
|_        _|_      _|_                     _|_             _|_              _|_              _|_         _|

{% for beroepslening in custom.leningen %}
  {% assign beroepsbedrag = beroepslening.value %}
{% endfor %}
{% ifi beroepsbedrag > 0 %}
| {% nic %}**<font color="ffffff">{% endnic %} Beroepsleningen {% nic %}</font>**{% endnic %}
|----+BF4E4A


{% fori beroepslening in custom.leningen %}{% if forloop.first %}
|:--10%---|:--5%--|:--------25%-----------|-----10%------:|------15%----:|---15%-------:|---20%------:+{% endif %}
{% stripnewlines %}
  | {% input beroepslening.datum as:date %} 
  | {% input beroepslening.duur %} 
  | {% input beroepslening.doc as:file %}
  | {% $1+input beroepslening.value as:currency %}
  | {% $2+input beroepslening.kapitaal as:currency %}
  | {% $3+input beroepslening.intresten as:currency %}
  | {% $4+input beroepslening.less_than_1y as:currency %}
{% endstripnewlines %}
|   | | {% input beroepslening.bank %} 
|    |   |  {% input beroepslening.omschrijving %}    |     |      |          | 
|_  _|_ _|_ {% input beroepslening.info placeholder:"" %} _|_  _|_     _|_     _|_{% endfori %}
|   | | **TOTAAL** | {{ $1 | currency }}| {{ $2 | currency }} {% result 'Totaalkapberoep' $2 %}| {{ $3 | currency }}| {{ $4 | currency }}
|_        _|_      _|_                     _|_             _|_              _|_              _|_         _|
{% endifi %}

{% for privaatlening in custop.privaatleningen %}
  {% assign privaatbedrag = privaatlening.value %}
{% endfor %}

{% ifi privaatbedrag > 0 %}

| {% nic %}**<font color="ffffff">{% endnic %} Private leningen {% nic %}</font>**{% endnic %}
|----+BF4E4A
{% endifi %}

{% fori privaatlening in custom.privaatleningen %}{% if forloop.first %}
|:--10%---|:--5%--|:--------25%-----------|-----10%------:|------15%----:|---15%-------:|---20%------:+{% endif %}
{% stripnewlines %}
  | {% input privaatlening.datum as:date %} 
  | {% input privaatlening.duur %} 
  | {% input privaatlening.doc as:file %}
  | {% $11+input privaatlening.value as:currency %}
  | {% $12+input privaatlening.kapitaal as:currency %}
  | {% $13+input privaatlening.intresten as:currency %}
  | {% $14+input privaatlening.less_than_1y as:currency %}
{% endstripnewlines %}
|   | | {% input privaatlening.bank %} 
|    |   |  {% input privaatlening.omschrijving %}    |     |      |          | 
|_  _|_ _|_ {% input privaatlening.info placeholder:"" %} _|_  _|_     _|_     _|_{% endfori %}
|   | | **TOTAAL** | {{ $11 | currency }}| {{ $12 | currency }} {% result 'Totaalkapprivaat' $12 %}| {{ $13 | currency }}{% result 'Totaalintrestprivaat' $13 %}| {{ $14 | currency }}

Hi @Cedric ,

If my understanding is correct, you would like something like this:

| Datum | Duur | Bank | Geleend | Afgelost boekjaar | Saldo op
| | | Omschrijving | bedrag | {{ period.year_start_date | date:‘%d/%m/%Y’ }} - {{ period.year_end_date | date:‘%d/%m/%Y’ }} | {{ period.year_end_date | date:‘%d/%m/%Y’ }}
| | | | | waarvan |

|:–10%----|:–5%—|:--------25%-----------|-----10%------:|:------15%----:|:—15%-------:|—20%------:+
| | | | | kapitaal | intresten | |
|_ | | | | | | _|

{% for beroepslening in custom.leningen %}
{% assign beroepsbedrag = beroepslening.value %}
{% endfor %}
{% ifi beroepsbedrag > 0 %}
| {% nic %}{% endnic %} Beroepsleningen {% nic %}{% endnic %}
|----+BF4E4A

{% fori beroepslening in custom.leningen %}{% if forloop.first %}
|:–10%—|:–5%–|:--------25%-----------|-----10%------:|------15%----:|—15%-------:|—20%------:+{% endif %}
{% stripnewlines %}
| {% input beroepslening.datum as:date %}
| {% input beroepslening.duur %}
| {% input beroepslening.doc as:file %} {% input beroepslening.copy as:boolean default:false %}
| {% $1+input beroepslening.value as:currency %}
| {% $2+input beroepslening.kapitaal as:currency %}
| {% $3+input beroepslening.intresten as:currency %}
| {% $4+input beroepslening.less_than_1y as:currency %}
{% endstripnewlines %}
| | | {% input beroepslening.bank %}
| | | {% input beroepslening.omschrijving %} | | | |
|_ | | {% input beroepslening.info placeholder:“” %} | | | |{% endfori %}
| | | TOTAAL | {{ $1 | currency }}| {{ $2 | currency }} {% result ‘Totaalkapberoep’ $2 %}| {{ $3 | currency }}| {{ $4 | currency }}
|_ | | | | | | _|
{% endifi %}

{% for beroepslening in custom.leningen %}{% assign copy_details = beroepslening.copy | default:false %}{% assign beroepslening_datum = beroepslening.datum %}{% assign beroepslening_duur = beroepslening.duur %}{% endfor %}

{% for privaatlening in custop.privaatleningen %}
{% assign privaatbedrag = privaatlening.value %}
{% endfor %}

{% ifi privaatbedrag > 0 %}

| {% nic %}{% endnic %} Private leningen {% nic %}{% endnic %}
|----+BF4E4A
{% endifi %}

{% fori privaatlening in custom.privaatleningen %}{% if forloop.first %}
|:–10%—|:–5%–|:--------25%-----------|-----10%------:|------15%----:|—15%-------:|—20%------:+{% endif %}
{% stripnewlines %}
{% if copy_details == true %}{% assign beroepslening_datum_def = beroepslening_datum %}{% assign beroepslening_duur_def = beroepslening_duur %}{% endif %}
| {% input privaatlening.datum as:date default:beroepslening_datum_def %}
| {% input privaatlening.duur default:beroepslening_duur_def %}
| {% input privaatlening.doc as:file %}
| {% $11+input privaatlening.value as:currency %}
| {% $12+input privaatlening.kapitaal as:currency %}
| {% $13+input privaatlening.intresten as:currency %}
| {% $14+input privaatlening.less_than_1y as:currency %}
{% endstripnewlines %}
| | | {% input privaatlening.bank %}
| | | {% input privaatlening.omschrijving %} | | | |
|_ | | {% input privaatlening.info placeholder:“” %} | | | |{% assign beroepslening_datum = “” %}{% assign beroepslening_duur = “” %}{% endfori %}
| | | TOTAAL | {{ $11 | currency }}| {{ $12 | currency }} {% result ‘Totaalkapprivaat’ $12 %}| {{ $13 | currency }}{% result ‘Totaalintrestprivaat’ $13 %}| {{ $14 | currency }}

I have added a boolean next to the beroepslening.doc input field. When this boolean is checked, the value for ‘datum’ and ‘duur’ are filled in by the values of beroepslening.datum and beroepslening.duur by default (in the inputfields privaatlening.datum and privaatlening.duur).

So far, I have only completed the code for ‘datum’ and ‘duur’.

Hope this is the information need to complete your template!

In case you have additional questions, please do no hesitate to contact us.

Kind regards,
Robin

@robindeclercq Thanks for the information.

I tried to use it, but it only works if you check only one boolean, so if you have two loans who are partly professional and private, it doesn’t work…
Any idea how to solve it?

Second issue I have with this, when ‘datum’ and ‘duur’ are filled by the values of the private loans, you still have to fill something in to have a second line, to add another loan, seems not that handy…

Hi @Cedric,

Taking into your account your remarks, I have amended the liquid code a bit.

For starters, I have created an additional table under the ‘Private leningen’ header which loops through the ‘Beroepsleningen’ table (by means of a for-loop). In case the boolean is checked, the values of the beroepsleningen table are copied.

Thereafter, there is still the fori-loop for the 100% private loans.

Please find the code hereafter:

| Datum    | Duur   |   Bank  | Geleend        | Afgelost boekjaar                              | Saldo op         
|          |        | Omschrijving                | bedrag         |  {{ period.year_start_date | date:'%d/%m/%Y' }} - {{ period.year_end_date | date:'%d/%m/%Y' }}   | {{ period.year_end_date | date:'%d/%m/%Y' }}
|          |        |                             |                | waarvan                                       | 

|:--10%----|:--5%---|:--------25%-----------|-----10%------:|:------15%----:|:---15%-------:|---20%------:+
|          |        |                       |               |  kapitaal      | intresten      |           |
|_        _|_      _|_                     _|_             _|_              _|_              _|_         _|

{% for beroepslening in custom.leningen %}
  {% assign beroepsbedrag = beroepslening.value %}
{% endfor %}
{% ifi beroepsbedrag > 0 %}
| {% nic %}**<font color="ffffff">{% endnic %} Beroepsleningen {% nic %}</font>**{% endnic %}
|----+BF4E4A

{% fori beroepslening in custom.leningen %}{% if forloop.first %}
|:--10%---|:--5%--|:--------25%-----------|-----10%------:|------15%----:|---15%-------:|---20%------:+{% endif %}
{% stripnewlines %}
| {% input beroepslening.datum as:date %} 
| {% input beroepslening.duur %} 
| {% input beroepslening.doc as:file %} {% input beroepslening.copy as:boolean default:false %} {% assign copy_details = beroepslening.copy | default:false %}
| {% $1+input beroepslening.value as:currency %}
| {% $2+input beroepslening.kapitaal as:currency %}
| {% $3+input beroepslening.intresten as:currency %}
| {% $4+input beroepslening.less_than_1y as:currency %}
{% endstripnewlines %}
|   | | {% input beroepslening.bank %} 
|    |   |  {% input beroepslening.omschrijving %}    |     |      |          | 
|_  _|_ _|_ {% input beroepslening.info placeholder:"" %} _|_  _|_     _|_     _|_{% endfori %}
|   | | **TOTAAL** | {{ $1 | currency }}| {{ $2 | currency }} {% result 'Totaalkapberoep' $2 %}| {{ $3 | currency }}| {{ $4 | currency }}
|_        _|_      _|_                     _|_             _|_              _|_              _|_         _|
{% endifi %}

{% for privaatlening in custop.privaatleningen %}
 {% assign privaatbedrag = privaatlening.value %}
{% endfor %}

{% ifi privaatbedrag > 0 %}

| {% nic %}**<font color="ffffff">{% endnic %} Private leningen {% nic %}</font>**{% endnic %}
|----+BF4E4A
{% endifi %}

{% stripnewlines %}
|:--10%---|:--5%--|:--------25%-----------|-----10%------:|------15%----:|---15%-------:|---20%------:+ {% for beroepslening in custom.leningen %}{% newline %}{% if beroepslening.copy == true %}
| {% input beroepslening.datum as:date %} 
| {% input beroepslening.duur  %} 
| {% input beroepslening.doc as:file %}
| {% $11+input beroepslening.value as:currency %}
| {% $12+input beroepslening.kapitaal as:currency %}
| {% $13+input beroepslening.intresten as:currency %}
| {% $14+input beroepslening.less_than_1y as:currency %}{% newline %}
|   | | {% input beroepslening.bank %}{% newline %}
|    |   |  {% input beroepslening.omschrijving %}    |     |      |          | {% newline %}
|_  _|_ _|_ {% input beroepslening.info placeholder:"" %} _|_  _|_     _|_     _|_
{% endif %}
{% endfor %}
{% endstripnewlines %}

{% stripnewlines %}
|:--10%---|:--5%--|:--------25%-----------|-----10%------:|------15%----:|---15%-------:|---20%------:+ {% fori privaatlening in custom.privaatleningen %}{% newline %}
| {% input privaatlening.datum as:date default:beroepslening_datum_def %} 
| {% input privaatlening.duur default:beroepslening_duur_def  %} 
| {% input privaatlening.doc as:file %}
| {% $11+input privaatlening.value as:currency %}
| {% $12+input privaatlening.kapitaal as:currency %}
| {% $13+input privaatlening.intresten as:currency %}
| {% $14+input privaatlening.less_than_1y as:currency %}{% newline %}
|   | | {% input privaatlening.bank %} {% newline %}
|    |   |  {% input privaatlening.omschrijving %}    |     |      |          | {% newline %}
|_  _|_ _|_ {% input privaatlening.info placeholder:"" %} _|_  _|_     _|_     _|_{% endfori %}{% endstripnewlines %}
|   | | **TOTAAL** | {{ $11 | currency }}| {{ $12 | currency }} {% result 'Totaalkapprivaat' $12 %}| {{ $13 | currency }}{% result 'Totaalintrestprivaat' $13 %}| {{ $14 | currency }}

Hope this is clear for you!

Don’t hesitate to contact us in case of additional questions.

Kind regards,
Robin

Thanks @robindeclercq.

Template works perfectly the way I needed!