validierung positionsumer

This commit is contained in:
Ralph Soika 2021-02-05 14:24:51 +01:00
parent 4648c27f0c
commit edc1be0d25
6 changed files with 65 additions and 3 deletions

View file

@ -24,6 +24,9 @@ public class InvoicePlugin extends AbstractPlugin {
public static final String CHILD_ITEM_PROPERTY = "_ChildItems"; public static final String CHILD_ITEM_PROPERTY = "_ChildItems";
public static final String ERROR_MISSING_DATA = "MISSING_DATA"; 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") @SuppressWarnings("unused")
private static Logger logger = Logger.getLogger(InvoicePlugin.class.getName()); private static Logger logger = Logger.getLogger(InvoicePlugin.class.getName());
@ -47,6 +50,15 @@ public class InvoicePlugin extends AbstractPlugin {
+ " muss aufgefüllt sein!"); + " 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()) { if (posItem.getItemValueString("category").trim().isEmpty()) {
// throw a plugin exception - because name is missing! // throw a plugin exception - because name is missing!
throw new PluginException(InvoicePlugin.class.getName(), ERROR_MISSING_DATA, throw new PluginException(InvoicePlugin.class.getName(), ERROR_MISSING_DATA,

View file

@ -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));
}
}

File diff suppressed because one or more lines are too long

View file

@ -69,7 +69,7 @@
<Code Type="cs"><xsl:value-of select="$currency" /></Code> <Code Type="cs"><xsl:value-of select="$currency" /></Code>
</Codes> </Codes>
</Currency> </Currency>
<Value><xsl:value-of select="item[@name='order.total.net']/value" /></Value> <Value><xsl:value-of select="item[@name='order.total.netto']/value" /></Value>
<ExchangeRate><xsl:value-of select="item[@name='invoice.exchangerate']/value" /></ExchangeRate> <ExchangeRate><xsl:value-of select="item[@name='invoice.exchangerate']/value" /></ExchangeRate>
</Amount> </Amount>
</NetAmount> </NetAmount>

View file

@ -34,10 +34,21 @@
<Code Type="cs">EUR</Code> <Code Type="cs">EUR</Code>
</Codes> </Codes>
</Currency> </Currency>
<Value>1035.70</Value> <Value>84.03</Value>
<ExchangeRate>1.00345</ExchangeRate> <ExchangeRate>1.00345</ExchangeRate>
</Amount> </Amount>
</NetAmount> </NetAmount>
<VATAmount>
<Amount>
<Currency>
<Codes>
<Code Type="cs">EUR</Code>
</Codes>
</Currency>
<Value>15.97</Value>
<ExchangeRate>1.00345</ExchangeRate>
</Amount>
</VATAmount>
<VATInformation> <VATInformation>
<VATAmount> <VATAmount>
<Amount isDomesticCurrency="true"> <Amount isDomesticCurrency="true">

View file

@ -218,6 +218,16 @@
<item name="invoice.total"> <item name="invoice.total">
<value xsi:type="xs:decimal">1035.70</value> <value xsi:type="xs:decimal">1035.70</value>
</item> </item>
<item name="order.total.netto">
<value xsi:type="xs:decimal">84.03</value>
</item>
<item name="invoice.total">
<value xsi:type="xs:decimal">100.00</value>
</item>
<item name="order.total.tax">
<value xsi:type="xs:decimal">15.97</value>
</item>
<item name="invoice.exchangerate"> <item name="invoice.exchangerate">
<value xsi:type="xs:decimal">1.00345</value> <value xsi:type="xs:decimal">1.00345</value>
</item> </item>