diff --git a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/InvoicePlugin.java b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/InvoicePlugin.java
index 2f1560b..a862636 100644
--- a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/InvoicePlugin.java
+++ b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/InvoicePlugin.java
@@ -23,6 +23,9 @@ import org.imixs.workflow.exceptions.PluginException;
public class InvoicePlugin extends AbstractPlugin {
public static final String CHILD_ITEM_PROPERTY = "_ChildItems";
public static final String ERROR_MISSING_DATA = "MISSING_DATA";
+
+ // XX-YYY-####-###
+ public static final String REGEX_POSNUMER = "([A-Z]{2}-[A-Z]{3}-[0-9]{4}-[0-9]{3})";
@SuppressWarnings("unused")
private static Logger logger = Logger.getLogger(InvoicePlugin.class.getName());
@@ -47,6 +50,15 @@ public class InvoicePlugin extends AbstractPlugin {
+ " muss aufgefüllt sein!");
}
+ // validate pos for regex pattern 'XX-YYY-####-###'
+ if (! posItem.getItemValueString("name").matches(REGEX_POSNUMER)) {
+ // throw a plugin exception - because name is missing!
+ throw new PluginException(InvoicePlugin.class.getName(), ERROR_MISSING_DATA,
+ "Eingabefehler - Die Positionsnummer in Zeile " + posItem.getItemValueString("numpos")
+ + " muss im Format 'XX-YYY-####-###' eingeben werden!");
+ }
+
+
if (posItem.getItemValueString("category").trim().isEmpty()) {
// throw a plugin exception - because name is missing!
throw new PluginException(InvoicePlugin.class.getName(), ERROR_MISSING_DATA,
diff --git a/office-alexander-logistics-app/src/test/java/com/alexanderlogistics/TestPostionsnummernRegex.java b/office-alexander-logistics-app/src/test/java/com/alexanderlogistics/TestPostionsnummernRegex.java
new file mode 100644
index 0000000..32c2b47
--- /dev/null
+++ b/office-alexander-logistics-app/src/test/java/com/alexanderlogistics/TestPostionsnummernRegex.java
@@ -0,0 +1,29 @@
+package com.alexanderlogistics;
+
+import org.junit.Test;
+
+import junit.framework.Assert;
+
+/**
+ * This test generates random test data
+ *
+ * @author rsoika
+ *
+ */
+public class TestPostionsnummernRegex {
+
+ /**
+ * Test positionnummern 'XX-YYY-####-###'
+ */
+ @Test
+ public void testPutFileToFTP() {
+
+ Assert.assertTrue("AA-BBC-1234-991".matches(InvoicePlugin.REGEX_POSNUMER));
+ Assert.assertFalse("aa-BBC-1234-991".matches(InvoicePlugin.REGEX_POSNUMER));
+ Assert.assertFalse("CC-BBC-1234-991 ".matches(InvoicePlugin.REGEX_POSNUMER));
+
+ Assert.assertTrue("IM-ZEL-2101-005".matches(InvoicePlugin.REGEX_POSNUMER));
+
+ }
+
+}
diff --git a/reports/cargosoft/cargosoft-1.0.0.imixs-report b/reports/cargosoft/cargosoft-1.0.0.imixs-report
index c30c2e6..407708c 100644
--- a/reports/cargosoft/cargosoft-1.0.0.imixs-report
+++ b/reports/cargosoft/cargosoft-1.0.0.imixs-report
@@ -1 +1 @@
-- $uniqueid$workflowgroup$taskid$workflowsummaryinvoice.numberinvoice.dateinvoice.totalinvoice.currencycdtr.namecdtr.ibancdtr.bicdbtr.namedbtr.ibandbtr.bicpayment.type
- UTF-8
- Cargosoft Export - only the XSL Template is needed here!
- cargosoft
- <?xml version="1.0" encoding="UTF-8" standalone="yes"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:strip-space elements="*" /> <xsl:output method="xml" indent="yes" encoding="UTF-8" standalone="yes" /> <xsl:template match="/"> <xsl:variable name="date" select="/data/document/item[@name='$modified']/value" /> <Invoices version="2020.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Message> <SenderID>Imixs-Office-Workflow</SenderID> <ReceiverID>Cargosoft</ReceiverID> <MessageID><xsl:value-of select="/data/document/item[@name='$uniqueid']/value" /></MessageID> <MessageDate> <DateTime><xsl:value-of select="$date" /></DateTime> </MessageDate> </Message> <xsl:apply-templates select="/data/document[normalize-space(item[@name = '$workflowgroup']/value) = 'Cargosoft-Export']" /> </Invoices> </xsl:template> <!-- This template builds invoice info --> <xsl:template match="/data/document[normalize-space(item[@name = '$workflowgroup']/value) = 'Cargosoft-Export']"> <xsl:variable name="date" select="item[@name='$modified']/value"/> <xsl:variable name="currency" select="item[@name='invoice.currency']/value"/> <Invoice> <InvoiceHeader> <Client> <Codes> <!-- Als Typ muss „cs“ übermittelt werden und im Code wird dann der Cargosoft Mandant erwartet. --> <Code Type="cs">001</Code> </Codes> </Client> <!-- Hier muss eine eindeutige Belegnummer für jeden einzelnen Beleg übermittelt werden. Es muss sich um eine Nummer handeln, die pro Beleg hochgezählt wird und darf sich nicht überschneiden mit dem CargoSoft Belegnummernkreis. Daher den Nummernkreis vorher mit CargoSoft absprechen. --> <InvoiceNumber><xsl:value-of select="item[@name='numsequencenumber']/value" /></InvoiceNumber> <InvoiceType> <Codes> <Code Type="cs">INVOICE</Code> </Codes> </InvoiceType> <InvoiceCurrency> <Codes> <Code Type="cs"><xsl:value-of select="$currency" /></Code> </Codes> </InvoiceCurrency> <InvoiceAmount> <NetAmount> <Amount> <Currency> <Codes> <Code Type="cs"><xsl:value-of select="$currency" /></Code> </Codes> </Currency> <Value><xsl:value-of select="item[@name='order.total.net']/value" /></Value> <ExchangeRate><xsl:value-of select="item[@name='invoice.exchangerate']/value" /></ExchangeRate> </Amount> </NetAmount> <VATAmount> <Amount> <Currency> <Codes> <Code Type="cs"><xsl:value-of select="$currency" /></Code> </Codes> </Currency> <Value><xsl:value-of select="item[@name='order.total.tax']/value" /></Value> <ExchangeRate><xsl:value-of select="item[@name='invoice.exchangerate']/value" /></ExchangeRate> </Amount> </VATAmount> <VATInformation> <VATAmount> <Amount isDomesticCurrency="true"> <Currency> <Codes> <Code Type="cs"><xsl:value-of select="$currency" /></Code> </Codes> </Currency> <Value>0</Value> </Amount> </VATAmount> </VATInformation> </InvoiceAmount> <CollectionInvoice>false</CollectionInvoice> <xsl:if test="string-length(item[@name='invoice.period']/value) > 0"> <BookingPeriod><xsl:value-of select="item[@name='invoice.period']/value" /></BookingPeriod> </xsl:if> <Booked>false</Booked> <InvoiceDate><xsl:value-of select="item[@name='invoice.date']/value" /></InvoiceDate> <InvoiceAddress type="CN"> <Codes> <Code Type="cs"><xsl:value-of select="item[@name='cdtr.number']/value" /></Code> </Codes> </InvoiceAddress> <References> <Reference type="cs"><xsl:value-of select="item[@name='invoice.number']/value" /></Reference> </References> <!-- Attachements --> <xsl:if test="item[@name='$file.count']/value > 0"> <Attachments> <xsl:for-each select="item[@name='$file']/value/item"> <Attachment> <xsl:attribute name="id"><xsl:value-of select="./value/item[@name='md5checksum']/value" /></xsl:attribute> <xsl:attribute name="version">1</xsl:attribute> <Filename><xsl:value-of select="./@name" /></Filename> <Description>Imixs-Office-Workflow</Description> <Content><xsl:value-of select="./value[2]" /></Content> </Attachment> </xsl:for-each> </Attachments> </xsl:if> </InvoiceHeader> <InvoiceRows> <xsl:for-each select="item[@name='_childitems']/value"> <InvoiceRow> <Row><xsl:value-of select="./item[@name='numpos']/value" /></Row> <FileNumber><xsl:value-of select="./item[@name='name']/value" /></FileNumber> <InvoiceAmount> <NetAmount> <Amount> <Currency> <Codes> <Code Type="cs"><xsl:value-of select="$currency" /></Code> </Codes> </Currency> <Value><xsl:value-of select="./item[@name='amount']/value" /></Value> </Amount> </NetAmount> <VATInformation> <VAT> <Codes> <Code Type="cs"><xsl:value-of select="./item[@name='tax']/value" /></Code> </Codes> </VAT> </VATInformation> </InvoiceAmount> <ActivityType> <Codes> <Code Type="cs"><xsl:value-of select="./item[@name='category']/value" /></Code> </Codes> </ActivityType> </InvoiceRow> </xsl:for-each> </InvoiceRows> </Invoice> </xsl:template> </xsl:stylesheet>
- /office-alexander-logistics/reports/cargosoft/cargosoft-1.0.2.xsl
\ No newline at end of file
+- $uniqueid$workflowgroup$taskid$workflowsummaryinvoice.numberinvoice.dateinvoice.totalinvoice.currencycdtr.namecdtr.ibancdtr.bicdbtr.namedbtr.ibandbtr.bicpayment.type
- UTF-8
- Cargosoft Export - only the XSL Template is needed here!
- cargosoft
- <?xml version="1.0" encoding="UTF-8" standalone="yes"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:strip-space elements="*" /> <xsl:output method="xml" indent="yes" encoding="UTF-8" standalone="yes" /> <xsl:template match="/"> <xsl:variable name="date" select="/data/document/item[@name='$modified']/value" /> <Invoices version="2020.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Message> <SenderID>Imixs-Office-Workflow</SenderID> <ReceiverID>Cargosoft</ReceiverID> <MessageID><xsl:value-of select="/data/document/item[@name='$uniqueid']/value" /></MessageID> <MessageDate> <DateTime><xsl:value-of select="$date" /></DateTime> </MessageDate> </Message> <xsl:apply-templates select="/data/document[normalize-space(item[@name = '$workflowgroup']/value) = 'Cargosoft-Export']" /> </Invoices> </xsl:template> <!-- This template builds invoice info --> <xsl:template match="/data/document[normalize-space(item[@name = '$workflowgroup']/value) = 'Cargosoft-Export']"> <xsl:variable name="date" select="item[@name='$modified']/value"/> <xsl:variable name="currency" select="item[@name='invoice.currency']/value"/> <Invoice> <InvoiceHeader> <Client> <Codes> <!-- Als Typ muss „cs“ übermittelt werden und im Code wird dann der Cargosoft Mandant erwartet. --> <Code Type="cs">001</Code> </Codes> </Client> <!-- Hier muss eine eindeutige Belegnummer für jeden einzelnen Beleg übermittelt werden. Es muss sich um eine Nummer handeln, die pro Beleg hochgezählt wird und darf sich nicht überschneiden mit dem CargoSoft Belegnummernkreis. Daher den Nummernkreis vorher mit CargoSoft absprechen. --> <InvoiceNumber><xsl:value-of select="item[@name='numsequencenumber']/value" /></InvoiceNumber> <InvoiceType> <Codes> <Code Type="cs">INVOICE</Code> </Codes> </InvoiceType> <InvoiceCurrency> <Codes> <Code Type="cs"><xsl:value-of select="$currency" /></Code> </Codes> </InvoiceCurrency> <InvoiceAmount> <NetAmount> <Amount> <Currency> <Codes> <Code Type="cs"><xsl:value-of select="$currency" /></Code> </Codes> </Currency> <Value><xsl:value-of select="item[@name='order.total.netto']/value" /></Value> <ExchangeRate><xsl:value-of select="item[@name='invoice.exchangerate']/value" /></ExchangeRate> </Amount> </NetAmount> <VATAmount> <Amount> <Currency> <Codes> <Code Type="cs"><xsl:value-of select="$currency" /></Code> </Codes> </Currency> <Value><xsl:value-of select="item[@name='order.total.tax']/value" /></Value> <ExchangeRate><xsl:value-of select="item[@name='invoice.exchangerate']/value" /></ExchangeRate> </Amount> </VATAmount> <VATInformation> <VATAmount> <Amount isDomesticCurrency="true"> <Currency> <Codes> <Code Type="cs"><xsl:value-of select="$currency" /></Code> </Codes> </Currency> <Value>0</Value> </Amount> </VATAmount> </VATInformation> </InvoiceAmount> <CollectionInvoice>false</CollectionInvoice> <xsl:if test="string-length(item[@name='invoice.period']/value) > 0"> <BookingPeriod><xsl:value-of select="item[@name='invoice.period']/value" /></BookingPeriod> </xsl:if> <Booked>false</Booked> <InvoiceDate><xsl:value-of select="item[@name='invoice.date']/value" /></InvoiceDate> <InvoiceAddress type="CN"> <Codes> <Code Type="cs"><xsl:value-of select="item[@name='cdtr.number']/value" /></Code> </Codes> </InvoiceAddress> <References> <Reference type="cs"><xsl:value-of select="item[@name='invoice.number']/value" /></Reference> </References> <!-- Attachements --> <xsl:if test="item[@name='$file.count']/value > 0"> <Attachments> <xsl:for-each select="item[@name='$file']/value/item"> <Attachment> <xsl:attribute name="id"><xsl:value-of select="./value/item[@name='md5checksum']/value" /></xsl:attribute> <xsl:attribute name="version">1</xsl:attribute> <Filename><xsl:value-of select="./@name" /></Filename> <Description>Imixs-Office-Workflow</Description> <Content><xsl:value-of select="./value[2]" /></Content> </Attachment> </xsl:for-each> </Attachments> </xsl:if> </InvoiceHeader> <InvoiceRows> <xsl:for-each select="item[@name='_childitems']/value"> <InvoiceRow> <Row><xsl:value-of select="./item[@name='numpos']/value" /></Row> <FileNumber><xsl:value-of select="./item[@name='name']/value" /></FileNumber> <InvoiceAmount> <NetAmount> <Amount> <Currency> <Codes> <Code Type="cs"><xsl:value-of select="$currency" /></Code> </Codes> </Currency> <Value><xsl:value-of select="./item[@name='amount']/value" /></Value> </Amount> </NetAmount> <VATInformation> <VAT> <Codes> <Code Type="cs"><xsl:value-of select="./item[@name='tax']/value" /></Code> </Codes> </VAT> </VATInformation> </InvoiceAmount> <ActivityType> <Codes> <Code Type="cs"><xsl:value-of select="./item[@name='category']/value" /></Code> </Codes> </ActivityType> </InvoiceRow> </xsl:for-each> </InvoiceRows> </Invoice> </xsl:template> </xsl:stylesheet>
- /office-alexander-logistics/reports/cargosoft/cargosoft-1.0.2.xsl
\ No newline at end of file
diff --git a/reports/cargosoft/cargosoft-1.0.2.xsl b/reports/cargosoft/cargosoft-1.0.2.xsl
index 892119c..4a94cb0 100644
--- a/reports/cargosoft/cargosoft-1.0.2.xsl
+++ b/reports/cargosoft/cargosoft-1.0.2.xsl
@@ -69,7 +69,7 @@
-
+
diff --git a/reports/cargosoft/test/positionen.out.xml b/reports/cargosoft/test/positionen.out.xml
index 9741db9..09f1a6c 100644
--- a/reports/cargosoft/test/positionen.out.xml
+++ b/reports/cargosoft/test/positionen.out.xml
@@ -34,10 +34,21 @@
EUR
- 1035.70
+ 84.03
1.00345
+
+
+
+
+ EUR
+
+
+ 15.97
+ 1.00345
+
+
diff --git a/reports/cargosoft/test/positionen.xml b/reports/cargosoft/test/positionen.xml
index 6224895..6dc6779 100644
--- a/reports/cargosoft/test/positionen.xml
+++ b/reports/cargosoft/test/positionen.xml
@@ -218,6 +218,16 @@
-
1035.70
+ -
+ 84.03
+
+ -
+ 100.00
+
+ -
+ 15.97
+
+
-
1.00345