update, javax und sepa dinge

This commit is contained in:
Ralph Soika 2024-08-26 12:41:39 +02:00
parent d41a2fb063
commit 74b12b0032
9 changed files with 418 additions and 21 deletions

View file

@ -13,6 +13,7 @@ import org.imixs.workflow.exceptions.PluginException;
import org.imixs.workflow.exceptions.QueryException; import org.imixs.workflow.exceptions.QueryException;
import org.imixs.workflow.faces.util.ResourceBundleHandler; import org.imixs.workflow.faces.util.ResourceBundleHandler;
import jakarta.ejb.EJB;
import jakarta.inject.Inject; import jakarta.inject.Inject;
/** /**
@ -63,7 +64,8 @@ public class InvoicePlugin extends AbstractPlugin {
@ConfigProperty(name = "invoice.position.pattern", defaultValue = INVOICE_POSITIONS_PATTERN_DEFAULT) @ConfigProperty(name = "invoice.position.pattern", defaultValue = INVOICE_POSITIONS_PATTERN_DEFAULT)
String invoicePositionsPattern; String invoicePositionsPattern;
@Inject // @Inject
@EJB
KreditorDebitorService kreditorService; KreditorDebitorService kreditorService;
@Inject @Inject

View file

@ -30,17 +30,16 @@ package com.alexanderlogistics;
import java.util.List; import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.annotation.security.DeclareRoles;
import javax.annotation.security.RolesAllowed;
import javax.annotation.security.RunAs;
import org.imixs.workflow.ItemCollection; import org.imixs.workflow.ItemCollection;
import org.imixs.workflow.engine.DocumentService; import org.imixs.workflow.engine.DocumentService;
import org.imixs.workflow.exceptions.PluginException; import org.imixs.workflow.exceptions.PluginException;
import org.imixs.workflow.exceptions.QueryException; import org.imixs.workflow.exceptions.QueryException;
import jakarta.ejb.EJB; import jakarta.annotation.security.DeclareRoles;
import jakarta.annotation.security.RolesAllowed;
import jakarta.annotation.security.RunAs;
import jakarta.ejb.Singleton; import jakarta.ejb.Singleton;
import jakarta.inject.Inject;
/** /**
* Der KreditorService wird verwendet um einen Kreditor zu finden oder neue * Der KreditorService wird verwendet um einen Kreditor zu finden oder neue
@ -64,7 +63,7 @@ public class KreditorDebitorService {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static Logger logger = Logger.getLogger(KreditorDebitorService.class.getName()); private static Logger logger = Logger.getLogger(KreditorDebitorService.class.getName());
@EJB @Inject
DocumentService documentService; DocumentService documentService;
/** /**

View file

@ -31,8 +31,6 @@ import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.annotation.security.RunAs;
import org.eclipse.microprofile.config.inject.ConfigProperty; import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.imixs.archive.core.SnapshotService; import org.imixs.archive.core.SnapshotService;
import org.imixs.workflow.FileData; import org.imixs.workflow.FileData;
@ -40,6 +38,7 @@ import org.imixs.workflow.ItemCollection;
import org.imixs.workflow.engine.DocumentService; import org.imixs.workflow.engine.DocumentService;
import org.imixs.workflow.exceptions.QueryException; import org.imixs.workflow.exceptions.QueryException;
import jakarta.annotation.security.RunAs;
import jakarta.ejb.Singleton; import jakarta.ejb.Singleton;
import jakarta.inject.Inject; import jakarta.inject.Inject;

View file

@ -32,10 +32,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.annotation.security.DeclareRoles;
import javax.annotation.security.RolesAllowed;
import javax.annotation.security.RunAs;
import org.imixs.workflow.ItemCollection; import org.imixs.workflow.ItemCollection;
import org.imixs.workflow.engine.DocumentService; import org.imixs.workflow.engine.DocumentService;
import org.imixs.workflow.engine.WorkflowService; import org.imixs.workflow.engine.WorkflowService;
@ -44,6 +40,9 @@ import org.imixs.workflow.exceptions.ModelException;
import org.imixs.workflow.exceptions.PluginException; import org.imixs.workflow.exceptions.PluginException;
import org.imixs.workflow.exceptions.ProcessingErrorException; import org.imixs.workflow.exceptions.ProcessingErrorException;
import jakarta.annotation.security.DeclareRoles;
import jakarta.annotation.security.RolesAllowed;
import jakarta.annotation.security.RunAs;
import jakarta.ejb.Singleton; import jakarta.ejb.Singleton;
import jakarta.inject.Inject; import jakarta.inject.Inject;

View file

@ -38,10 +38,6 @@ import java.util.List;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
@ -70,6 +66,10 @@ import com.alexanderlogistics.xml.CargosoftXMLInvoiceImportService;
import jakarta.ejb.Stateless; import jakarta.ejb.Stateless;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
/** /**
** Dieser Service korrigiert falsch importierte Cargosoft daten. ** Dieser Service korrigiert falsch importierte Cargosoft daten.

View file

@ -54,7 +54,7 @@ public class TestSEPATransform {
@Test @Test
public void testBankPolski() throws IOException { public void testBankPolski() throws IOException {
String MODEL_PATH_XML = "sepa/beispiel-daten.xml"; String MODEL_PATH_XML = "sepa/beispiel-daten.xml";
String MODEL_PATH_XSL = "sepa/sepa-2.0.8-pl.xsl"; String MODEL_PATH_XSL = "sepa/sepa-2.0.9-pl.xsl";
try { try {
XSLTester.transform(MODEL_PATH_XML, MODEL_PATH_XSL, "../reports/sepa/result_sepa02.xml"); XSLTester.transform(MODEL_PATH_XML, MODEL_PATH_XSL, "../reports/sepa/result_sepa02.xml");
} catch (Exception e) { } catch (Exception e) {

View file

@ -58,7 +58,7 @@
<value xsi:type="xs:string">Rechnungseingang</value> <value xsi:type="xs:string">Rechnungseingang</value>
</item> </item>
<item name="$workflowsummary"> <item name="$workflowsummary">
<value xsi:type="xs:string">Invoice Example-1</value> <value xsi:type="xs:string">Invoice Example-1 Test_123</value>
</item> </item>
<item name="cdtr.bic"> <item name="cdtr.bic">
<value xsi:type="xs:string">XXXADEMM</value> <value xsi:type="xs:string">XXXADEMM</value>
@ -86,7 +86,10 @@
<value xsi:type="xs:dateTime">2020-07-07T00:00:00+02:00</value> <value xsi:type="xs:dateTime">2020-07-07T00:00:00+02:00</value>
</item> </item>
<item name="invoice.number"> <item name="invoice.number">
<value xsi:type="xs:string">202007000175</value> <value xsi:type="xs:string">2020_XX07000175</value>
</item>
<item name="sequencenumber">
<value xsi:type="xs:string">4711</value>
</item> </item>
<item name="invoice.total"> <item name="invoice.total">
<value xsi:type="xs:decimal">290.40</value> <value xsi:type="xs:decimal">290.40</value>
@ -136,7 +139,10 @@
<value xsi:type="xs:dateTime">2020-07-07T00:00:00+02:00</value> <value xsi:type="xs:dateTime">2020-07-07T00:00:00+02:00</value>
</item> </item>
<item name="invoice.number"> <item name="invoice.number">
<value xsi:type="xs:string">202007000175</value> <value xsi:type="xs:string"></value>
</item>
<item name="sequencenumber">
<value xsi:type="xs:string">4711</value>
</item> </item>
<item name="invoice.total"> <item name="invoice.total">
<value xsi:type="xs:decimal">292.44</value> <value xsi:type="xs:decimal">292.44</value>

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,196 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="2.0">
<xsl:strip-space elements="*" />
<xsl:output method="xml" indent="yes" encoding="UTF-8" standalone="yes" />
<xsl:template match="/">
<xsl:variable name="now" select="current-dateTime()" />
<Document
xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03 pain.001.001.03.xsd">
<CstmrCdtTrfInitn>
<!-- generate header info -->
<!-- compute count of invoices -->
<xsl:variable name="count"
select="count(/data/document[starts-with(normalize-space(item[@name = '$modelversion']/value),'rechnungseingang')]/item[@name='$uniqueid']/value)" />
<!-- compute total amount -->
<xsl:variable name="totalsum"
select="xs:decimal(sum(/data/document[starts-with(normalize-space(item[@name = '$modelversion']/value),'rechnungseingang')]/item[@name='invoice.total']/value))" />
<!-- round to 2 digits -->
<xsl:variable name="total"
select="format-number(xs:decimal(round-half-to-even($totalsum, 2)), '0.00')" />
<!-- shortcut for the sepa export document -->
<xsl:variable name="exportWorkitem"
select="/data/document[normalize-space(item[@name = '$workflowgroup']/value) = 'SEPA-Export']" />
<GrpHdr>
<MsgId>
<xsl:value-of
select="replace($exportWorkitem/item[@name='$uniqueid']/value, '-', '')" />
</MsgId>
<CreDtTm>
<xsl:value-of
select="format-dateTime($now, '[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01]')" />
</CreDtTm>
<NbOfTxs>
<xsl:value-of select="$count" />
</NbOfTxs>
<CtrlSum>
<!-- round to 2 digits -->
<xsl:value-of select="$total" />
</CtrlSum>
<InitgPty>
<Nm>
<xsl:value-of
select="$exportWorkitem/item[@name='dbtr.name']/value" />
</Nm>
</InitgPty>
</GrpHdr>
<PmtInf>
<PmtInfId>
<xsl:value-of
select="replace($exportWorkitem/item[@name='$uniqueid']/value, '-', '')" />
<xsl:text>-1</xsl:text>
</PmtInfId>
<PmtMtd>TRF</PmtMtd>
<NbOfTxs>
<xsl:value-of select="$count" />
</NbOfTxs>
<CtrlSum>
<!-- round to 2 digits -->
<xsl:value-of select="$total" />
</CtrlSum>
<PmtTpInf>
<SvcLvl>
<Cd>SEPA</Cd>
</SvcLvl>
</PmtTpInf>
<ReqdExctnDt>
<xsl:value-of
select="format-dateTime($now, '[Y0001]-[M01]-[D01]')" />
</ReqdExctnDt>
<Dbtr>
<Nm>
<xsl:value-of
select="$exportWorkitem/item[@name='dbtr.name']/value" />
</Nm>
</Dbtr>
<DbtrAcct>
<Id>
<IBAN>
<xsl:value-of
select="replace($exportWorkitem/item[@name='dbtr.iban']/value, ' ', '')" />
</IBAN>
</Id>
</DbtrAcct>
<DbtrAgt>
<FinInstnId>
<BIC>
<xsl:value-of
select="replace($exportWorkitem/item[@name='dbtr.bic']/value, ' ', '')" />
</BIC>
</FinInstnId>
</DbtrAgt>
<!--
SHAR Charges are shared between debtor and creditor
SLEV Charges are handled according to service level
-->
<ChrgBr>SHAR</ChrgBr>
<!-- generate CdtTrfTxInf for each invoice -->
<xsl:apply-templates
select="/data/document[starts-with(normalize-space(item[@name = '$modelversion']/value),'rechnungseingang')]" />
</PmtInf>
</CstmrCdtTrfInitn>
</Document>
</xsl:template>
<!-- This template builds sepa header info -->
<xsl:template
match="/data/document[normalize-space(item[@name = '$workflowgroup']/value) = 'SEPA-Export']">
<!-- not in use -->
</xsl:template>
<!-- This template builds sepa payment info for each invoice -->
<xsl:template
match="/data/document[starts-with(normalize-space(item[@name = '$modelversion']/value),'rechnungseingang')]">
<!-- round to 2 digits - geht nur mit sum funktion -->
<xsl:variable
name="wert2"
select="format-number(xs:decimal(round-half-to-even(item[@name='invoice.total']/value, 2)), '0.00')" />
<CdtTrfTxInf
xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03">
<PmtId>
<EndToEndId>NOTPROVIDED</EndToEndId>
</PmtId>
<Amt>
<InstdAmt>
<xsl:attribute name="Ccy"><xsl:value-of
select="item[@name='invoice.currency']/value" /></xsl:attribute>
<!-- round to 2 digits -->
<xsl:value-of select="$wert2" />
</InstdAmt>
</Amt>
<CdtrAgt>
<FinInstnId>
<BIC>
<xsl:value-of select="replace(item[@name='cdtr.bic']/value, ' ', '')" />
</BIC>
</FinInstnId>
</CdtrAgt>
<Cdtr>
<!-- MAX70 -->
<Nm>
<!-- <xsl:value-of select="substring(item[@name='cdtr.name']/value, 1, 70)" /> -->
<!-- entfernen der non ascii zeichen
<xsl:value-of
select="substring(replace(item[@name='cdtr.name']/value, '\P{IsBasicLatin}', ''), 1, 70)" />
-->
<xsl:value-of
select="substring(translate(
normalize-space(item[@name='cdtr.name']/value),
translate(item[@name='cdtr.name']/value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZĄĆĘŁÓŚŹŻŃabcdefghijklmnopqrstuvwxyząćęłóśźżń0123456789 /-?:().,''+''{}.', ''),''), 1, 70)" />
</Nm>
</Cdtr>
<CdtrAcct>
<Id>
<IBAN>
<xsl:value-of select="replace(item[@name='cdtr.iban']/value, ' ', '')" />
</IBAN>
</Id>
</CdtrAcct>
<RmtInf>
<!-- Max140Text -->
<Ustrd>
<xsl:choose>
<xsl:when test="string-length(item[@name='invoice.number']/value) > 0">
<xsl:value-of
select="substring(translate(
normalize-space(item[@name='invoice.number']/value),
translate(item[@name='invoice.number']/value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZĄĆĘŁÓŚŹŻŃabcdefghijklmnopqrstuvwxyząćęłóśźżń0123456789 /-?:().,''+''{}.', ''),''), 1, 140)" />
</xsl:when>
<xsl:otherwise>
<!-- fallback -->
<xsl:value-of
select="substring(item[@name='sequencenumber']/value, 1, 140)" />
</xsl:otherwise>
</xsl:choose>
</Ustrd>
</RmtInf>
</CdtTrfTxInf>
</xsl:template>
</xsl:stylesheet>