refactoring op listen
This commit is contained in:
parent
6977228367
commit
4507638daf
9 changed files with 224 additions and 12 deletions
|
|
@ -366,6 +366,12 @@
|
|||
<version>3.3.6</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.imixs.workflow</groupId>
|
||||
<artifactId>imixs-melman</artifactId>
|
||||
<version>${org.imixs.melman.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -170,7 +170,7 @@ public class OPListExportAdapter extends POIFindReplaceAdapter {
|
|||
// calculate summ of all invoices
|
||||
double catSum = 0;
|
||||
for (ItemCollection invoice : invoices) {
|
||||
catSum = catSum + invoice.getItemValueDouble("invoice.total");
|
||||
catSum = catSum + invoice.getItemValueDouble("invoice.saldo");
|
||||
}
|
||||
if (catSum < 0) {
|
||||
// SOLL
|
||||
|
|
@ -192,7 +192,7 @@ public class OPListExportAdapter extends POIFindReplaceAdapter {
|
|||
row.getCell(3).setCellValue(invoice.getItemValueString("invoice.text"));
|
||||
row.getCell(4).setCellValue(invoice.getItemValueDate("invoice.date"));
|
||||
row.getCell(5).setCellValue(invoice.getItemValueDate("invoice.duedate"));
|
||||
double total = invoice.getItemValueDouble("invoice.total");
|
||||
double total = invoice.getItemValueDouble("invoice.saldo");
|
||||
if (total < 0) {
|
||||
// SOLL
|
||||
row.getCell(6).setCellValue(total);
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ public class DatevCargosoftImportAdapter implements SignalAdapter {
|
|||
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyyMMdd");
|
||||
|
||||
// load spaces Pos Expressions
|
||||
Map<String, List<String>> spaces = loadSpacesConfig();
|
||||
Map<String, List<String>> spacePosMappings = loadSpacePosMappings();
|
||||
|
||||
|
||||
ItemCollection invoiceWorkitem = null;
|
||||
|
|
@ -245,7 +245,7 @@ public class DatevCargosoftImportAdapter implements SignalAdapter {
|
|||
logger.info("...close workitem....");
|
||||
|
||||
// nein - also invoice schließen
|
||||
closeInvoiceWorkitem(invoiceWorkitem, splitBuchungen,spaces);
|
||||
closeInvoiceWorkitem(invoiceWorkitem, splitBuchungen,spacePosMappings);
|
||||
invoiceWorkitem = null;
|
||||
// neue Splitbuchungstabelle anlegen
|
||||
splitBuchungen = new ArrayList<ItemCollection>();
|
||||
|
|
@ -263,7 +263,7 @@ public class DatevCargosoftImportAdapter implements SignalAdapter {
|
|||
}
|
||||
|
||||
} // wile end
|
||||
closeInvoiceWorkitem(invoiceWorkitem, splitBuchungen,spaces);
|
||||
closeInvoiceWorkitem(invoiceWorkitem, splitBuchungen,spacePosMappings);
|
||||
|
||||
} catch (IOException | ParseException e) {
|
||||
throw new PluginException(DatevCargosoftImportAdapter.class.getName(),
|
||||
|
|
@ -292,9 +292,10 @@ public class DatevCargosoftImportAdapter implements SignalAdapter {
|
|||
|
||||
/**
|
||||
* Helper method that loads all expressions from the spaces
|
||||
*
|
||||
* @return List of list of expressions
|
||||
*/
|
||||
private Map<String,List<String>> loadSpacesConfig() {
|
||||
private Map<String,List<String>> loadSpacePosMappings() {
|
||||
Map<String,List<String>> result =new HashMap<>();
|
||||
// als erstes lesen wir die pos.mappings aus den Spaces ein, auf die dann eine
|
||||
// Rechnung emapped werden kann.
|
||||
|
|
@ -389,7 +390,7 @@ public class DatevCargosoftImportAdapter implements SignalAdapter {
|
|||
* @throws AccessDeniedException
|
||||
*/
|
||||
private void closeInvoiceWorkitem(ItemCollection invoiceWorkitem, List<ItemCollection> splitBuchungen,
|
||||
Map<String, List<String>> expressionsMap)
|
||||
Map<String, List<String>> spacePosMappings)
|
||||
throws AccessDeniedException, ProcessingErrorException, PluginException, ModelException {
|
||||
if (invoiceWorkitem == null) {
|
||||
return; // no op
|
||||
|
|
@ -430,7 +431,8 @@ public class DatevCargosoftImportAdapter implements SignalAdapter {
|
|||
// dazu kucken wir in alle spaces den config wert 'pos.mapping'
|
||||
String text = invoiceWorkitem.getItemValueString("invoice.text");
|
||||
if (!text.isEmpty()) {
|
||||
for (Map.Entry<String, List<String> > entry : expressionsMap.entrySet()) {
|
||||
boolean found=false;
|
||||
for (Map.Entry<String, List<String> > entry : spacePosMappings.entrySet()) {
|
||||
List<String> expressionsList=entry.getValue();
|
||||
for (String expr : expressionsList) {
|
||||
|
||||
|
|
@ -439,9 +441,13 @@ public class DatevCargosoftImportAdapter implements SignalAdapter {
|
|||
if (m.find()) {
|
||||
// we have a match
|
||||
invoiceWorkitem.setItemValue("space.ref", entry.getKey());
|
||||
found=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Processe die Invoice
|
||||
|
|
@ -450,6 +456,11 @@ public class DatevCargosoftImportAdapter implements SignalAdapter {
|
|||
|
||||
}
|
||||
|
||||
|
||||
public static void updateSpaceRef(ItemCollection invoice) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the List of ItemCollections back into a List of Map elements
|
||||
*
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ alexander_sub_positionen_read=
|
|||
alexander_sub_responsible=
|
||||
|
||||
space.sub_custom=Konfiguration
|
||||
space.help_custom=Bitte verwenden Sie hier Reguläre Ausdrücke wie z.B. /\bEX-SAL\b/ Dieser Ausdruck sucht nach dem Wert "EX-SAL" in einem String und achtet darauf, dass es nicht Teil eines größeren Ausdrucks ist (z.B. "EX-SALES").
|
||||
space.help_custom=Bitte verwenden Sie hier Reguläre Ausdrücke wie z.B. \\bEX-SAL Dieser Ausdruck sucht nach dem Wert "EX-SAL" in einem String und achtet darauf, dass es nicht Teil eines größeren Ausdrucks ist (z.B. "EX-SALES").
|
||||
|
||||
|
||||
ERROR_INVALID_IBANBIC=Die Eingabe der IBAN/BIC is ungültig. Bitte überprüfen Sie Ihre Eingaben.
|
||||
|
|
@ -10,6 +10,8 @@ alexander_sub_positionen_read=
|
|||
alexander_sub_responsible=
|
||||
|
||||
space.sub_custom=Konfiguration
|
||||
space.help_custom=Bitte verwenden Sie hier Reguläre Ausdrücke wie z.B. \\bEX-SAL Dieser Ausdruck sucht nach dem Wert "EX-SAL" in einem String und achtet darauf, dass es nicht Teil eines größeren Ausdrucks ist (z.B. "EX-SALES").
|
||||
|
||||
|
||||
|
||||
ERROR_INVALID_IBANBIC=Your input of the IBAN/BIC is invalid. Please check your data.
|
||||
|
|
|
|||
|
|
@ -65,11 +65,23 @@ public class TestFormat {
|
|||
if (m.find()) {
|
||||
System.out.println("Ich bin ein Held");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegex2() {
|
||||
String text="R IM-GCA-2210-031";
|
||||
String expr="\\bIM-GCA";
|
||||
|
||||
Pattern p = Pattern.compile(expr);
|
||||
|
||||
p = Pattern.compile(expr);
|
||||
|
||||
Matcher m = p.matcher(text);
|
||||
if (m.find()) {
|
||||
System.out.println("Ich bin ein Held");
|
||||
} else {
|
||||
System.out.println("Ich bin Kein Held");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,178 @@
|
|||
package com.alexanderlogistics.migration;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.imixs.melman.FormAuthenticator;
|
||||
import org.imixs.melman.RestAPIException;
|
||||
import org.imixs.melman.WorkflowClient;
|
||||
import org.imixs.workflow.ItemCollection;
|
||||
import org.imixs.workflow.exceptions.PluginException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
/**
|
||||
* Dieser Agent ordnet nachträglich Ausgangsrechnungen aus der Migraiton einem
|
||||
* Space zu.
|
||||
*
|
||||
* @author rsoika
|
||||
*
|
||||
*/
|
||||
public class MigrationSpaceZuordnung {
|
||||
|
||||
WorkflowClient workflowCLient = null;
|
||||
String user = "archive";
|
||||
String ps = "archive4imixs";
|
||||
String restAPI = "https://test.alexander-logistics.office-workflow.de/api";
|
||||
int countProcessed = 0;
|
||||
int notFound = 0;
|
||||
int count = 0;
|
||||
Map<String, List<String>> spacePosMappings=null;
|
||||
Map<String, String> spaceNames=null;
|
||||
|
||||
@Before
|
||||
public void setup() throws PluginException, RestAPIException, UnsupportedEncodingException {
|
||||
|
||||
// Init Workflow Client
|
||||
workflowCLient = new WorkflowClient(restAPI);
|
||||
FormAuthenticator formAuth = new FormAuthenticator(restAPI, user, ps);
|
||||
workflowCLient.registerClientRequestFilter(formAuth);
|
||||
|
||||
|
||||
// load spaces Pos Expressions
|
||||
loadSpacePosMappings();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Diese methode liest offene Ausgangsrechnungen aus udn prüft of space.ref
|
||||
* bereits getzt ist.
|
||||
*
|
||||
* @throws PluginException
|
||||
* @throws RestAPIException
|
||||
* @throws UnsupportedEncodingException
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void anlysiere() throws RestAPIException, PluginException, UnsupportedEncodingException {
|
||||
|
||||
System.out.println("***********************");
|
||||
System.out.println("* Update Ausgangsrechnungen Pos-Space Mapping *");
|
||||
System.out.println("***********************");
|
||||
|
||||
int maxCount = 10000;
|
||||
|
||||
String query = "$modelversion:\"rechnungsausgang-de-1.0\" AND type:workitem";
|
||||
|
||||
int pageSize = 100;
|
||||
int pageIndex = 0;
|
||||
while (true) {
|
||||
workflowCLient.setPageIndex(pageIndex);
|
||||
workflowCLient.setPageSize(pageSize);
|
||||
List<ItemCollection> invoices = workflowCLient.searchDocuments(query);
|
||||
|
||||
|
||||
System.out.println("... ich processe " + invoices.size() +" invoices...");
|
||||
|
||||
// teste space.ref
|
||||
for (ItemCollection invoice: invoices) {
|
||||
count++;
|
||||
boolean update=false;
|
||||
if (invoice.getItemValueString("space.ref").isEmpty()) {
|
||||
|
||||
// Jezt noch das Space mapping
|
||||
// dazu kucken wir in alle spaces den config wert 'pos.mapping'
|
||||
String text = invoice.getItemValueString("invoice.text");
|
||||
if (!text.isEmpty()) {
|
||||
|
||||
for (Map.Entry<String, List<String> > entry : spacePosMappings.entrySet()) {
|
||||
List<String> expressionsList=entry.getValue();
|
||||
for (String expr : expressionsList) {
|
||||
|
||||
Pattern p = Pattern.compile(expr);
|
||||
Matcher m = p.matcher(text);
|
||||
if (m.find()) {
|
||||
// we have a match
|
||||
invoice.setItemValue("space.ref", entry.getKey());
|
||||
invoice.setItemValue("space.name", spaceNames.get(entry.getKey()));
|
||||
|
||||
update=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (update) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (update) {
|
||||
// update invioce
|
||||
System.out.println("...ich update invoice: " + invoice.getUniqueID());
|
||||
try {
|
||||
workflowCLient.saveDocument(invoice);
|
||||
countProcessed++;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// fetrig?
|
||||
if (invoices.size() < pageSize) {
|
||||
break;
|
||||
}
|
||||
if (count>=maxCount) {
|
||||
break;
|
||||
}
|
||||
pageIndex++;
|
||||
}
|
||||
|
||||
System.out.println("=================================================");
|
||||
System.out.println("... fininshed - read " + count + " invoices");
|
||||
System.out.println(" updated " + countProcessed + " invoices");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method that loads all expressions from the spaces
|
||||
*
|
||||
* @return List of list of expressions
|
||||
* @throws UnsupportedEncodingException
|
||||
* @throws RestAPIException
|
||||
*/
|
||||
private void loadSpacePosMappings() throws RestAPIException, UnsupportedEncodingException {
|
||||
spacePosMappings = new HashMap<>();
|
||||
spaceNames= new HashMap<>();
|
||||
// als erstes lesen wir die pos.mappings aus den Spaces ein, auf die dann eine
|
||||
// Rechnung emapped werden kann.
|
||||
|
||||
List<ItemCollection> spaces_subs = workflowCLient.searchDocuments("type:space");
|
||||
for (ItemCollection space : spaces_subs) {
|
||||
spacePosMappings.put(space.getUniqueID(), space.getItemValueList("pos.mapping", String.class));
|
||||
spaceNames.put(space.getUniqueID(), space.getItemValueString("space.name"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
"EXTF";"510";21;"Buchungsstapel";7;"20220721060421653";"";"CS";"cargoservice";"";"";"";"20220101";"4";"20220101";"20221231";"202206ALL";"CS";"";"";0;"EUR";"";"";"";"";"";"";"";"";""
|
||||
Umsatz (ohne Soll-/Haben-Kennzeichen);Soll-Haben-Kennzeichen;WKZ Umsatz;Kurs;Basisumsatz;WKZ Basisumsatz;Konto;Gegenkonto;BU-Schlüssel;Belegdatum;Belegfeld 1;Belegfeld 2;Skonto;Buchungstext;Postensperre;Diverse Adressnummer;Geschäftspartnerbank;Sachverhalt;Zinssperre;Beleglink;Beleginfo-Art 1;Beleginfo-Inhalt 1;Beleginfo-Art 2;Beleginfo-Inhalt 2;Beleginfo-Art 3;Beleginfo-Inhalt 3;Beleginfo-Art 4;Beleginfo-Inhalt 4;Beleginfo-Art 5;Beleginfo-Inhalt 5;Beleginfo-Art 6;Beleginfo-Inhalt 6;Beleginfo-Art 7;Beleginfo-Inhalt 7;Beleginfo-Art 8;Beleginfo-Inhalt 8;KOST1-Kostenstelle;KOST2-Kostenstelle;KOST-Menge;EU-Mitgliedstaatu. USt-IdNr.;EU-Steuersatz;Abw. Versteuerungsart;Sachverhalt L+L;Funktionserg<72>nzung L+L;BU 49 Hauptfunktionstyp;BU 49 Hauptfunktionsnummer;BU 49 Funktionserg<72>nzung;Zusatzinformation-Art 1;Zusatzinformation-Inhalt 1;Zusatzinformation-Art 2;Zusatzinformation-Inhalt 2;Zusatzinformation-Art 3;Zusatzinformation-Inhalt 3;Zusatzinformation-Art 4;Zusatzinformation-Inhalt 4;Zusatzinformation-Art 5;Zusatzinformation-Inhalt 5;Zusatzinformation-Art 6;Zusatzinformation-Inhalt 6;Zusatzinformation-Art 7;Zusatzinformation-Inhalt 7;Zusatzinformation-Art 8;Zusatzinformation-Inhalt 8;Zusatzinformation-Art 9;Zusatzinformation-Inhalt 9;Zusatzinformation-Art 10;Zusatzinformation-Inhalt 10;Zusatzinformation-Art 11;Zusatzinformation-Inhalt 11;Zusatzinformation-Art 12;Zusatzinformation-Inhalt 12;Zusatzinformation-Art 13;Zusatzinformation-Inhalt 13;Zusatzinformation-Art 14;Zusatzinformation-Inhalt 14;Zusatzinformation-Art 15;Zusatzinformation-Inhalt 15;Zusatzinformation-Art 16;Zusatzinformation-Inhalt 16;Zusatzinformation-Art 17;Zusatzinformation-Inhalt 17;Zusatzinformation-Art 18;Zusatzinformation-Inhalt 18;Zusatzinformation-Art 19;Zusatzinformation-Inhalt 19;Zusatzinformation-Art 20;Zusatzinformation-Inhalt 20;St<53>ck;Gewicht;Zahlweise;Forderungsart;Veranlagungsjahr;Zugeordnete F<>lligkeit;Skontotyp;Auftragsnummer;Buchungstyp;USt-Schl<68>ssel (Anzahlungen);EU-Mitgliedstaat (Anzahlungen);Sachverhalt L+L (Anzahlungen);EU-Steuersatz (Anzahlungen);Erlöskonto (Anzahlungen);Herkunft-Kz;Leerfeld;KOST-Datum;SEPAMandatsreferenz;Skontosperre;Gesellschaftername;Beteiligtennummer;Identifikationsnummer;Zeichnernummer;Postensperre bis;Bezeichnung SoBil-Sachverhalt;Kennzeichen SoBil-Buchung;Festschreibung;Leistungsdatum;Datum Zuord. Steuerperiode
|
||||
2810,00;"H";"EUR";0,000000;0,00;;8011;12976;;1410;"183885";;;"R IM-GCA-2210-031";0;;;0;;;;;Faelligkeit;20221113;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
Can't render this file because it has a wrong number of fields in line 2.
|
2
pom.xml
2
pom.xml
|
|
@ -27,7 +27,7 @@
|
|||
<org.imixs.adapters.version>2.3.1</org.imixs.adapters.version>
|
||||
<!-- 2.2.14 -->
|
||||
<org.imixs.archive.version>2.3.0</org.imixs.archive.version>
|
||||
<org.imixs.melman.version>1.0.20</org.imixs.melman.version>
|
||||
<org.imixs.melman.version>1.0.22</org.imixs.melman.version>
|
||||
<org.imixs.ml.version>1.1.6-SNAPSHOT</org.imixs.ml.version>
|
||||
<microprofile.version>2.2</microprofile.version>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue