fixed junit tests

This commit is contained in:
Ralph Soika 2024-02-16 11:52:45 +01:00
parent 2464753877
commit 1ad63b644c
6 changed files with 129 additions and 146 deletions

View file

@ -85,7 +85,7 @@ public class TestIMAPAuhtenticators {
source.setItemValue(DocumentImportService.SOURCE_ITEM_SERVER, "outlook.office365.com"); source.setItemValue(DocumentImportService.SOURCE_ITEM_SERVER, "outlook.office365.com");
source.setItemValue(DocumentImportService.SOURCE_ITEM_PORT, "993"); source.setItemValue(DocumentImportService.SOURCE_ITEM_PORT, "993");
source.setItemValue(DocumentImportService.SOURCE_ITEM_USER, "Imixs_bhv@alexander-logistics.com"); source.setItemValue(DocumentImportService.SOURCE_ITEM_USER, "Imixsbhv@alexander-logistics.com");
source.setItemValue(DocumentImportService.SOURCE_ITEM_PASSWORD, "A6x8Q~EWVUyt~gfyTHtIJf4ig.F9tajUpEEXMaCL"); source.setItemValue(DocumentImportService.SOURCE_ITEM_PASSWORD, "A6x8Q~EWVUyt~gfyTHtIJf4ig.F9tajUpEEXMaCL");
Properties sourceOptions = new Properties(); Properties sourceOptions = new Properties();

View file

@ -30,7 +30,6 @@ import com.sun.mail.imap.IMAPFolder;
import junit.framework.Assert; import junit.framework.Assert;
/** /**
* This test shows how to access outlook via oauth2 * This test shows how to access outlook via oauth2
* *
@ -91,7 +90,7 @@ public class TestIMAPOutlookOAuth {
// try to connect... // try to connect...
token = getAuthToken(); token = getAuthToken();
Assert.assertNotNull(token); Assert.assertNotNull(token);
store = connect(token, "Imixs_bhv@alexander-logistics.com"); store = connect(token, "Imixsbhv@alexander-logistics.com");
// store = connect(token, "mgeisler@alexander-logistics.com"); // store = connect(token, "mgeisler@alexander-logistics.com");
Assert.assertNotNull(store); Assert.assertNotNull(store);

View file

@ -1,15 +1,12 @@
package com.alexanderlogistics.migration; package com.alexanderlogistics.migration;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -19,10 +16,13 @@ import org.imixs.workflow.ItemCollection;
import org.imixs.workflow.datev.imports.DatevImportAdapter; import org.imixs.workflow.datev.imports.DatevImportAdapter;
import org.imixs.workflow.exceptions.PluginException; import org.imixs.workflow.exceptions.PluginException;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import junit.framework.Assert; import junit.framework.Assert;
@Ignore
@Deprecated
public class DueDateBugfix { public class DueDateBugfix {
WorkflowClient workflowCLient = null; WorkflowClient workflowCLient = null;
@ -46,13 +46,15 @@ public class DueDateBugfix {
* *
*/ */
@Test @Test
@Ignore
public void fixe() { public void fixe() {
System.out.println("***********************"); System.out.println("***********************");
System.out.println("* Bugfix *"); System.out.println("* Bugfix *");
System.out.println("***********************"); System.out.println("***********************");
/* Erledigte /*
* Erledigte
* *
* *
* EXTF_202301_202302030602_1295 * EXTF_202301_202302030602_1295
@ -121,48 +123,45 @@ public class DueDateBugfix {
// suche Rechnung // suche Rechnung
String query = "$modelversion:\"rechnungsausgang-de-1.0\" AND type:workitem AND invoice.number:\"" String query = "$modelversion:\"rechnungsausgang-de-1.0\" AND type:workitem AND invoice.number:\""
+ belegNummer+"\""; + belegNummer + "\"";
workflowCLient.setPageSize(1); workflowCLient.setPageSize(1);
List<ItemCollection> invoices = workflowCLient.searchDocuments(query); List<ItemCollection> invoices = workflowCLient.searchDocuments(query);
if (invoices.size()==1) { if (invoices.size() == 1) {
ItemCollection invoice=invoices.get(0); ItemCollection invoice = invoices.get(0);
Date bugDate = invoice.getItemValueDate("invoice.duedate"); Date bugDate = invoice.getItemValueDate("invoice.duedate");
if (!dueDate.equals(bugDate)) { if (!dueDate.equals(bugDate)) {
fixes++; fixes++;
System.out.println(".... FIX " + belegNummer + " -> " + dueDate + " Bugi Date="+bugDate); System.out.println(".... FIX " + belegNummer + " -> " + dueDate + " Bugi Date=" + bugDate);
invoice.setItemValue("invoice.duedate", dueDate); invoice.setItemValue("invoice.duedate", dueDate);
invoice.setItemValue("invoice.reminder", dueDate); invoice.setItemValue("invoice.reminder", dueDate);
if (invoice.getTaskID()==5100) { if (invoice.getTaskID() == 5100) {
invoice.event(20); invoice.event(20);
workflowCLient.processWorkitem(invoice); workflowCLient.processWorkitem(invoice);
} else { } else {
workflowCLient.saveDocument(invoice); workflowCLient.saveDocument(invoice);
} }
} else { } else {
System.out.println(".... OK " + belegNummer + " -> " + dueDate + " Bugi Date="+bugDate); System.out.println(".... OK " + belegNummer + " -> " + dueDate + " Bugi Date=" + bugDate);
} }
} else { } else {
System.out.println(".... " + belegNummer + " ist unbekannt"); System.out.println(".... " + belegNummer + " ist unbekannt");
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println("hat nicht geklappt: "+e.getMessage()); System.out.println("hat nicht geklappt: " + e.getMessage());
} }
count++; count++;
//if (fixes>0) break; // if (fixes>0) break;
} }

View file

@ -1,11 +1,9 @@
package com.alexanderlogistics.migration; package com.alexanderlogistics.migration;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
@ -19,10 +17,13 @@ import org.imixs.melman.WorkflowClient;
import org.imixs.workflow.ItemCollection; import org.imixs.workflow.ItemCollection;
import org.imixs.workflow.exceptions.PluginException; import org.imixs.workflow.exceptions.PluginException;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import junit.framework.Assert; import junit.framework.Assert;
@Ignore
@Deprecated
public class MigrationMahnerAusziffern { public class MigrationMahnerAusziffern {
List<Rechnung> rechnungen = new ArrayList<Rechnung>(); List<Rechnung> rechnungen = new ArrayList<Rechnung>();
@ -31,9 +32,10 @@ public class MigrationMahnerAusziffern {
String user = "archive"; String user = "archive";
String ps = "archive4imixs"; String ps = "archive4imixs";
String restAPI = "https://alexander-logistics.office-workflow.de/api"; String restAPI = "https://alexander-logistics.office-workflow.de/api";
int countProcessed=0; int countProcessed = 0;
int notFound=0; int notFound = 0;
int count = 0; int count = 0;
@Before @Before
public void setup() throws PluginException, RestAPIException { public void setup() throws PluginException, RestAPIException {
rechnungen = new ArrayList<Rechnung>(); rechnungen = new ArrayList<Rechnung>();
@ -41,14 +43,14 @@ public class MigrationMahnerAusziffern {
workflowCLient = new WorkflowClient(restAPI); workflowCLient = new WorkflowClient(restAPI);
FormAuthenticator formAuth = new FormAuthenticator(restAPI, user, ps); FormAuthenticator formAuth = new FormAuthenticator(restAPI, user, ps);
workflowCLient.registerClientRequestFilter(formAuth); workflowCLient.registerClientRequestFilter(formAuth);
ItemCollection ding = workflowCLient.getWorkitem("1ef4757f-69ae-4ec1-8ba1-01d380d046e7"); ItemCollection ding = workflowCLient.getWorkitem("1ef4757f-69ae-4ec1-8ba1-01d380d046e7");
if (ding!=null) { if (ding != null) {
System.out.println("pip"); System.out.println("pip");
} else { } else {
System.out.println("pap"); System.out.println("pap");
} }
} }
@ -56,11 +58,13 @@ public class MigrationMahnerAusziffern {
* Diese Test Method wandelt die Datei OPD_migration_230126.csv in eine EXTV * Diese Test Method wandelt die Datei OPD_migration_230126.csv in eine EXTV
* Datev Datei um, welche wir dann für einen einmaligen Import der * Datev Datei um, welche wir dann für einen einmaligen Import der
* Rechnugnsdaten verwenden können. * Rechnugnsdaten verwenden können.
* @throws PluginException *
* @throws RestAPIException * @throws PluginException
* @throws RestAPIException
* *
*/ */
@Test @Test
@Ignore
public void anlysiere() throws RestAPIException, PluginException { public void anlysiere() throws RestAPIException, PluginException {
System.out.println("***********************"); System.out.println("***********************");
@ -85,7 +89,6 @@ public class MigrationMahnerAusziffern {
Assert.assertTrue(fieldnames.contains("Kontonummer")); Assert.assertTrue(fieldnames.contains("Kontonummer"));
String line; String line;
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
@ -99,17 +102,16 @@ public class MigrationMahnerAusziffern {
analyzeLine(data, count); analyzeLine(data, count);
count++; count++;
// if (count>2800) { // if (count>2800) {
// break; // break;
// } // }
} }
System.out.println("================================================="); System.out.println("=================================================");
System.out.println("... fininshed - read " + count + " lines."); System.out.println("... fininshed - read " + count + " lines.");
System.out.println(" " + notFound + " Rechnungen nicht mehr aktiven Bestand"); System.out.println(" " + notFound + " Rechnungen nicht mehr aktiven Bestand");
System.out.println(" processed " + countProcessed + " Rechnungen in total"); System.out.println(" processed " + countProcessed + " Rechnungen in total");
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
@ -133,15 +135,13 @@ public class MigrationMahnerAusziffern {
* @param data * @param data
* @throws IOException * @throws IOException
* @throws RestAPIException * @throws RestAPIException
* @throws PluginException * @throws PluginException
*/ */
private void analyzeLine(String[] data, int line) throws IOException, RestAPIException, PluginException { private void analyzeLine(String[] data, int line) throws IOException, RestAPIException, PluginException {
System.out.println("...line " + count); System.out.println("...line " + count);
String rechnungsNummer = data[2]; String rechnungsNummer = data[2];
String rechnungsDatum = data[3]; String rechnungsDatum = data[3];
String faelligkeit = data[4]; String faelligkeit = data[4];
String saldo = data[7]; String saldo = data[7];
@ -193,38 +193,34 @@ public class MigrationMahnerAusziffern {
// nur wenn die Rechnung in Office ist // nur wenn die Rechnung in Office ist
if (findRechnung(rech.rechnungsNummer)) { if (findRechnung(rech.rechnungsNummer)) {
Rechnung matchingRech = findMatch(rech); Rechnung matchingRech = findMatch(rech);
if (matchingRech != null) { if (matchingRech != null) {
System.out.println("___________________________________________________"); System.out.println("___________________________________________________");
System.out.println(" Bitte Ausziffern : " + rech.konto + " = " + rech.rechnungsNummer + " -> " System.out.println(" Bitte Ausziffern : " + rech.konto + " = " + rech.rechnungsNummer + " -> "
+ matchingRech.rechnungsNummer); + matchingRech.rechnungsNummer);
// Starte RestAPI call..... // Starte RestAPI call.....
processRechnungen(rech.rechnungsNummer, matchingRech.rechnungsNummer); processRechnungen(rech.rechnungsNummer, matchingRech.rechnungsNummer);
// matchingRech muss aus dem cach raus // matchingRech muss aus dem cach raus
boolean removeresult=rechnungen.remove(matchingRech); boolean removeresult = rechnungen.remove(matchingRech);
if (removeresult==false) { if (removeresult == false) {
System.out.println(" ACHTUNG WIR haben ein Proboem "); System.out.println(" ACHTUNG WIR haben ein Proboem ");
throw new PluginException("ERROR", "ERROR", "Nichzt im chache!!!!!!"); throw new PluginException("ERROR", "ERROR", "Nichzt im chache!!!!!!");
} }
//throw new PluginException("STOP", "STOP", "STOP!!!!!!"); // throw new PluginException("STOP", "STOP", "STOP!!!!!!");
} else { } else {
// ab in den cache // ab in den cache
rechnungen.add(rech); rechnungen.add(rech);
} }
} else { } else {
// die rechnung gibts nicht und es gibt nicths zu prüfen // die rechnung gibts nicht und es gibt nicths zu prüfen
} }
} }
@ -239,9 +235,10 @@ public class MigrationMahnerAusziffern {
* *
* @throws UnsupportedEncodingException * @throws UnsupportedEncodingException
* @throws RestAPIException * @throws RestAPIException
* @throws PluginException * @throws PluginException
*/ */
private void processRechnungen(String rech1, String rech2) throws RestAPIException, UnsupportedEncodingException, PluginException { private void processRechnungen(String rech1, String rech2)
throws RestAPIException, UnsupportedEncodingException, PluginException {
// erstmal die Kanddaten suchen // erstmal die Kanddaten suchen
String query = "type:workitem AND $modelversion:rechnungsausgang-de-1.0 AND (invoice.number:" + rech1 String query = "type:workitem AND $modelversion:rechnungsausgang-de-1.0 AND (invoice.number:" + rech1
+ " OR invoice.number:" + rech2 + ")"; + " OR invoice.number:" + rech2 + ")";
@ -249,23 +246,22 @@ public class MigrationMahnerAusziffern {
List<ItemCollection> result = workflowCLient.searchDocuments(query); List<ItemCollection> result = workflowCLient.searchDocuments(query);
if (result == null || result.size() != 2) { if (result == null || result.size() != 2) {
System.out.println("Fehler - Rechnungen nicht gefunden!"); System.out.println("Fehler - Rechnungen nicht gefunden!");
notFound=notFound+2; notFound = notFound + 2;
return; return;
} }
System.out.println("Ich beginne jetzt mit Gabys Workflow..."); System.out.println("Ich beginne jetzt mit Gabys Workflow...");
ItemCollection rechItemCol=result.get(0); ItemCollection rechItemCol = result.get(0);
rechItemCol.event(420); rechItemCol.event(420);
workflowCLient.processWorkitem(rechItemCol); workflowCLient.processWorkitem(rechItemCol);
rechItemCol=result.get(1); rechItemCol = result.get(1);
rechItemCol.event(420); rechItemCol.event(420);
workflowCLient.processWorkitem(rechItemCol); workflowCLient.processWorkitem(rechItemCol);
countProcessed=countProcessed+2; countProcessed = countProcessed + 2;
} }
/** /**
* Teste ob es diese Rechnung im Office gibt. * Teste ob es diese Rechnung im Office gibt.
* *
@ -276,18 +272,17 @@ public class MigrationMahnerAusziffern {
*/ */
private boolean findRechnung(String rech1) throws RestAPIException, UnsupportedEncodingException, PluginException { private boolean findRechnung(String rech1) throws RestAPIException, UnsupportedEncodingException, PluginException {
// erstmal die Kanddaten suchen // erstmal die Kanddaten suchen
String query = "type:workitem AND $modelversion:rechnungsausgang-de-1.0 AND (invoice.number:" + rech1+ ")"; String query = "type:workitem AND $modelversion:rechnungsausgang-de-1.0 AND (invoice.number:" + rech1 + ")";
//System.out.println(query); // System.out.println(query);
List<ItemCollection> result = workflowCLient.searchDocuments(query); List<ItemCollection> result = workflowCLient.searchDocuments(query);
if (result != null && result.size() == 1) { if (result != null && result.size() == 1) {
//System.out.println(" OK - Rechnungen gefunden!"); // System.out.println(" OK - Rechnungen gefunden!");
return true; return true;
} }
return false; return false;
} }
/** /**
* Hilfsmethdoe die prüft ob es zu diesr Rechnung shcon eine passende * Hilfsmethdoe die prüft ob es zu diesr Rechnung shcon eine passende
* Gegenrechnung gibt. * Gegenrechnung gibt.
@ -361,8 +356,6 @@ public class MigrationMahnerAusziffern {
return MigrationMahnerAusziffern.this; return MigrationMahnerAusziffern.this;
} }
} }
} }

View file

@ -13,10 +13,13 @@ import java.util.List;
import org.imixs.workflow.exceptions.PluginException; import org.imixs.workflow.exceptions.PluginException;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import junit.framework.Assert; import junit.framework.Assert;
@Ignore
@Deprecated
public class MigrationMahnerDatev { public class MigrationMahnerDatev {
List<String> doppelteBuchungen = new ArrayList<String>(); List<String> doppelteBuchungen = new ArrayList<String>();
@ -36,6 +39,7 @@ public class MigrationMahnerDatev {
* *
*/ */
@Test @Test
@Ignore
public void migriere() { public void migriere() {
System.out.println("***********************"); System.out.println("***********************");
@ -62,7 +66,7 @@ public class MigrationMahnerDatev {
// write output file... // write output file...
BufferedWriter writer = new BufferedWriter(new FileWriter(filename_output)); BufferedWriter writer = new BufferedWriter(new FileWriter(filename_output));
writeEXTFHeader(writer,WJ); writeEXTFHeader(writer, WJ);
// Jetzt iterieren wir über die Input Datei und schreiben jeweilse eine Zeile // Jetzt iterieren wir über die Input Datei und schreiben jeweilse eine Zeile
// in die Output Datei... // in die Output Datei...
@ -100,9 +104,9 @@ public class MigrationMahnerDatev {
} }
count++; count++;
// if (count>25) { // if (count>25) {
// break; // break;
// } // }
} }
writer.close(); writer.close();
@ -138,10 +142,12 @@ public class MigrationMahnerDatev {
* @param writer * @param writer
* @throws IOException * @throws IOException
*/ */
private void writeEXTFHeader(BufferedWriter writer,String wj) throws IOException { private void writeEXTFHeader(BufferedWriter writer, String wj) throws IOException {
writer.write( writer.write(
"\"EXTF\";\"510\";21;\"Buchungsstapel\";7;\"20220721060421653\";\"\";\"CS\";\"cargoservice\";\"\";\"\";\"\";\"" + WJ + "0101\";\"4\";\"" + WJ + "0101\";\"" + WJ + "1231\";\"202206ALL\";\"CS\";\"\";\"\";0;\"EUR\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\""); "\"EXTF\";\"510\";21;\"Buchungsstapel\";7;\"20220721060421653\";\"\";\"CS\";\"cargoservice\";\"\";\"\";\"\";\""
+ WJ + "0101\";\"4\";\"" + WJ + "0101\";\"" + WJ
+ "1231\";\"202206ALL\";\"CS\";\"\";\"\";0;\"EUR\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\"");
writer.newLine(); writer.newLine();
writer.write( writer.write(
"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"); "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");
@ -158,17 +164,17 @@ public class MigrationMahnerDatev {
private void writeOutputLine(BufferedWriter writer, String[] data, int line) throws IOException { private void writeOutputLine(BufferedWriter writer, String[] data, int line) throws IOException {
String rechnungsNummer = data[2]; String rechnungsNummer = data[2];
String rechnungsDatum=data[3]; String rechnungsDatum = data[3];
String faelligkeit=data[4]; String faelligkeit = data[4];
String saldo=data[7]; String saldo = data[7];
String zahlung=data[6]; String zahlung = data[6];
// vertasuchen // vertasuchen
if (faelligkeit.length()==8) { if (faelligkeit.length() == 8) {
faelligkeit=faelligkeit.substring(4,8)+faelligkeit.substring(2,4)+faelligkeit.substring(0,2); faelligkeit = faelligkeit.substring(4, 8) + faelligkeit.substring(2, 4) + faelligkeit.substring(0, 2);
} else { } else {
faelligkeit="20230125"; faelligkeit = "20230125";
} }
String text=data[18]; String text = data[18];
String basisumsatz = "0,00"; String basisumsatz = "0,00";
String umsatz = data[5]; String umsatz = data[5];
if ("0,00".equals(umsatz)) { if ("0,00".equals(umsatz)) {
@ -195,36 +201,37 @@ public class MigrationMahnerDatev {
String gegenkonto = data[0]; String gegenkonto = data[0];
String konto = data[12]; String konto = data[12];
boolean skip=false; boolean skip = false;
if (rechnungsnummern.contains(rechnungsNummer)) { if (rechnungsnummern.contains(rechnungsNummer)) {
doppelteBuchungen.add(rechnungsNummer + "\tZahlung=" + zahlung + "\tSaldo="+saldo); doppelteBuchungen.add(rechnungsNummer + "\tZahlung=" + zahlung + "\tSaldo=" + saldo);
skip=true; skip = true;
} }
rechnungsnummern.add(rechnungsNummer); rechnungsnummern.add(rechnungsNummer);
if (skip) { if (skip) {
return; return;
} }
// umdrehen von sh // umdrehen von sh
if ("\"H\"".equals(sh)) { if ("\"H\"".equals(sh)) {
sh="\"S\""; sh = "\"S\"";
} else { } else {
sh="\"H\""; sh = "\"H\"";
} }
// umsätze // umsätze
writer.write(umsatz + ";" + sh + ";" + wkz + ";" + kurs + ";" + basisumsatz + ";"); writer.write(umsatz + ";" + sh + ";" + wkz + ";" + kurs + ";" + basisumsatz + ";");
// wkz // wkz
if (wkz.equals("\"EUR\"")) { if (wkz.equals("\"EUR\"")) {
writer.write(";"); writer.write(";");
} else { } else {
writer.write("\"EUR\";"); writer.write("\"EUR\";");
} }
// konten // konten
writer.write(konto + ";" + gegenkonto + ";;"); writer.write(konto + ";" + gegenkonto + ";;");
// datum und rechnungsnummer // datum und rechnungsnummer
writer.write(rechnungsDatum.substring(0,4) + ";" + rechnungsNummer + ";;;"+text + ";0;;;0;;;;;Faelligkeit;"+faelligkeit+";"); writer.write(rechnungsDatum.substring(0, 4) + ";" + rechnungsNummer + ";;;" + text + ";0;;;0;;;;;Faelligkeit;"
+ faelligkeit + ";");
writer.write(";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"); writer.write(";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;");
writer.newLine(); writer.newLine();
} }

View file

@ -1,19 +1,9 @@
package com.alexanderlogistics.migration; 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.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -26,8 +16,6 @@ import org.junit.Before;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import junit.framework.Assert;
/** /**
* Dieser Agent ordnet nachträglich Ausgangsrechnungen aus der Migraiton einem * Dieser Agent ordnet nachträglich Ausgangsrechnungen aus der Migraiton einem
* Space zu. * Space zu.
@ -35,6 +23,8 @@ import junit.framework.Assert;
* @author rsoika * @author rsoika
* *
*/ */
@Ignore
@Deprecated
public class MigrationSpaceZuordnung { public class MigrationSpaceZuordnung {
WorkflowClient workflowCLient = null; WorkflowClient workflowCLient = null;
@ -44,8 +34,8 @@ public class MigrationSpaceZuordnung {
int countProcessed = 0; int countProcessed = 0;
int notFound = 0; int notFound = 0;
int count = 0; int count = 0;
Map<String, List<String>> spacePosMappings=null; Map<String, List<String>> spacePosMappings = null;
Map<String, String> spaceNames=null; Map<String, String> spaceNames = null;
@Before @Before
public void setup() throws PluginException, RestAPIException, UnsupportedEncodingException { public void setup() throws PluginException, RestAPIException, UnsupportedEncodingException {
@ -55,10 +45,8 @@ public class MigrationSpaceZuordnung {
FormAuthenticator formAuth = new FormAuthenticator(restAPI, user, ps); FormAuthenticator formAuth = new FormAuthenticator(restAPI, user, ps);
workflowCLient.registerClientRequestFilter(formAuth); workflowCLient.registerClientRequestFilter(formAuth);
// load spaces Pos Expressions // load spaces Pos Expressions
loadSpacePosMappings(); loadSpacePosMappings();
} }
@ -68,10 +56,10 @@ public class MigrationSpaceZuordnung {
* *
* @throws PluginException * @throws PluginException
* @throws RestAPIException * @throws RestAPIException
* @throws UnsupportedEncodingException * @throws UnsupportedEncodingException
* *
*/ */
@Test @Test
@Ignore @Ignore
public void anlysiere() throws RestAPIException, PluginException, UnsupportedEncodingException { public void anlysiere() throws RestAPIException, PluginException, UnsupportedEncodingException {
@ -84,34 +72,33 @@ public class MigrationSpaceZuordnung {
String query = "$modelversion:\"rechnungsausgang-de-1.0\" AND type:workitem"; String query = "$modelversion:\"rechnungsausgang-de-1.0\" AND type:workitem";
int pageSize = 100; int pageSize = 100;
int pageIndex =0; int pageIndex = 0;
while (true) { while (true) {
workflowCLient.setPageIndex(pageIndex); workflowCLient.setPageIndex(pageIndex);
workflowCLient.setPageSize(pageSize); workflowCLient.setPageSize(pageSize);
workflowCLient.setSortBy("$created"); workflowCLient.setSortBy("$created");
List<ItemCollection> invoices = workflowCLient.searchDocuments(query); List<ItemCollection> invoices = workflowCLient.searchDocuments(query);
System.out.println("... ich processe " + invoices.size() + " invoices...");
System.out.println("... ich processe " + invoices.size() +" invoices...");
// teste space.ref // teste space.ref
for (ItemCollection invoice: invoices) { for (ItemCollection invoice : invoices) {
count++; count++;
boolean update=false; boolean update = false;
String currentSpaceRef=invoice.getItemValueString("space.ref"); String currentSpaceRef = invoice.getItemValueString("space.ref");
List<String> refList=invoice.getItemValueList("$uniqueidref",String.class); List<String> refList = invoice.getItemValueList("$uniqueidref", String.class);
if (currentSpaceRef.isEmpty() || !refList.contains(currentSpaceRef)) { if (currentSpaceRef.isEmpty() || !refList.contains(currentSpaceRef)) {
// Jezt noch das Space mapping // Jezt noch das Space mapping
// dazu kucken wir in alle spaces den config wert 'pos.mapping' // dazu kucken wir in alle spaces den config wert 'pos.mapping'
String text = invoice.getItemValueString("invoice.text"); String text = invoice.getItemValueString("invoice.text");
if (!text.isEmpty()) { if (!text.isEmpty()) {
for (Map.Entry<String, List<String> > entry : spacePosMappings.entrySet()) { for (Map.Entry<String, List<String>> entry : spacePosMappings.entrySet()) {
List<String> expressionsList=entry.getValue(); List<String> expressionsList = entry.getValue();
for (String expr : expressionsList) { for (String expr : expressionsList) {
Pattern p = Pattern.compile(expr); Pattern p = Pattern.compile(expr);
Matcher m = p.matcher(text); Matcher m = p.matcher(text);
if (m.find()) { if (m.find()) {
@ -119,8 +106,8 @@ public class MigrationSpaceZuordnung {
invoice.setItemValue("space.ref", entry.getKey()); invoice.setItemValue("space.ref", entry.getKey());
invoice.setItemValue("space.name", spaceNames.get(entry.getKey())); invoice.setItemValue("space.name", spaceNames.get(entry.getKey()));
invoice.appendItemValueUnique("$uniqueidref", entry.getKey()); invoice.appendItemValueUnique("$uniqueidref", entry.getKey());
update=true; update = true;
break; break;
} }
} }
@ -130,26 +117,25 @@ public class MigrationSpaceZuordnung {
} }
} }
} }
if (update) { if (update) {
// update invioce // update invioce
System.out.println("...ich update invoice: " + invoice.getUniqueID()); System.out.println("...ich update invoice: " + invoice.getUniqueID());
try { try {
workflowCLient.saveDocument(invoice); workflowCLient.saveDocument(invoice);
countProcessed++; countProcessed++;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
// fetrig? // fetrig?
if (invoices.size() < pageSize) { if (invoices.size() < pageSize) {
break; break;
} }
if (count>=maxCount) { if (count >= maxCount) {
break; break;
} }
pageIndex++; pageIndex++;
@ -165,12 +151,12 @@ public class MigrationSpaceZuordnung {
* Helper method that loads all expressions from the spaces * Helper method that loads all expressions from the spaces
* *
* @return List of list of expressions * @return List of list of expressions
* @throws UnsupportedEncodingException * @throws UnsupportedEncodingException
* @throws RestAPIException * @throws RestAPIException
*/ */
private void loadSpacePosMappings() throws RestAPIException, UnsupportedEncodingException { private void loadSpacePosMappings() throws RestAPIException, UnsupportedEncodingException {
spacePosMappings = new HashMap<>(); spacePosMappings = new HashMap<>();
spaceNames= new HashMap<>(); spaceNames = new HashMap<>();
// als erstes lesen wir die pos.mappings aus den Spaces ein, auf die dann eine // als erstes lesen wir die pos.mappings aus den Spaces ein, auf die dann eine
// Rechnung emapped werden kann. // Rechnung emapped werden kann.
@ -180,6 +166,5 @@ public class MigrationSpaceZuordnung {
spaceNames.put(space.getUniqueID(), space.getItemValueString("space.name")); spaceNames.put(space.getUniqueID(), space.getItemValueString("space.name"));
} }
} }
} }