From ac2bc4bfe8595d4a92f127ab7f12fefd2eaffb7d Mon Sep 17 00:00:00 2001
From: Ralph Soika
Date: Mon, 30 Sep 2024 12:31:40 +0200
Subject: [PATCH] neue modelle - minor fixes
---
.../api/CargosoftMigrationRestService.java | 167 +
.../mahnlauf/MahnlaufService.java | 4 +
workflow/posteingang-de-2.0.0.bpmn | 12 +-
workflow/rechnungsausgang-de-1.0.12.bpmn | 4117 +++++++++++++++++
4 files changed, 4294 insertions(+), 6 deletions(-)
create mode 100644 workflow/rechnungsausgang-de-1.0.12.bpmn
diff --git a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/api/CargosoftMigrationRestService.java b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/api/CargosoftMigrationRestService.java
index b131dd8..e1c0e09 100644
--- a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/api/CargosoftMigrationRestService.java
+++ b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/api/CargosoftMigrationRestService.java
@@ -35,6 +35,7 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
+import java.util.Map;
import java.util.TimeZone;
import java.util.logging.Logger;
@@ -47,6 +48,7 @@ import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
+import org.imixs.marty.team.TeamService;
import org.imixs.workflow.FileData;
import org.imixs.workflow.ItemCollection;
import org.imixs.workflow.engine.DocumentService;
@@ -62,12 +64,14 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import com.alexanderlogistics.InvoiceUtil;
+import com.alexanderlogistics.mahnlauf.MahnlaufService;
import com.alexanderlogistics.xml.CargosoftXMLInvoiceImportService;
import jakarta.ejb.Stateless;
import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
+import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
@@ -102,12 +106,175 @@ public class CargosoftMigrationRestService implements Serializable {
@Inject
WorkflowService workflowService;
+ @Inject
+ MahnlaufService mahnlaufService;
+
+ @Inject
+ TeamService teamService;
+
private static Logger logger = Logger.getLogger(CargosoftMigrationRestService.class.getName());
public CargosoftMigrationRestService() {
super();
}
+ /**
+ * Dieser Endpunkt akutalisiert alle ausgehenden noch offenen Rechnungen in
+ * Bezug auf die Abteilungszugehörigkeit.
+ *
+ *
+ * @return
+ * @throws QueryException
+ * @throws AccessDeniedException
+ * @throws ProcessingErrorException
+ * @throws PluginException
+ * @throws ModelException
+ */
+ @GET
+ @Path("/invoices/fix/spaces")
+ @Produces({ MediaType.TEXT_PLAIN })
+ public String updateInvoiceSpacesAssignment()
+ throws QueryException, AccessDeniedException, ProcessingErrorException, PluginException, ModelException {
+ count = 0;
+ String query = "($modelversion:rechnungsausgang-de-1.0) AND (type:workitem)";
+ // "AND $taskid:[20240604 TO 20240701]";
+ logger.info("query=" + query);
+ log = "Update Space Assignment in Outgoing Invoices\n\n" + query;
+
+ List result = documentService.find(query, 9999, 0);
+ log = log + " " + new Date() + "\n\n";
+ log = log + "\n\nFound " + result.size() + " open invoices.";
+
+ // load spaces Pos Expressions
+ Map> spacePosMappings = mahnlaufService.loadSpacePosMappings();
+
+ for (ItemCollection invoice : result) {
+
+ String oldSpaceRef = invoice.getItemValueString("space.ref");
+ mahnlaufService.mapInvoiceTextToSpace(invoice, spacePosMappings);
+ String newSpaceRef = invoice.getItemValueString("space.ref");
+ if (newSpaceRef.isEmpty()) {
+ // wir dürfen die space.ref nicht löschen!
+ continue;
+ }
+ // change?
+ if (!oldSpaceRef.equals(newSpaceRef)) {
+ count++;
+ logger.info("...fix invoice: " + invoice.getUniqueID());
+ // lookup space
+ ItemCollection space = documentService.load(newSpaceRef);
+ invoice.setItemValue("space.name", space.getItemValueString("name"));
+ invoice.setItemValue("migration.space.ref", oldSpaceRef);
+ documentService.save(invoice);
+
+ }
+
+ }
+
+ log = log + "\n\n=== Completed! " + count + " fixes! ===\n\n";
+ return log;
+ }
+
+ /**
+ * Dieser Endpunkt akutalisiert alle ausgehenden noch offenen Rechnungen in
+ * Bezug auf die Abteilungszugehörigkeit.
+ *
+ *
+ * @return
+ * @throws QueryException
+ * @throws AccessDeniedException
+ * @throws ProcessingErrorException
+ * @throws PluginException
+ * @throws ModelException
+ */
+ @GET
+ @Path("/invoices/fix/index/{page}")
+ @Produces({ MediaType.TEXT_PLAIN })
+ public String updateInvoiceIndex(@PathParam("page") int page)
+ throws QueryException, AccessDeniedException, ProcessingErrorException, PluginException, ModelException {
+ count = 0;
+ String query = "($modelversion:rechnungsausgang-de-1.0) AND (type:workitem)";
+
+ logger.info("query=" + query);
+ log = "Update index Invoices\n\n" + query;
+
+ List result = documentService.find(query, 100, page);
+ log = log + " " + new Date() + "\n\n";
+ log = log + " size= 500 page=" + page + "\n\n";
+ log = log + "\n\nFound " + result.size() + " open invoices.";
+
+ logger.info("Found " + result.size() + " open invoices.");
+ for (ItemCollection invoice : result) {
+
+ documentService.save(invoice);
+
+ count++;
+ logger.info("... update index " + invoice.getUniqueID());
+
+ }
+
+ log = log + "\n\n=== Completed! " + count + " fixes! ===\n\n";
+ return log;
+ }
+
+ /**
+ * Dieser Endpunkt akutalisiert alle ausgehenden noch offenen Rechnungen in
+ * Bezug auf die Abteilungszugehörigkeit.
+ *
+ *
+ * @return
+ * @throws QueryException
+ * @throws AccessDeniedException
+ * @throws ProcessingErrorException
+ * @throws PluginException
+ * @throws ModelException
+ */
+ @GET
+ @Path("/steuerbescheide/fix/spaces")
+ @Produces({ MediaType.TEXT_PLAIN })
+ public String updateSteuerbescheideSpacesAssignment()
+ throws QueryException, AccessDeniedException, ProcessingErrorException, PluginException, ModelException {
+ count = 0;
+ String query = "($modelversion:steuerbescheid-de-1.0) AND (type:workitem)";
+ // "AND $taskid:[20240604 TO 20240701]";
+ logger.info("query=" + query);
+ log = "Update Space Assignment in Steuerbescheide\n\n" + query;
+
+ List result = documentService.find(query, 9999, 0);
+
+ log = log + " " + new Date() + "\n\n";
+ log = log + "\n\nFound " + result.size() + " open steuerbescheide.";
+
+ // load spaces Pos Expressions
+ Map> spacePosMappings = mahnlaufService.loadSpacePosMappings();
+
+ for (ItemCollection invoice : result) {
+
+ String oldSpaceRef = invoice.getItemValueString("space.ref");
+ mahnlaufService.mapInvoiceTextToSpace(invoice, spacePosMappings);
+ String newSpaceRef = invoice.getItemValueString("space.ref");
+ if (newSpaceRef.isEmpty()) {
+ // wir dürfen die space.ref nicht löschen!
+ continue;
+ }
+ // change?
+ if (!oldSpaceRef.equals(newSpaceRef)) {
+ count++;
+ logger.info("...fix invoice: " + invoice.getUniqueID());
+ // lookup space
+ ItemCollection space = documentService.load(newSpaceRef);
+ invoice.setItemValue("space.name", space.getItemValueString("name"));
+ invoice.setItemValue("migration.space.ref", oldSpaceRef);
+ documentService.save(invoice);
+
+ }
+
+ }
+
+ log = log + "\n\n=== Completed! " + count + " fixes! ===\n\n";
+ return log;
+ }
+
/**
* This method loads taxonomy data for a workflow group within a given process
* and builds a ChartJS data structure in JSON format
diff --git a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/mahnlauf/MahnlaufService.java b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/mahnlauf/MahnlaufService.java
index a21d65e..ea9828b 100644
--- a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/mahnlauf/MahnlaufService.java
+++ b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/mahnlauf/MahnlaufService.java
@@ -138,6 +138,10 @@ public class MahnlaufService {
for (Map.Entry> entry : spacePosMappings.entrySet()) {
List expressionsList = entry.getValue();
for (String expr : expressionsList) {
+ if (expr == null || expr.trim().isEmpty()) {
+ // skip wenn keine Regex definiert wurde.
+ continue;
+ }
Pattern p = Pattern.compile(expr);
Matcher m = p.matcher(text);
if (m.find()) {
diff --git a/workflow/posteingang-de-2.0.0.bpmn b/workflow/posteingang-de-2.0.0.bpmn
index 7499e6f..6db55ef 100644
--- a/workflow/posteingang-de-2.0.0.bpmn
+++ b/workflow/posteingang-de-2.0.0.bpmn
@@ -615,7 +615,7 @@ Betrag: _amount (Brutto € _amount_brutto
https://llama.cpp.imixs.com/
XML
- true
+ false
cdtr.name,invoice.number,invoice.date,invoice.total,payment.date,cdtr.iban,cdtr.bic,total
@@ -1002,7 +1002,7 @@ Note: Do not generate any other information instead of the XML object. Do not ge
https://llama.cpp.imixs.com/
invoice.summary
- true
+ false
false
]]>
@@ -1393,7 +1393,7 @@ Betrag: _amount (Brutto € _amount_brutto
-
+
@@ -1626,13 +1626,13 @@ Betrag: _amount (Brutto € _amount_brutto
-
+
-
+
@@ -1650,7 +1650,7 @@ Betrag: _amount (Brutto € _amount_brutto
-
+
diff --git a/workflow/rechnungsausgang-de-1.0.12.bpmn b/workflow/rechnungsausgang-de-1.0.12.bpmn
new file mode 100644
index 0000000..8b89f6c
--- /dev/null
+++ b/workflow/rechnungsausgang-de-1.0.12.bpmn
@@ -0,0 +1,4117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+$workflowstatus
+
+]]>
+
+
+ In case you have already made the payment, please disregard this notice. If you require any information regarding your account, please do not hesitate to contact us.
+Thank you for your cooperation.
+
+Kind regards
Alexander Global Logistics GmbH
+
+