Hy,我想知道我怎么能防止,ouptut将显示相同日期或相同合同类型的两倍。此外,我不知道如何在最后的日期/合同类型后面加上逗号...
目前输出将是:
我想如何获得输出:
因此,如果有两次相同的日期或相同的合同我只想在我的列表中一次。如果它不同,它应该显示所有这些,并且在两种情况下都是列表的最后一个输出后面的逗号。如果您知道如何更改标题取决于是否有0,1或2个日期,那将是惊人的。
<#assign translations = {
"de": {
"bbo": "Per {0}",
"sqm":"m²",
"contract00":"Vertragstyp:",
"contract01":"Befristet",
"contract02":"Unbefristet",
"contract03":"Befristet mit echter Option",
"contract04":"Befristet mit unechter Option",
"contract05":"Amortisation Mieterausbau",
"contract06":"Umsatzmiete",
"contract07":"Andere",
"contract08":"Unbekannt",
"start00":"Vertragsstart:",
"end00":"Vertragsende"
},
"en":{
"bbo": "Per {0}",
"sqm":"m²",
"contract00":"Contract type:",
"contract01":"Limited",
"contract02":"Unlimited",
"contract03":"Limited with real option",
"contract04":"Limited with unreal option",
"contract05":"Amortisation Mieterausbau",
"contract06":"Umsatzmiete",
"contract07":"Other",
"contract08":"Unknown",
"start00":"Start of contract:",
"end00":"End of contract:"
}
}>
<br>
<#assign msg = translations[.lang]>
<#assign currency = valuation.valuationSettings.valuationCurrency>
<#assign rentalUnits = valuation.draftRul.rentalUnits>
<#assign rentalUnitsWithTenant = []>
<#list rentalUnits as ru>
<#if ru.currentLease?? && ru.currentLease.tenant?? >
<#assign rentalUnitsWithTenant = rentalUnitsWithTenant + [ru]>
</#if>
</#list>
<#assign rentalUnitsByTenant = groupBy(rentalUnitsWithTenant, "currentLease.tenant")>
<ul>
<#list rentalUnitsByTenant?keys?sort as tenant>
<#assign rentalUnitsOfTenant = rentalUnitsByTenant[tenant]>
<#assign area=sum(rentalUnitsOfTenant, "areaPerUnitValue")>
<#assign income = sum(rentalUnitsOfTenant, "currentLease.income.income")>
<#assign units = sum(rentalUnitsOfTenant, "units")>
<#if income gte 100000>
<li>
${tenant}: ${area} ${msg["sqm"]}, ${currency} ${income?string[",##0"]},
${msg["contract00"]}
<#list rentalUnitsOfTenant as ru>
<#if ru.currentLease??>
<#if ru.currentLease.contractType= "LIMITED">
<#assign contract = msg["contract01"]>
<#elseif ru.currentLease.contractType="UNLIMITED">
<#assign contract = msg["contract02"]>
<#elseif ru.currentLease.contractType="LIMITED_WITH_REAL_OPTION">
<#assign contract = msg["contract03"]>
<#elseif ru.currentLease.contractType="LIMITED_WITH_UNREAL_OPTION">
<#assign contract = msg["contract04"]>
<#elseif ru.currentLease.contractType="AMORTISATION">
<#assign contract = msg["contract05"]>
<#elseif ru.currentLease.contractType="UMSATZMIETE">
<#assign contract = msg["contract06"]>
<#elseif ru.currentLease.contractType="OTHER">
<#assign contract = msg["contract07"]>
<#elseif ru.currentLease.contractType="UNKNOWN">
<#assign contract = msg["contract08"]>
</#if>
${contract}<#sep>/</#sep>
</#if>
</#list>
${msg["start00"]}
<#list rentalUnitsOfTenant as ru>
<#if ru.currentLease??>
${ru.currentLease.start!}<#sep>/</#sep>
</#if>
</#list>
Enddaten:
<#list rentalUnitsOfTenant as ru>
<#if ru.currentLease.end??>
${ru.currentLease.end!}<#sep>/</#sep>
</#if>
</#list>
</li>
</#if>
</#list>
</ul>
如果您有我的一个问题的解决方案,我已经感激不尽了。
尝试在打印值之前构建唯一列表,它可能类似于下面的示例。关键是seq_contains方法。
<#assign uniqueList = []>
<#list rentalUnitsOfTenant as ru>
<#if ru.currentLease??>
<#if ru.currentLease.contractType= "LIMITED">
<#assign contract = msg["contract01"]>
...
</#if>
<#if !uniqueList?seq_contains(contract) >
<#assign uniqueList = uniqueList + [contract]>
</#if>
</#if>
</#list>
<#list uniqueList as contract>
${contract}<#sep>/</#sep>
</#list>