fixed junit tests
This commit is contained in:
parent
2464753877
commit
1ad63b644c
6 changed files with 129 additions and 146 deletions
|
|
@ -85,7 +85,7 @@ public class TestIMAPAuhtenticators {
|
|||
source.setItemValue(DocumentImportService.SOURCE_ITEM_SERVER, "outlook.office365.com");
|
||||
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");
|
||||
|
||||
Properties sourceOptions = new Properties();
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import com.sun.mail.imap.IMAPFolder;
|
|||
|
||||
import junit.framework.Assert;
|
||||
|
||||
|
||||
/**
|
||||
* This test shows how to access outlook via oauth2
|
||||
*
|
||||
|
|
@ -91,7 +90,7 @@ public class TestIMAPOutlookOAuth {
|
|||
// try to connect...
|
||||
token = getAuthToken();
|
||||
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");
|
||||
|
||||
Assert.assertNotNull(store);
|
||||
|
|
|
|||
|
|
@ -1,15 +1,12 @@
|
|||
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.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -19,10 +16,13 @@ import org.imixs.workflow.ItemCollection;
|
|||
import org.imixs.workflow.datev.imports.DatevImportAdapter;
|
||||
import org.imixs.workflow.exceptions.PluginException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
@Ignore
|
||||
@Deprecated
|
||||
public class DueDateBugfix {
|
||||
|
||||
WorkflowClient workflowCLient = null;
|
||||
|
|
@ -46,13 +46,15 @@ public class DueDateBugfix {
|
|||
*
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
public void fixe() {
|
||||
|
||||
System.out.println("***********************");
|
||||
System.out.println("* Bugfix *");
|
||||
System.out.println("***********************");
|
||||
|
||||
/* Erledigte
|
||||
|
||||
/*
|
||||
* Erledigte
|
||||
*
|
||||
*
|
||||
* EXTF_202301_202302030602_1295
|
||||
|
|
@ -121,48 +123,45 @@ public class DueDateBugfix {
|
|||
|
||||
// suche Rechnung
|
||||
String query = "$modelversion:\"rechnungsausgang-de-1.0\" AND type:workitem AND invoice.number:\""
|
||||
+ belegNummer+"\"";
|
||||
+ belegNummer + "\"";
|
||||
|
||||
workflowCLient.setPageSize(1);
|
||||
List<ItemCollection> invoices = workflowCLient.searchDocuments(query);
|
||||
|
||||
if (invoices.size()==1) {
|
||||
ItemCollection invoice=invoices.get(0);
|
||||
|
||||
|
||||
if (invoices.size() == 1) {
|
||||
ItemCollection invoice = invoices.get(0);
|
||||
|
||||
Date bugDate = invoice.getItemValueDate("invoice.duedate");
|
||||
|
||||
|
||||
|
||||
if (!dueDate.equals(bugDate)) {
|
||||
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.reminder", dueDate);
|
||||
|
||||
if (invoice.getTaskID()==5100) {
|
||||
|
||||
if (invoice.getTaskID() == 5100) {
|
||||
invoice.event(20);
|
||||
workflowCLient.processWorkitem(invoice);
|
||||
|
||||
|
||||
} else {
|
||||
workflowCLient.saveDocument(invoice);
|
||||
workflowCLient.saveDocument(invoice);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
System.out.println(".... OK " + belegNummer + " -> " + dueDate + " Bugi Date="+bugDate);
|
||||
System.out.println(".... OK " + belegNummer + " -> " + dueDate + " Bugi Date=" + bugDate);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
System.out.println(".... " + belegNummer + " ist unbekannt");
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println("hat nicht geklappt: "+e.getMessage());
|
||||
System.out.println("hat nicht geklappt: " + e.getMessage());
|
||||
}
|
||||
count++;
|
||||
|
||||
//if (fixes>0) break;
|
||||
|
||||
// if (fixes>0) break;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
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;
|
||||
|
|
@ -19,10 +17,13 @@ import org.imixs.melman.WorkflowClient;
|
|||
import org.imixs.workflow.ItemCollection;
|
||||
import org.imixs.workflow.exceptions.PluginException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
@Ignore
|
||||
@Deprecated
|
||||
public class MigrationMahnerAusziffern {
|
||||
|
||||
List<Rechnung> rechnungen = new ArrayList<Rechnung>();
|
||||
|
|
@ -31,9 +32,10 @@ public class MigrationMahnerAusziffern {
|
|||
String user = "archive";
|
||||
String ps = "archive4imixs";
|
||||
String restAPI = "https://alexander-logistics.office-workflow.de/api";
|
||||
int countProcessed=0;
|
||||
int notFound=0;
|
||||
int countProcessed = 0;
|
||||
int notFound = 0;
|
||||
int count = 0;
|
||||
|
||||
@Before
|
||||
public void setup() throws PluginException, RestAPIException {
|
||||
rechnungen = new ArrayList<Rechnung>();
|
||||
|
|
@ -41,14 +43,14 @@ public class MigrationMahnerAusziffern {
|
|||
workflowCLient = new WorkflowClient(restAPI);
|
||||
FormAuthenticator formAuth = new FormAuthenticator(restAPI, user, ps);
|
||||
workflowCLient.registerClientRequestFilter(formAuth);
|
||||
|
||||
|
||||
ItemCollection ding = workflowCLient.getWorkitem("1ef4757f-69ae-4ec1-8ba1-01d380d046e7");
|
||||
|
||||
if (ding!=null) {
|
||||
|
||||
if (ding != null) {
|
||||
System.out.println("pip");
|
||||
} else {
|
||||
System.out.println("pap");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -56,11 +58,13 @@ public class MigrationMahnerAusziffern {
|
|||
* 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
|
||||
* Rechnugnsdaten verwenden können.
|
||||
* @throws PluginException
|
||||
* @throws RestAPIException
|
||||
*
|
||||
* @throws PluginException
|
||||
* @throws RestAPIException
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
public void anlysiere() throws RestAPIException, PluginException {
|
||||
|
||||
System.out.println("***********************");
|
||||
|
|
@ -85,7 +89,6 @@ public class MigrationMahnerAusziffern {
|
|||
Assert.assertTrue(fieldnames.contains("Kontonummer"));
|
||||
|
||||
String line;
|
||||
|
||||
|
||||
while ((line = br.readLine()) != null) {
|
||||
|
||||
|
|
@ -99,17 +102,16 @@ public class MigrationMahnerAusziffern {
|
|||
|
||||
analyzeLine(data, count);
|
||||
count++;
|
||||
|
||||
// if (count>2800) {
|
||||
// break;
|
||||
// }
|
||||
|
||||
|
||||
// if (count>2800) {
|
||||
// break;
|
||||
// }
|
||||
|
||||
}
|
||||
System.out.println("=================================================");
|
||||
System.out.println("... fininshed - read " + count + " lines.");
|
||||
System.out.println(" " + notFound + " Rechnungen nicht mehr aktiven Bestand");
|
||||
System.out.println(" processed " + countProcessed + " Rechnungen in total");
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
|
@ -133,15 +135,13 @@ public class MigrationMahnerAusziffern {
|
|||
* @param data
|
||||
* @throws IOException
|
||||
* @throws RestAPIException
|
||||
* @throws PluginException
|
||||
* @throws PluginException
|
||||
*/
|
||||
private void analyzeLine(String[] data, int line) throws IOException, RestAPIException, PluginException {
|
||||
|
||||
|
||||
System.out.println("...line " + count);
|
||||
String rechnungsNummer = data[2];
|
||||
|
||||
|
||||
|
||||
|
||||
String rechnungsDatum = data[3];
|
||||
String faelligkeit = data[4];
|
||||
String saldo = data[7];
|
||||
|
|
@ -193,38 +193,34 @@ public class MigrationMahnerAusziffern {
|
|||
|
||||
// nur wenn die Rechnung in Office ist
|
||||
if (findRechnung(rech.rechnungsNummer)) {
|
||||
|
||||
|
||||
Rechnung matchingRech = findMatch(rech);
|
||||
if (matchingRech != null) {
|
||||
System.out.println("___________________________________________________");
|
||||
System.out.println(" Bitte Ausziffern : " + rech.konto + " = " + rech.rechnungsNummer + " -> "
|
||||
+ matchingRech.rechnungsNummer);
|
||||
|
||||
|
||||
// Starte RestAPI call.....
|
||||
processRechnungen(rech.rechnungsNummer, matchingRech.rechnungsNummer);
|
||||
|
||||
|
||||
// matchingRech muss aus dem cach raus
|
||||
boolean removeresult=rechnungen.remove(matchingRech);
|
||||
if (removeresult==false) {
|
||||
boolean removeresult = rechnungen.remove(matchingRech);
|
||||
if (removeresult == false) {
|
||||
System.out.println(" ACHTUNG WIR haben ein Proboem ");
|
||||
throw new PluginException("ERROR", "ERROR", "Nichzt im chache!!!!!!");
|
||||
}
|
||||
|
||||
//throw new PluginException("STOP", "STOP", "STOP!!!!!!");
|
||||
|
||||
|
||||
// throw new PluginException("STOP", "STOP", "STOP!!!!!!");
|
||||
|
||||
} else {
|
||||
// ab in den cache
|
||||
rechnungen.add(rech);
|
||||
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
// die rechnung gibts nicht und es gibt nicths zu prüfen
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -239,9 +235,10 @@ public class MigrationMahnerAusziffern {
|
|||
*
|
||||
* @throws UnsupportedEncodingException
|
||||
* @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
|
||||
String query = "type:workitem AND $modelversion:rechnungsausgang-de-1.0 AND (invoice.number:" + rech1
|
||||
+ " OR invoice.number:" + rech2 + ")";
|
||||
|
|
@ -249,23 +246,22 @@ public class MigrationMahnerAusziffern {
|
|||
List<ItemCollection> result = workflowCLient.searchDocuments(query);
|
||||
if (result == null || result.size() != 2) {
|
||||
System.out.println("Fehler - Rechnungen nicht gefunden!");
|
||||
notFound=notFound+2;
|
||||
notFound = notFound + 2;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
System.out.println("Ich beginne jetzt mit Gabys Workflow...");
|
||||
ItemCollection rechItemCol=result.get(0);
|
||||
ItemCollection rechItemCol = result.get(0);
|
||||
rechItemCol.event(420);
|
||||
workflowCLient.processWorkitem(rechItemCol);
|
||||
|
||||
rechItemCol=result.get(1);
|
||||
rechItemCol = result.get(1);
|
||||
rechItemCol.event(420);
|
||||
workflowCLient.processWorkitem(rechItemCol);
|
||||
|
||||
countProcessed=countProcessed+2;
|
||||
countProcessed = countProcessed + 2;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Teste ob es diese Rechnung im Office gibt.
|
||||
*
|
||||
|
|
@ -276,18 +272,17 @@ public class MigrationMahnerAusziffern {
|
|||
*/
|
||||
private boolean findRechnung(String rech1) throws RestAPIException, UnsupportedEncodingException, PluginException {
|
||||
// erstmal die Kanddaten suchen
|
||||
String query = "type:workitem AND $modelversion:rechnungsausgang-de-1.0 AND (invoice.number:" + rech1+ ")";
|
||||
//System.out.println(query);
|
||||
String query = "type:workitem AND $modelversion:rechnungsausgang-de-1.0 AND (invoice.number:" + rech1 + ")";
|
||||
// System.out.println(query);
|
||||
List<ItemCollection> result = workflowCLient.searchDocuments(query);
|
||||
if (result != null && result.size() == 1) {
|
||||
//System.out.println(" OK - Rechnungen gefunden!");
|
||||
// System.out.println(" OK - Rechnungen gefunden!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Hilfsmethdoe die prüft ob es zu diesr Rechnung shcon eine passende
|
||||
* Gegenrechnung gibt.
|
||||
|
|
@ -361,8 +356,6 @@ public class MigrationMahnerAusziffern {
|
|||
return MigrationMahnerAusziffern.this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,10 +13,13 @@ import java.util.List;
|
|||
|
||||
import org.imixs.workflow.exceptions.PluginException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
@Ignore
|
||||
@Deprecated
|
||||
public class MigrationMahnerDatev {
|
||||
|
||||
List<String> doppelteBuchungen = new ArrayList<String>();
|
||||
|
|
@ -36,6 +39,7 @@ public class MigrationMahnerDatev {
|
|||
*
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
public void migriere() {
|
||||
|
||||
System.out.println("***********************");
|
||||
|
|
@ -62,7 +66,7 @@ public class MigrationMahnerDatev {
|
|||
|
||||
// write output file...
|
||||
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
|
||||
// in die Output Datei...
|
||||
|
|
@ -100,9 +104,9 @@ public class MigrationMahnerDatev {
|
|||
}
|
||||
count++;
|
||||
|
||||
// if (count>25) {
|
||||
// break;
|
||||
// }
|
||||
// if (count>25) {
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
|
||||
writer.close();
|
||||
|
|
@ -138,10 +142,12 @@ public class MigrationMahnerDatev {
|
|||
* @param writer
|
||||
* @throws IOException
|
||||
*/
|
||||
private void writeEXTFHeader(BufferedWriter writer,String wj) throws IOException {
|
||||
private void writeEXTFHeader(BufferedWriter writer, String wj) throws IOException {
|
||||
|
||||
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.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");
|
||||
|
|
@ -158,17 +164,17 @@ public class MigrationMahnerDatev {
|
|||
private void writeOutputLine(BufferedWriter writer, String[] data, int line) throws IOException {
|
||||
|
||||
String rechnungsNummer = data[2];
|
||||
String rechnungsDatum=data[3];
|
||||
String faelligkeit=data[4];
|
||||
String saldo=data[7];
|
||||
String zahlung=data[6];
|
||||
String rechnungsDatum = data[3];
|
||||
String faelligkeit = data[4];
|
||||
String saldo = data[7];
|
||||
String zahlung = data[6];
|
||||
// vertasuchen
|
||||
if (faelligkeit.length()==8) {
|
||||
faelligkeit=faelligkeit.substring(4,8)+faelligkeit.substring(2,4)+faelligkeit.substring(0,2);
|
||||
if (faelligkeit.length() == 8) {
|
||||
faelligkeit = faelligkeit.substring(4, 8) + faelligkeit.substring(2, 4) + faelligkeit.substring(0, 2);
|
||||
} else {
|
||||
faelligkeit="20230125";
|
||||
faelligkeit = "20230125";
|
||||
}
|
||||
String text=data[18];
|
||||
String text = data[18];
|
||||
String basisumsatz = "0,00";
|
||||
String umsatz = data[5];
|
||||
if ("0,00".equals(umsatz)) {
|
||||
|
|
@ -195,36 +201,37 @@ public class MigrationMahnerDatev {
|
|||
String gegenkonto = data[0];
|
||||
String konto = data[12];
|
||||
|
||||
boolean skip=false;
|
||||
boolean skip = false;
|
||||
if (rechnungsnummern.contains(rechnungsNummer)) {
|
||||
doppelteBuchungen.add(rechnungsNummer + "\tZahlung=" + zahlung + "\tSaldo="+saldo);
|
||||
skip=true;
|
||||
doppelteBuchungen.add(rechnungsNummer + "\tZahlung=" + zahlung + "\tSaldo=" + saldo);
|
||||
skip = true;
|
||||
}
|
||||
rechnungsnummern.add(rechnungsNummer);
|
||||
if (skip) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// umdrehen von sh
|
||||
if ("\"H\"".equals(sh)) {
|
||||
sh="\"S\"";
|
||||
sh = "\"S\"";
|
||||
} else {
|
||||
sh="\"H\"";
|
||||
sh = "\"H\"";
|
||||
}
|
||||
|
||||
|
||||
// umsätze
|
||||
writer.write(umsatz + ";" + sh + ";" + wkz + ";" + kurs + ";" + basisumsatz + ";");
|
||||
// wkz
|
||||
if (wkz.equals("\"EUR\"")) {
|
||||
writer.write(";");
|
||||
} else {
|
||||
writer.write("\"EUR\";");
|
||||
writer.write("\"EUR\";");
|
||||
}
|
||||
// konten
|
||||
writer.write(konto + ";" + gegenkonto + ";;");
|
||||
// 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.newLine();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,9 @@
|
|||
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;
|
||||
|
||||
|
|
@ -26,8 +16,6 @@ import org.junit.Before;
|
|||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
/**
|
||||
* Dieser Agent ordnet nachträglich Ausgangsrechnungen aus der Migraiton einem
|
||||
* Space zu.
|
||||
|
|
@ -35,6 +23,8 @@ import junit.framework.Assert;
|
|||
* @author rsoika
|
||||
*
|
||||
*/
|
||||
@Ignore
|
||||
@Deprecated
|
||||
public class MigrationSpaceZuordnung {
|
||||
|
||||
WorkflowClient workflowCLient = null;
|
||||
|
|
@ -44,8 +34,8 @@ public class MigrationSpaceZuordnung {
|
|||
int countProcessed = 0;
|
||||
int notFound = 0;
|
||||
int count = 0;
|
||||
Map<String, List<String>> spacePosMappings=null;
|
||||
Map<String, String> spaceNames=null;
|
||||
Map<String, List<String>> spacePosMappings = null;
|
||||
Map<String, String> spaceNames = null;
|
||||
|
||||
@Before
|
||||
public void setup() throws PluginException, RestAPIException, UnsupportedEncodingException {
|
||||
|
|
@ -55,10 +45,8 @@ public class MigrationSpaceZuordnung {
|
|||
FormAuthenticator formAuth = new FormAuthenticator(restAPI, user, ps);
|
||||
workflowCLient.registerClientRequestFilter(formAuth);
|
||||
|
||||
|
||||
// load spaces Pos Expressions
|
||||
loadSpacePosMappings();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -68,10 +56,10 @@ public class MigrationSpaceZuordnung {
|
|||
*
|
||||
* @throws PluginException
|
||||
* @throws RestAPIException
|
||||
* @throws UnsupportedEncodingException
|
||||
* @throws UnsupportedEncodingException
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
@Test
|
||||
@Ignore
|
||||
public void anlysiere() throws RestAPIException, PluginException, UnsupportedEncodingException {
|
||||
|
||||
|
|
@ -84,34 +72,33 @@ public class MigrationSpaceZuordnung {
|
|||
String query = "$modelversion:\"rechnungsausgang-de-1.0\" AND type:workitem";
|
||||
|
||||
int pageSize = 100;
|
||||
int pageIndex =0;
|
||||
int pageIndex = 0;
|
||||
while (true) {
|
||||
workflowCLient.setPageIndex(pageIndex);
|
||||
workflowCLient.setPageSize(pageSize);
|
||||
workflowCLient.setSortBy("$created");
|
||||
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
|
||||
for (ItemCollection invoice: invoices) {
|
||||
for (ItemCollection invoice : invoices) {
|
||||
count++;
|
||||
boolean update=false;
|
||||
|
||||
String currentSpaceRef=invoice.getItemValueString("space.ref");
|
||||
List<String> refList=invoice.getItemValueList("$uniqueidref",String.class);
|
||||
boolean update = false;
|
||||
|
||||
String currentSpaceRef = invoice.getItemValueString("space.ref");
|
||||
List<String> refList = invoice.getItemValueList("$uniqueidref", String.class);
|
||||
if (currentSpaceRef.isEmpty() || !refList.contains(currentSpaceRef)) {
|
||||
|
||||
|
||||
// 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 (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()) {
|
||||
|
|
@ -119,8 +106,8 @@ public class MigrationSpaceZuordnung {
|
|||
invoice.setItemValue("space.ref", entry.getKey());
|
||||
invoice.setItemValue("space.name", spaceNames.get(entry.getKey()));
|
||||
invoice.appendItemValueUnique("$uniqueidref", entry.getKey());
|
||||
|
||||
update=true;
|
||||
|
||||
update = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -130,26 +117,25 @@ public class MigrationSpaceZuordnung {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (update) {
|
||||
// update invioce
|
||||
System.out.println("...ich update invoice: " + invoice.getUniqueID());
|
||||
try {
|
||||
workflowCLient.saveDocument(invoice);
|
||||
countProcessed++;
|
||||
workflowCLient.saveDocument(invoice);
|
||||
countProcessed++;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// fetrig?
|
||||
if (invoices.size() < pageSize) {
|
||||
break;
|
||||
}
|
||||
if (count>=maxCount) {
|
||||
if (count >= maxCount) {
|
||||
break;
|
||||
}
|
||||
pageIndex++;
|
||||
|
|
@ -165,12 +151,12 @@ public class MigrationSpaceZuordnung {
|
|||
* Helper method that loads all expressions from the spaces
|
||||
*
|
||||
* @return List of list of expressions
|
||||
* @throws UnsupportedEncodingException
|
||||
* @throws RestAPIException
|
||||
* @throws UnsupportedEncodingException
|
||||
* @throws RestAPIException
|
||||
*/
|
||||
private void loadSpacePosMappings() throws RestAPIException, UnsupportedEncodingException {
|
||||
spacePosMappings = new HashMap<>();
|
||||
spaceNames= new HashMap<>();
|
||||
spaceNames = new HashMap<>();
|
||||
// als erstes lesen wir die pos.mappings aus den Spaces ein, auf die dann eine
|
||||
// Rechnung emapped werden kann.
|
||||
|
||||
|
|
@ -180,6 +166,5 @@ public class MigrationSpaceZuordnung {
|
|||
spaceNames.put(space.getUniqueID(), space.getItemValueString("space.name"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue