diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 3760347..968a79f 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -21,7 +21,7 @@ - DWC = AED; EUR;CHF;SEK;RUB;NOK;GBP;USD;CAD b) Mandant ID - 2. OP Listen Template im Textbausteein aktualisieren + 2. OP Listen Template im Textbaustein aktualisieren 3. Alle Workflow Modelle erneuern 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 533e7fb..607ba92 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 @@ -6,6 +6,7 @@ import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.eclipse.microprofile.config.inject.ConfigProperty; import org.imixs.workflow.ItemCollection; import org.imixs.workflow.engine.plugins.AbstractPlugin; import org.imixs.workflow.exceptions.PluginException; @@ -28,7 +29,7 @@ import jakarta.inject.Inject; * geprüft ob die Rechnungsnummer schon einmal vorkam. Falls ja, wird eine * Warnung ausgegeben. Der Benutzer kann diese dann skippen. *
- * Zusäztlich berechnet das Plugin das feld invoice.positions mit einer Value + * Zusätzlich berechnet das Plugin das Feld invoice.positions mit einer Value * liste der Positionsnummern. Dieses Feld wird indiziert, so dass gezielt nach * Positionsnummern gesucht werden kann. *
@@ -51,11 +52,17 @@ public class InvoicePlugin extends AbstractPlugin { public static final String ERROR_DUPPLICATE_INVOICE_NUMBER = "DUPPLICATE_INVOICE_NUMBER"; public static final String ERROR_NEW_IBANBIC = "NEW_IBANBIC"; - // XX-YYY-####-### - public static final String REGEX_POSNUMER = "([A-Z]{2}-[A-Z]{3}-[0-9]{4}-[0-9]{3})"; - private static Logger logger = Logger.getLogger(InvoicePlugin.class.getName()); + // Positions Pattern - kann überschrieben werden + // Default = ([A-Z]{2}-[A-Z]{3}-[0-9]{4}-[0-9]{3}) + // Optional = ([A-Z]{2}-(?:[A-Z]{3}|[A-Z]{6})-[0-9]{4}-[0-9]{3}) + public final static String INVOICE_POSITIONS_PATTERN_DEFAULT = "([A-Z]{2}-(?:[A-Z]{3}|[A-Z]{6})-[0-9]{4}-[0-9]{3})"; + + @Inject + @ConfigProperty(name = "invoice.position.pattern", defaultValue = INVOICE_POSITIONS_PATTERN_DEFAULT) + String invoicePositionsPattern; + @Inject KreditorDebitorService kreditorService; @@ -129,7 +136,7 @@ public class InvoicePlugin extends AbstractPlugin { } // validate pos for regex pattern 'XX-YYY-####-###' - if (!posItem.getItemValueString("name").matches(REGEX_POSNUMER)) { + if (!posItem.getItemValueString("name").matches(invoicePositionsPattern)) { // throw a plugin exception - because name is missing! String message = resourceBundleHandler.findMessage("ERROR_FORMAT_POSNO"); message = message.replace("{1}", posItem.getItemValueString("numpos")); 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 index 2e4cda0..2c5b604 100644 --- a/office-alexander-logistics-app/src/test/java/com/alexanderlogistics/TestPostionsnummernRegex.java +++ b/office-alexander-logistics-app/src/test/java/com/alexanderlogistics/TestPostionsnummernRegex.java @@ -20,15 +20,14 @@ public class TestPostionsnummernRegex { @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("AA-BBC-1234-991".matches(InvoicePlugin.INVOICE_POSITIONS_PATTERN_DEFAULT)); + Assert.assertFalse("aa-BBC-1234-991".matches(InvoicePlugin.INVOICE_POSITIONS_PATTERN_DEFAULT)); + Assert.assertFalse("CC-BBC-1234-991 ".matches(InvoicePlugin.INVOICE_POSITIONS_PATTERN_DEFAULT)); - Assert.assertTrue("IM-ZEL-2101-005".matches(InvoicePlugin.REGEX_POSNUMER)); + Assert.assertTrue("IM-ZEL-2101-005".matches(InvoicePlugin.INVOICE_POSITIONS_PATTERN_DEFAULT)); } - @Test public void testCargoImportText() {