This commit is contained in:
Ralph Soika 2024-08-12 12:07:00 +02:00
parent 74d1107c9a
commit fc7a591da7
3 changed files with 17 additions and 11 deletions

View file

@ -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

View file

@ -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.
* <p>
* 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.
* <p>
@ -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"));

View file

@ -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() {