Loan - date expired - don't show

Hi everyone,

in the code underneath I made an overview of the loans of the client.
If a loan has expired (detail.custom.einddatum) in the current year, it should not be shown anymore in my overview next year in the printed version of the template.
In the workversion of the template - we would like to keep the history of the loans - so there it should still be shown.
I was thinking about using if and ic, but I can’t figure out which is the right way to do it.
Can someone help me?

´´´

->Kredieten<-


{% stripnewlines %}
{% fori detail in custom.details %}

{% if forloop.first %}
| {% t “Doel lening” %}
| {% t “Bank” %}
| {% t “Contractnummer” %}
| {% t “Begindatum” %}
| {% t “Einddatum” %}
| {% t “Totaal kapitaalbedrag”%}
| {% t “Reeds afgelost”%}
| {% t “Aflossing huidig jaar”%}
| {% t “Resterend kapitaal”%}
| {% t “Intrest huidig jaar” %}
| {% t “Beroeps%” %}
| {% t “Beroepsmatige intrest” %}
{% ic %}| {% t “Privé intrest” %}{% endic %}
{% ic %}| {% t “Aflossingstabel” %}{% endic %}
{% newline %}
|:----------10%-----------:
|:---------10%------:
|:—10%—:
|:—10%—:
|:—10%—:
|—10%—:
|—10%—:
|—10%—:
|—10%—:
|—10%—:
|----10%----:
|–5%–:
|–10%–:
|----10%–:+#
{% endif %}

{% newline %}

| {% input detail.custom.doel lening %}
| {% input detail.custom.bank %}
| {% input detail.custom.contractnummer %}{% assign contractnummer = detail.custom.contractnummer %}{% result ‘contractnummer’ contractnummer %}
| {% input detail.custom.begindatum | date: “%d/%m/%Y”%}{% assign begindatum = detail.custom.begindatum | date: “%d/%m/%Y” %}
| {% input detail.custom.einddatum | date: “%d/%m/%Y” %}
| {% $3+input detail.custom.totaal_kapitaalbedrag as:currency%}
| {% $4+input detail.custom.reeds_afgelost as:currency%}
| {% $5+input detail.custom.aflossing_huidig_jaar as:currency %}

{% rollforward detail.custom.reeds_afgelost+detail.custom.aflossing_huidig_jaar detail.custom.reeds_afgelost %}
{% rollforward nil detail.custom.aflossing_huidig_jaar %}

| {%=$1+ detail.custom.totaal_kapitaalbedrag-detail.custom.reeds_afgelost-detail.custom.aflossing_huidig_jaar %}
| {% $7+input detail.custom.totale_intrest as:currency %}
{% rollforward nil detail.custom.totale_intrest %}
| {% input detail.custom.beroeps as:percentage %}
| {%=$0+ detail.custom.totale_intrestdetail.custom.beroeps %}{% assign beroepsintresten = detail.custom.totale_intrestdetail.custom.beroeps %}
| {%=$2+ detail.custom.totale_intrest-beroepsintresten %}
| {% input detail.custom.bijlage as:file %}

{% if forloop.last %}
{% newline %}
|
|
|
|
|
|{{ $3 | abs | currency }}
|{{ $4 | abs | currency }}
|{{ $5 | abs | currency }}
|{{ $1 | abs | currency }}
|{{ $7 | abs | currency }}

|
**|{{ $0 | abs | currency }}{% if ABS(#650000-$0) < 0.01 %}{% unreconciled 0 as:indicator %}{% else %}{% unreconciled #650000-$0 as:indicator %}{% endif %}
|{{ $2 | abs | currency }}
|
{% endif %}
{% if detail.custom.begindatum >= period.year_start_date and detail.custom.begindatum <= period.year_end_date %}
{% $6+ detail.custom.totaal_kapitaalbedrag %}
{% endif %}

{% endfori %}
{% endstripnewlines %}

{% result ‘priveintresten’ $2 %}
{% result ‘totaalkapitaal’ $3 %}
{% result ‘afgelost’ $4 %}
{% result ‘huidige’ $5 %}
{% result ‘nieuwelening’ $6 %}


->Banksaldo’s<-


{% stripnewlines %}
{% fori bank in custom.bank_saldo %}

{% if forloop.first %}
| {% t “Rekeningnummer” %}
| {% t “Bank” %}
| {% t "Saldo per " %}{{ period.minus_2y.year_end_date | date: “%d/%m/%Y”}}
| {% t "Saldo per " %}{{ period.minus_1y.year_end_date | date: “%d/%m/%Y”}}
| {% t "Saldo per " %}{{ period.year_end_date | date: “%d/%m/%Y”}}
{% newline %}
|:----------20%-----------:
|:---------20%------:
|:—20%—:
|:—20%—:
|:—20%—:#

{% endif %}

{% newline %}
| {% input bank.rekeningnummer %}
| {% input bank.kredietinstelling %}
| {% input bank.saldoy2 placeholder:“Saldo Y-2” as:currency %}{% assign saldoy2 = bank.saldoy2 %}
| {% $8+input bank.saldoy1 placeholder:“Saldo Y-1” as:currency %}{% result ‘beginsaldo’ $8 %}
| {% $9+input bank.saldoy placeholder:“Saldo Y” as:currency %}{% result ‘eindsaldo’ $9 %}
{% rollforward bank.saldoy1 bank.saldoy2 %}
{% rollforward bank.saldoy bank.saldoy1 %}
{% rollforward nil bank.saldoy %}

{% if forloop.last %}
{% newline %}
|
|
|
| {{ $8 }}
|{{ $9 }}
{% endif %}
{% endfori %}
{% endstripnewlines %}´´´

Hi Lise

The best tag to use in this case is an ifi-statement, a condition inside an ifi-statement will only be looked at in export mode and in input view it will always be true.

So I think this should help you further:

{% assign end_date = period.end_date | date: "%Y/%m/%d" %}
{% assign loan_end_date = detail.custom.einddatum | date: "%Y/%m/%d" %}

{% ifi loan_end_date > end_date %}
 *content*
{% endifi %}

You’ll also need to define your date inputs in the following way to ensure that the user will always add a date in a format you can use:

{% input detail.custom.einddatum as:date %}

Kind regards
Wouter

Hi Wouter,

Thx for your reply!
This already helps a bit - I get all the loans in the input view.

But in the export view I get no loans at all, while the expected behavior is that he will show the loans that are not expired yet.
Any idea how I can make this apart for every loan that gets filled in?

Greetings,
Lise

This code should work, so I think something might be going wrong in the placement or condition of the ifi-statement.

This is the code I used to test it :

->{::font size='l'}**Kredieten**{:/font}<-

{% assign end_date = period.end_date | date: "%Y/%m/%d" %}

{% stripnewlines %}
{% fori detail in custom.details %}
{% assign loan_end_date = detail.custom.einddatum | date: "%Y/%m/%d" %}

{% if forloop.first %}
| {% t "Doel lening" %}
| {% t "Bank" %}
| {% t "Contractnummer" %}
| {% t "Begindatum" %}
| {% t "Einddatum" %}
| {% t "Totaal kapitaalbedrag"%}
| {% t "Reeds afgelost"%}
| {% t "Aflossing huidig jaar"%}
| {% t "Resterend kapitaal"%}
| {% t "Intrest huidig jaar" %}
| {% t "Beroeps%" %}
| {% t "Beroepsmatige intrest" %}
{% ic %}| {% t "Privé intrest" %}{% endic %}
{% ic %}| {% t "Aflossingstabel" %}{% endic %}
{% newline %}
|:---10%-----:
|:---10%-----:
|:---10%-----:
|:---10%-----:
|:---10%-----:
|----10%-----:
|----10%-----:
|----10%-----:
|----10%-----:
|----10%-----:
|----10%-----:
|----5%------:
|----10%-----:
|------------:+
{% endif %}
{% ifi loan_end_date > end_date %}
{% newline %}
| {% input detail.custom.doel lening %}
| {% input detail.custom.bank %}
| {% input detail.custom.contractnummer %}{% assign contractnummer =     detail.custom.contractnummer %}{% result "contractnummer" contractnummer %}
| {% input detail.custom.begindatum | date: "%d/%m/%Y"%}{% assign begindatum =     detail.custom.begindatum | date: "%d/%m/%Y" %}
| {% input detail.custom.einddatum | date: "%d/%m/%Y" %}
| {% $3+input detail.custom.totaal_kapitaalbedrag as:currency%}
| {% $4+input detail.custom.reeds_afgelost as:currency%}
| {% $5+input detail.custom.aflossing_huidig_jaar as:currency %}

{% rollforward detail.custom.reeds_afgelost+detail.custom.aflossing_huidig_jaar detail.custom.reeds_afgelost %}
{% rollforward nil detail.custom.aflossing_huidig_jaar %}

| {%=$1+ detail.custom.totaal_kapitaalbedrag-detail.custom.reeds_afgelost-    detail.custom.aflossing_huidig_jaar %}
| {% $7+input detail.custom.totale_intrest as:currency %}
{% rollforward nil detail.custom.totale_intrest %}
| {% input detail.custom.beroeps as:percentage %}
| {%=$0+ detail.custom.totale_intrestdetail %}{% assign beroepsintresten = detail.custom.totale_intrestdetail %}
| {%=$2+ detail.custom.totale_intrest-beroepsintresten %}
| {% input detail.custom.bijlage as:file %}
{% endifi %}
{% if forloop.last %}
{% newline %}
|
|
|
|
|
|{% ifi $3 != 0 %}{{ $3 | abs | currency }}{% endifi %}
|{% ifi $4 != 0 %}{{ $4 | abs | currency }}{% endifi %}
|{% ifi $5 != 0 %}{{ $5 | abs | currency }}{% endifi %}
|{% ifi $1 != 0 %}{{ $1 | abs | currency }}{% endifi %}
|{% ifi $7 != 0 %}{{ $7 | abs | currency }}{% endifi %}
|
**|{{ $0 | abs | currency }}{% if ABS(#650000-$0) < 0.01 %}{% unreconciled 0 as:indicator %}{% else %}{% unreconciled #650000-$0 as:indicator %}{% endif %}
|{{ $2 | abs | currency }}
|
{% endif %}
{% if detail.custom.begindatum >= period.year_start_date and detail.custom.begindatum <= period.year_end_date %}
{% $6+ detail.custom.totaal_kapitaalbedrag %}
{% endif %}
{% endfori %}
{% endstripnewlines %}

{% result "priveintresten" $2 %}
{% result "totaalkapitaal" $3 %}
{% result "afgelost" $4 %}
{% result "huidige" $5 %}
{% result "nieuwelening" $6 %}

{% assign bank_saldi_collection = custom.bank_saldo %}
{% ifi bank_saldi_collection.size > 0 %}
->{::font size='l'}**Banksaldo's**{:/font}<-
{% endifi %}

{% stripnewlines %}
{% fori bank in custom.bank_saldo %}

{% if forloop.first %}
| {% t "Rekeningnummer" %}
| {% t "Bank" %}
| {% t "Saldo per " %}{{ period.minus_2y.year_end_date | date: "%d/%m/%Y"}}
| {% t "Saldo per " %}{{ period.minus_1y.year_end_date | date: "%d/%m/%Y"}}
| {% t "Saldo per " %}{{ period.year_end_date | date: "%d/%m/%Y"}}
{% newline %}
|:----------20%-----------:
|:---------20%------:
|:---20%---:
|:---20%---:
|:---20%---:

{% endif %}

{% newline %}
| {% input bank.rekeningnummer %}
| {% input bank.kredietinstelling %}
| {% input bank.saldoy2 placeholder:"Saldo Y-2" as:currency %}{% assign saldoy2 = bank.saldoy2 %}
| {% $8+input bank.saldoy1 placeholder:"Saldo Y-1" as:currency %}{% result "beginsaldo" $8 %}
| {% $9+input bank.saldoy placeholder:"Saldo Y" as:currency %}{% result "eindsaldo" $9 %}
{% rollforward bank.saldoy1 bank.saldoy2 %}
{% rollforward bank.saldoy bank.saldoy1 %}
{% rollforward nil bank.saldoy %}

{% if forloop.last %}
{% newline %}
|
|
|
| {{ $8 }}
|{{ $9 }}
{% endif %}
{% endfori %}
{% endstripnewlines %}

Kind regards
Wouter

Solved!
Thanks a lot!