<#– function definitions –>
<#function getReferenceNote payment>
<#assign paidTransactions = transHash[payment.internalid]>
<#assign referenceNote = “”>
<#assign paidTransactionsCount = paidTransactions?size>
<#if (paidTransactionsCount >= 1)>
<#list paidTransactions as transaction>
<#if transaction.tranid?has_content>
<#if referenceNote?has_content>
<#assign referenceNote = referenceNote + “, ” + transaction.tranid>
<#else>
<#assign referenceNote = transaction.tranid>
</#if>
</#if>
</#list>
</#if>
<#return referenceNote>
</#function>
<#function convertSEPACharSet text>
<#assign value = text>
<#assign value = value?replace(‘&’,’+’)>
<#assign value = value?replace(‘*’,’.’)>
<#assign value = value?replace(‘$’,’.’)>
<#assign value = value?replace(‘%’,’.’)>
<#assign value = value?replace(”’,’ ‘)>
<#assign value = value?replace(‘/’,’ ‘)>
<#assign value = convertToLatinCharSet(value)>
<#return value>
</#function>
<#– cached values –>
<#assign totalAmount = computeTotalAmount(payments)>
<#– template building –>
#OUTPUT START#
<?xml version=”1.0″ encoding=”UTF-8″?>
<Document xmlns=”urn:iso:std:iso:20022:tech:xsd:pain.001.003.03″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”>
<CstmrCdtTrfInitn>
<GrpHdr>
<MsgId>${pfa.id}</MsgId>
<CreDtTm>${pfa.custrecord_2663_file_creation_timestamp?date?string(“yyyy-MM-dd”)}T${pfa.custrecord_2663_file_creation_timestamp?time?string(“HH:mm:ss”)}</CreDtTm>
<NbOfTxs>${payments?size?c}</NbOfTxs>
<CtrlSum>${formatAmount(totalAmount,”decLessThan1″)}</CtrlSum>
<InitgPty>
<Nm>${setMaxLength(convertSEPACharSet(cbank.custpage_eft_custrecord_2663_statement_name),70)}</Nm>
<Id>
<PrvtId>
<Othr>
<Id>${setMaxLength(convertSEPACharSet(convertToLatinCharSet(cbank.custpage_eft_custrecord_2663_bank_comp_id)),35)}</Id>
</Othr>
</PrvtId>
</Id>
</InitgPty>
</GrpHdr>
<PmtInf>
<#list payments as payment>
<#assign ebank = ebanks[payment_index]>
<#assign entity = entities[payment_index]>
<PmtInfId>${setMaxLength(pfa.id,5)}-${setMaxLength(convertSEPACharSet(pfa.custrecord_2663_ref_note),30)}</PmtInfId>
<PmtMtd>DD</PmtMtd>
<BtchBookg>true</BtchBookg>
<NbOfTxs>${setMaxLength(payments?size,15)}</NbOfTxs>
<CtrlSum>${formatAmount(totalAmount,”decLessThan1″)}</CtrlSum>
<PmtTpInf>
<InstrPrty>NORM</InstrPrty>
<SvcLvl>
<Cd>SEPA</Cd>
</SvcLvl>
<LclInstrm>
<Cd>${pfa.custrecord_2663_direct_debit_type}</Cd>
</LclInstrm>
<SeqTp>${ebank.custrecord_2663_entity_billing_seq_type}</SeqTp>
<CtgyPurp>SALA</CtgyPurp>
</PmtTpInf>
<ReqdColltnDt>${pfa.custrecord_2663_process_date?string(“yyyy-MM-dd”)}</ReqdColltnDt>
<Cdtr>
<Nm>${setMaxLength(convertSEPACharSet(cbank.custpage_eft_custrecord_2663_statement_name),70)}</Nm>
</Cdtr>
<PstlAdr>
<StrtNm>${setMaxLength(convertSEPACharSet(convertToLatinCharSet(cbank.custpage_eft_custrecord_2663_bank_address1)),70)}</StrtNm>
<BldgNb>${setMaxLength(convertSEPACharSet(convertToLatinCharSet(cbank.custpage_eft_custrecord_2663_bank_address2)),16)}</BldgNb>
<PstCd>${setMaxLength(convertSEPACharSet(convertToLatinCharSet(cbank.custpage_eft_custrecord_2663_bank_zip)),16)}</PstCd>
<TwnNm>${setMaxLength(convertSEPACharSet(convertToLatinCharSet(cbank.custpage_eft_custrecord_2663_bank_city)),35)}</TwnNm>
<Ctry>${getCountryCode(cbank.custpage_eft_custrecord_2663_bank_country)}</Ctry>
</PstlAdr>
<Id>
<OrgId>
<Othr>
<Id>${cbank.custpage_eft_custrecord_2663_bank_comp_id}</Id>
</Othr>
</OrgId>
</Id>
<CdtrAcct>
<Id>
<IBAN>${setMaxLength(cbank.custpage_eft_custrecord_2663_iban,34)}</IBAN>
</Id>
<Ccy>EUR</Ccy>
</CdtrAcct>
<CdtrAgt>
<FinInstnId>
<BIC>${cbank.custpage_eft_custrecord_2663_bic}</BIC>
</FinInstnId>
</CdtrAgt>
<UltmtCdtr>
<Nm>${setMaxLength(convertToLatinCharSet(cbank.custpage_eft_custrecord_2663_statement_name),70)}</Nm>
<Id>
<OrgId>
<Id>${cbank.custpage_eft_custrecord_2663_bank_comp_id}</Id>
</OrgId>
</Id>
</UltmtCdtr>
<ChrgBr>SLEV</ChrgBr>
<CdtrSchmeId>
<Id>
<PrvtId>
<Othr>
<Id>${cbank.custpage_eft_custrecord_2663_processor_code}</Id>
<SchmeNm>
<Prtry>SEPA</Prtry>
</SchmeNm>
</Othr>
</PrvtId>
</Id>
</CdtrSchmeId>
</#list>
<#list payments as payment>
<#assign ebank = ebanks[payment_index]>
<#assign entity = entities[payment_index]>
<DrctDbtTxInf>
<PmtId>
<InstrId>${pfa.id}-${setMaxLength(convertSEPACharSet(pfa.custrecord_2663_ref_note),29)}</InstrId>
<EndToEndId>${pfa.id}-${setMaxLength(payment.tranid,29)}</EndToEndId>
</PmtId>
<InstdAmt Ccy=”EUR”>${formatAmount(getAmount(payment),”decLessThan1″)}</InstdAmt>
<DrctDbtTx>
<MndtRltdInf>
<MndtId>${convertSEPACharSet(ebank.custrecord_2663_reference)}</MndtId>
<DtOfSgntr>${ebank.custrecord_2663_date_ref_mandate?string(“yyyy-MM-dd”)}</DtOfSgntr>
<#if ebank.custrecord_2663_customer_code == “AMEND_NONE”>
<AmdmntInd>false</AmdmntInd>
<#elseif ebank.custrecord_2663_customer_code == “AMEND_MANDATE_ID”>
<AmdmntInd>true</AmdmntInd>
<AmdmntInfDtls>
<OrgnlMndtId>${ebank.custrecord_2663_entity_issuer_num}</OrgnlMndtId>
</AmdmntInfDtls>
<#elseif ebank.custrecord_2663_customer_code == “AMEND_DEBTOR_ACCT”>
<AmdmntInd>true</AmdmntInd>
<AmdmntInfDtls>
<OrgnlDbtrAcct>
<Id>
<IBAN>${ebank.custrecord_2663_entity_acct_no}</IBAN>
</Id>
</OrgnlDbtrAcct>
</AmdmntInfDtls>
<#elseif ebank.custrecord_2663_customer_code == “AMEND_DEBTOR_AGENT”>
<AmdmntInd>true</AmdmntInd>
<AmdmntInfDtls>
<OrgnlDbtrAgt>
<FinInstnId>
<Othr>
<Id>SMNDA</Id>
</Othr>
</FinInstnId>
</OrgnlDbtrAgt>
</AmdmntInfDtls>
<#elseif ebank.custrecord_2663_customer_code == “AMEND_CREDITOR_ID”>
<AmdmntInd>true</AmdmntInd>
<AmdmntInfDtls>
<OrgnlCdtrSchmeId>
<Nm>${setMaxLength(convertSEPACharSet(ebank.custrecord_2663_entity_acct_name),70)}</Nm>
<Id>
<PrvtId>
<Othr>
<Id>${setMaxLength(convertSEPACharSet(ebank.custrecord_2663_entity_bank_no),35)}</Id>
<SchmeNm>
<Prtry>SEPA</Prtry>
</SchmeNm>
</Othr>
</PrvtId>
</Id>
</OrgnlCdtrSchmeId>
</AmdmntInfDtls>
</#if>
<#if ebank.custrecord_2663_entity_signature?has_content>
<ElctrncSgntr>${convertSEPACharSet(ebank.custrecord_2663_entity_signature)}</ElctrncSgntr>
</#if>
</MndtRltdInf>
</DrctDbtTx>
<CdtrSchmeId>
<Id>
<PrvtId>
<Othr>
<Id>${cbank.custpage_eft_custrecord_2663_processor_code}</Id>
<SchmeNm>
<Prtry>SEPA</Prtry>
</SchmeNm>
</Othr>
</PrvtId>
</Id>
</CdtrSchmeId>
<UltmtCdtr>
<Nm>${setMaxLength(convertToLatinCharSet(cbank.custpage_eft_custrecord_2663_statement_name),70)}</Nm>
<Id>
<OrgId>
<Id>${cbank.custpage_eft_custrecord_2663_bank_comp_id}</Id>
</OrgId>
</Id>
</UltmtCdtr>
<DbtrAgt>
<FinInstnId>
<BIC>${setMaxLength(convertSEPACharSet(ebank.custrecord_2663_entity_bic),11)}</BIC>
</FinInstnId>
</DbtrAgt>
<Dbtr>
<Nm>${setMaxLength(convertSEPACharSet(buildEntityName(entity,false)),70)}</Nm>
<PstlAdr>
<StrtNm>${setMaxLength(convertSEPACharSet(convertToLatinCharSet(ebank.custrecord_2663_entity_address1)),70)}</StrtNm>
<BldgNb>${setMaxLength(convertSEPACharSet(convertToLatinCharSet(ebank.custrecord_2663_entity_address2)),70)}</BldgNb>
<PstCd>${setMaxLength(convertSEPACharSet(convertToLatinCharSet(ebank.custrecord_2663_entity_zip)),16)}</PstCd>
<TwnNm>${setMaxLength(convertSEPACharSet(convertToLatinCharSet(ebank.custrecord_2663_entity_city)),16)}</TwnNm>
<Ctry>${getCountryCode(ebank.custrecord_2663_entity_country)}</Ctry>
</PstlAdr>
<Id>
<OrgId>
<Othr>
<Id>${convertToLatinCharSet(entity.internalid)}</Id>
</Othr>
</OrgId>
</Id>
</Dbtr>
<DbtrAcct>
<Id>
<IBAN>${setMaxLength(convertSEPACharSet(ebank.custrecord_2663_entity_iban),34)}</IBAN>
</Id>
</DbtrAcct>
<Purp>
<Cd>COLL</Cd>
</Purp>
<RmtInf>
<Ustrd>${setMaxLength(convertSEPACharSet(getReferenceNote(payment)),140)}</Ustrd>
</RmtInf>
</DrctDbtTxInf>
</#list>
</PmtInf>
</CstmrCdtTrfInitn>
</Document>
#OUTPUT END#