verbesserter SEPA Report

This commit is contained in:
Ralph Soika 2025-09-01 08:47:19 +02:00
parent e0e5bbd8f3
commit 0ef5fff446
2 changed files with 216 additions and 24 deletions

File diff suppressed because one or more lines are too long

View file

@ -4,19 +4,22 @@
<xsl:strip-space elements="*" /> <xsl:strip-space elements="*" />
<xsl:output method="xml" indent="yes" encoding="UTF-8" standalone="yes" /> <xsl:output method="xml" indent="yes" encoding="UTF-8" standalone="yes" />
<xsl:template match="/"> <xsl:template match="/">
<xsl:variable name="now" select="current-dateTime()" /> <Document <xsl:variable name="now" select="current-dateTime()" />
<Document
xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.003.03" xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.003.03"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pain.001.003.03 pain.001.003.03.xsd"> xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pain.001.003.03 pain.001.003.03.xsd">
<CstmrCdtTrfInitn> <!-- generate header info --> <!-- compute count of invoices --> <CstmrCdtTrfInitn>
<!-- generate header info -->
<!-- compute count of invoices -->
<xsl:variable name="count" <xsl:variable name="count"
select="count(/data/document[starts-with(normalize-space(item[@name = '$modelversion']/value),'rechnungseingang')]/item[@name='$uniqueid']/value)" /> <!-- select="count(/data/document[starts-with(normalize-space(item[@name = '$modelversion']/value),'rechnungseingang')]/item[@name='$uniqueid']/value)" />
compute total amount --> <!-- compute total amount -->
<xsl:variable name="totalsum" <xsl:variable name="totalsum"
select="xs:decimal(sum(/data/document[starts-with(normalize-space(item[@name = '$modelversion']/value),'rechnungseingang')]/item[@name='invoice.total']/value))" /> <!-- select="xs:decimal(sum(/data/document[starts-with(normalize-space(item[@name = '$modelversion']/value),'rechnungseingang')]/item[@name='invoice.total']/value))" />
round to 2 digits --> <!-- round to 2 digits -->
<xsl:variable name="total" select="xs:decimal(round-half-to-even($totalsum, 2))" /> <!-- <xsl:variable name="total" select="xs:decimal(round-half-to-even($totalsum, 2))" />
shortcut for the sepa export document --> <!-- shortcut for the sepa export document -->
<xsl:variable name="exportWorkitem" <xsl:variable name="exportWorkitem"
select="/data/document[normalize-space(item[@name = '$workflowgroup']/value) = 'SEPA-Export']" /> select="/data/document[normalize-space(item[@name = '$workflowgroup']/value) = 'SEPA-Export']" />
<GrpHdr> <GrpHdr>
@ -31,7 +34,8 @@
<NbOfTxs> <NbOfTxs>
<xsl:value-of select="$count" /> <xsl:value-of select="$count" />
</NbOfTxs> </NbOfTxs>
<CtrlSum> <!-- round to 2 digits --> <CtrlSum>
<!-- round to 2 digits -->
<xsl:value-of select="$total" /> <xsl:value-of select="$total" />
</CtrlSum> </CtrlSum>
<InitgPty> <InitgPty>
@ -50,7 +54,8 @@
<NbOfTxs> <NbOfTxs>
<xsl:value-of select="$count" /> <xsl:value-of select="$count" />
</NbOfTxs> </NbOfTxs>
<CtrlSum> <!-- round to 2 digits --> <CtrlSum>
<!-- round to 2 digits -->
<xsl:value-of select="$total" /> <xsl:value-of select="$total" />
</CtrlSum> </CtrlSum>
<PmtTpInf> <PmtTpInf>
@ -82,7 +87,8 @@
</BIC> </BIC>
</FinInstnId> </FinInstnId>
</DbtrAgt> </DbtrAgt>
<ChrgBr>SLEV</ChrgBr> <!-- generate CdtTrfTxInf for each invoice --> <ChrgBr>SLEV</ChrgBr>
<!-- generate CdtTrfTxInf for each invoice -->
<xsl:apply-templates <xsl:apply-templates
select="/data/document[starts-with(normalize-space(item[@name = '$modelversion']/value),'rechnungseingang')]" /> select="/data/document[starts-with(normalize-space(item[@name = '$modelversion']/value),'rechnungseingang')]" />
</PmtInf> </PmtInf>
@ -91,13 +97,13 @@
</xsl:template> <!-- </xsl:template> <!--
This template builds sepa header info --> This template builds sepa header info -->
<xsl:template <xsl:template
match="/data/document[normalize-space(item[@name = '$workflowgroup']/value) = 'SEPA-Export']"> <!-- match="/data/document[normalize-space(item[@name = '$workflowgroup']/value) = 'SEPA-Export']">
not in use --> <!-- not in use -->
</xsl:template> <!-- </xsl:template> <!--
This template builds sepa payment info for each invoice --> This template builds sepa payment info for each invoice -->
<xsl:template <xsl:template
match="/data/document[starts-with(normalize-space(item[@name = '$modelversion']/value),'rechnungseingang')]"> <!-- match="/data/document[starts-with(normalize-space(item[@name = '$modelversion']/value),'rechnungseingang')]">
round to 2 digits - geht nur mit sum funktion --> <xsl:variable <!-- round to 2 digits - geht nur mit sum funktion --> <xsl:variable
name="wert1" select="xs:decimal(sum(item[@name='invoice.total']/value))" /> <xsl:variable name="wert1" select="xs:decimal(sum(item[@name='invoice.total']/value))" /> <xsl:variable
name="wert2" select="xs:decimal(round-half-to-even($wert1,2))" /> <CdtTrfTxInf name="wert2" select="xs:decimal(round-half-to-even($wert1,2))" /> <CdtTrfTxInf
xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.003.03"> xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.003.03">
@ -107,8 +113,8 @@
<Amt> <Amt>
<InstdAmt> <InstdAmt>
<xsl:attribute name="Ccy"><xsl:value-of <xsl:attribute name="Ccy"><xsl:value-of
select="item[@name='invoice.currency']/value" /></xsl:attribute> <!-- select="item[@name='invoice.currency']/value" /></xsl:attribute>
round to 2 digits --> <!-- round to 2 digits -->
<xsl:value-of select="$wert2" /> <xsl:value-of select="$wert2" />
</InstdAmt> </InstdAmt>
</Amt> </Amt>
@ -119,9 +125,20 @@
</BIC> </BIC>
</FinInstnId> </FinInstnId>
</CdtrAgt> </CdtrAgt>
<Cdtr> <!-- MAX70 --> <Cdtr>
<!-- MAX70 -->
<!-- Aenderung 1.Sep 2025 - Name wird aus BPartner Interface genommen
partner.name if available -->
<Nm> <Nm>
<xsl:value-of select="substring(item[@name='cdtr.name']/value, 1, 70)" /> <xsl:choose>
<xsl:when test="string-length(item[@name='partner.name']/value) > 0">
<xsl:value-of
select="substring(item[@name='partner.name']/value, 1, 70)" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring(item[@name='cdtr.name']/value, 1, 70)" />
</xsl:otherwise>
</xsl:choose>
</Nm> </Nm>
</Cdtr> </Cdtr>
<CdtrAcct> <CdtrAcct>
@ -131,15 +148,19 @@
</IBAN> </IBAN>
</Id> </Id>
</CdtrAcct> </CdtrAcct>
<RmtInf> <!-- Max140Text --> <RmtInf>
<!-- Max140Text -->
<Ustrd> <Ustrd>
<xsl:choose> <xsl:choose>
<xsl:when test="string-length(item[@name='numsequencenumber']/value) > 0"> <!-- <xsl:when test="string-length(item[@name='sequencenumber']/value) > 0">
neues format buchungsnummer / rechn.nr --> <xsl:value-of <!-- neues format buchungsnummer / rechn.nr -->
select="item[@name='numsequencenumber']/value" /><xsl:text> / </xsl:text><xsl:value-of <xsl:value-of
select="item[@name='sequencenumber']/value" /><xsl:text> / </xsl:text><xsl:value-of
select="item[@name='invoice.number']/value" /> select="item[@name='invoice.number']/value" />
</xsl:when> </xsl:when>
<xsl:otherwise> <!-- fallback --> <xsl:value-of <xsl:otherwise>
<!-- fallback -->
<xsl:value-of
select="substring(item[@name='$workflowsummary']/value, 1, 140)" /> select="substring(item[@name='$workflowsummary']/value, 1, 140)" />
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>