update migration agl
This commit is contained in:
parent
d8e824f153
commit
5bc6225765
4 changed files with 243 additions and 78 deletions
|
|
@ -340,19 +340,37 @@
|
|||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- JUnit Tests -->
|
||||
<dependency>
|
||||
<groupId>javax.json</groupId>
|
||||
<artifactId>javax.json-api</artifactId>
|
||||
<version>1.1</version>
|
||||
<scope>test</scope>
|
||||
<groupId>javax.json</groupId>
|
||||
<artifactId>javax.json-api</artifactId>
|
||||
<version>1.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.glassfish</groupId>
|
||||
<artifactId>javax.json</artifactId>
|
||||
<version>1.1</version>
|
||||
<scope>test</scope>
|
||||
<groupId>org.glassfish</groupId>
|
||||
<artifactId>javax.json</artifactId>
|
||||
<version>1.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- JAX-RS 2.0 Test dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.core</groupId>
|
||||
<artifactId>jersey-client</artifactId>
|
||||
<version>2.30.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-rs-client</artifactId>
|
||||
<version>3.3.6</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.imixs.workflow</groupId>
|
||||
<artifactId>imixs-melman</artifactId>
|
||||
<version>1.0.22</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
|
|
|||
|
|
@ -237,13 +237,12 @@ public class OPListController implements Serializable {
|
|||
public void updateChildList(ItemCollection workitem) {
|
||||
double paymentTotal = 0;
|
||||
List<Map> mapInvoiceItems = new ArrayList<Map>();
|
||||
// convert the child ItemCollection elements into a List of Map
|
||||
logger.info("Convert child items into Map...");
|
||||
logger.fine("Convert child items into Map...");
|
||||
// iterate over all order items..
|
||||
List<String> selectionList = new ArrayList<String>();
|
||||
for (ItemCollection invoice : invoiceList) {
|
||||
if (invoice.getItemValueBoolean("selected")) {
|
||||
logger.info("calculate - " + invoice.getUniqueID());
|
||||
logger.fine("calculate - " + invoice.getUniqueID());
|
||||
selectionList.add(invoice.getUniqueID());
|
||||
paymentTotal = paymentTotal + invoice.getItemValueDouble("payment.amount");
|
||||
ItemCollection invoiceStub = new ItemCollection();
|
||||
|
|
|
|||
|
|
@ -8,9 +8,15 @@ 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.List;
|
||||
import java.util.Objects;
|
||||
|
||||
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;
|
||||
|
|
@ -21,20 +27,41 @@ public class MigrationMahnerAusziffern {
|
|||
|
||||
List<Rechnung> rechnungen = new ArrayList<Rechnung>();
|
||||
|
||||
|
||||
WorkflowClient workflowCLient = null;
|
||||
String user = "archive";
|
||||
String ps = "archive4imixs";
|
||||
String restAPI = "https://alexander-logistics.office-workflow.de/api";
|
||||
int countProcessed=0;
|
||||
int notFound=0;
|
||||
int count = 0;
|
||||
@Before
|
||||
public void setup() throws PluginException {
|
||||
List<Rechnung> rechnungen = new ArrayList<Rechnung>();
|
||||
public void setup() throws PluginException, RestAPIException {
|
||||
rechnungen = new ArrayList<Rechnung>();
|
||||
// Init Workflow Client
|
||||
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) {
|
||||
System.out.println("pip");
|
||||
} else {
|
||||
System.out.println("pap");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void anlysiere() {
|
||||
public void anlysiere() throws RestAPIException, PluginException {
|
||||
|
||||
System.out.println("***********************");
|
||||
System.out.println("* OP Listen Auszifferliste *");
|
||||
|
|
@ -57,10 +84,7 @@ public class MigrationMahnerAusziffern {
|
|||
|
||||
Assert.assertTrue(fieldnames.contains("Kontonummer"));
|
||||
|
||||
|
||||
|
||||
String line;
|
||||
int count = 0;
|
||||
|
||||
|
||||
while ((line = br.readLine()) != null) {
|
||||
|
|
@ -73,17 +97,18 @@ public class MigrationMahnerAusziffern {
|
|||
Assert.fail();
|
||||
}
|
||||
|
||||
analyzeLine(data,count);
|
||||
analyzeLine(data, count);
|
||||
count++;
|
||||
|
||||
// if (count>25) {
|
||||
// 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) {
|
||||
|
|
@ -101,29 +126,33 @@ public class MigrationMahnerAusziffern {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Prüft eine einzelen Datenzeile
|
||||
*
|
||||
* @param writer
|
||||
* @param data
|
||||
* @throws IOException
|
||||
* @throws RestAPIException
|
||||
* @throws PluginException
|
||||
*/
|
||||
private void analyzeLine(String[] data, int line) throws IOException {
|
||||
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];
|
||||
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)) {
|
||||
|
|
@ -150,26 +179,52 @@ public class MigrationMahnerAusziffern {
|
|||
String gegenkonto = data[0];
|
||||
String konto = data[12];
|
||||
|
||||
boolean skip=false;
|
||||
boolean skip = false;
|
||||
|
||||
// umdrehen von sh
|
||||
if ("\"H\"".equals(sh)) {
|
||||
sh="\"S\"";
|
||||
sh = "\"S\"";
|
||||
} else {
|
||||
sh="\"H\"";
|
||||
sh = "\"H\"";
|
||||
}
|
||||
|
||||
|
||||
|
||||
// cache diese Information
|
||||
Rechnung rech=new Rechnung(gegenkonto,rechnungsNummer,umsatz,sh, wkz);
|
||||
Rechnung rech = new Rechnung(gegenkonto, rechnungsNummer, umsatz, sh, wkz);
|
||||
|
||||
Rechnung matchingRech=findMatch(rech);
|
||||
if (matchingRech!=null) {
|
||||
System.out.println(" Bitte Ausziffern : "+rech.konto + " = " +rech.rechnungsNummer + " -> "+matchingRech.rechnungsNummer);
|
||||
// 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) {
|
||||
System.out.println(" ACHTUNG WIR haben ein Proboem ");
|
||||
throw new PluginException("ERROR", "ERROR", "Nichzt im chache!!!!!!");
|
||||
}
|
||||
|
||||
//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
|
||||
}
|
||||
|
||||
rechnungen.add(rech);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -177,26 +232,80 @@ public class MigrationMahnerAusziffern {
|
|||
return (data.isEmpty() || "\"\"".equals(data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Diese Methode schließt die Rechnungen mit den übergebenen Rechnungsnummer ab
|
||||
*
|
||||
* Beispiel: Bitte Ausziffern : 17755 = "190818" -> "190313"
|
||||
*
|
||||
* @throws UnsupportedEncodingException
|
||||
* @throws RestAPIException
|
||||
* @throws 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 + ")";
|
||||
System.out.println(query);
|
||||
List<ItemCollection> result = workflowCLient.searchDocuments(query);
|
||||
if (result == null || result.size() != 2) {
|
||||
System.out.println("Fehler - Rechnungen nicht gefunden!");
|
||||
notFound=notFound+2;
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println("Ich beginne jetzt mit Gabys Workflow...");
|
||||
ItemCollection rechItemCol=result.get(0);
|
||||
rechItemCol.event(420);
|
||||
workflowCLient.processWorkitem(rechItemCol);
|
||||
|
||||
rechItemCol=result.get(1);
|
||||
rechItemCol.event(420);
|
||||
workflowCLient.processWorkitem(rechItemCol);
|
||||
|
||||
countProcessed=countProcessed+2;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Hilfsmethdoe die prüft ob es zu diesr Rechnung shcon eine passende Gegenrechnung gibt.
|
||||
* @param rech
|
||||
* @return
|
||||
*/
|
||||
/**
|
||||
* Teste ob es diese Rechnung im Office gibt.
|
||||
*
|
||||
* @param rech1
|
||||
* @throws RestAPIException
|
||||
* @throws UnsupportedEncodingException
|
||||
* @throws PluginException
|
||||
*/
|
||||
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);
|
||||
List<ItemCollection> result = workflowCLient.searchDocuments(query);
|
||||
if (result != null && result.size() == 1) {
|
||||
//System.out.println(" OK - Rechnungen gefunden!");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Hilfsmethdoe die prüft ob es zu diesr Rechnung shcon eine passende
|
||||
* Gegenrechnung gibt.
|
||||
*
|
||||
* @param rech
|
||||
* @return
|
||||
*/
|
||||
private Rechnung findMatch(Rechnung rech) {
|
||||
|
||||
// gehen über all rechnungen und vergleiche alle eigenschaften
|
||||
for (Rechnung matchRech: rechnungen) {
|
||||
for (Rechnung matchRech : rechnungen) {
|
||||
|
||||
if (rech.rechnungsNummer.equals(matchRech.rechnungsNummer)) {
|
||||
System.out.println(" !! Rechnungsnummer Doppelt : " +rech.rechnungsNummer);
|
||||
System.out.println(" !! Rechnungsnummer Doppelt : " + rech.rechnungsNummer);
|
||||
}
|
||||
|
||||
if (rech.konto.equals(matchRech.konto )
|
||||
&& rech.umsatz.equals(matchRech.umsatz)
|
||||
&& rech.wkz.equals(matchRech.wkz)
|
||||
&& !rech.sh.equals(matchRech.sh)) {
|
||||
if (rech.konto.equals(matchRech.konto) && rech.umsatz.equals(matchRech.umsatz)
|
||||
&& rech.wkz.equals(matchRech.wkz) && !rech.sh.equals(matchRech.sh)) {
|
||||
// Hurrar wir habne eine treffer
|
||||
return matchRech;
|
||||
}
|
||||
|
|
@ -213,6 +322,7 @@ public class MigrationMahnerAusziffern {
|
|||
String umsatz;
|
||||
String sh;
|
||||
String wkz;
|
||||
|
||||
public Rechnung(String konto, String rechnungsNummer, String umsatz, String sh, String wkz) {
|
||||
super();
|
||||
this.konto = konto;
|
||||
|
|
@ -222,6 +332,37 @@ public class MigrationMahnerAusziffern {
|
|||
this.wkz = wkz;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + getEnclosingInstance().hashCode();
|
||||
result = prime * result + Objects.hash(konto, rechnungsNummer, sh, umsatz, wkz);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Rechnung other = (Rechnung) obj;
|
||||
if (!getEnclosingInstance().equals(other.getEnclosingInstance()))
|
||||
return false;
|
||||
return Objects.equals(konto, other.konto) && Objects.equals(rechnungsNummer, other.rechnungsNummer)
|
||||
&& Objects.equals(sh, other.sh) && Objects.equals(umsatz, other.umsatz)
|
||||
&& Objects.equals(wkz, other.wkz);
|
||||
}
|
||||
|
||||
private MigrationMahnerAusziffern getEnclosingInstance() {
|
||||
return MigrationMahnerAusziffern.this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- origin at X=0.0 Y=0.0 -->
|
||||
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:ext="http://org.eclipse.bpmn2/ext" xmlns:imixs="http://www.imixs.org/bpmn2" xmlns:xs="http://www.w3.org/2001/XMLSchema" id="Definitions_1" exporter="org.eclipse.bpmn2.modeler.core" exporterVersion="1.5.2.SNAPSHOT-v20200602-1600-B1" targetNamespace="http://www.imixs.org/bpmn2">
|
||||
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:ext="http://org.eclipse.bpmn2/ext" xmlns:imixs="http://www.imixs.org/bpmn2" xmlns:xs="http://www.w3.org/2001/XMLSchema" id="Definitions_1" exporter="org.eclipse.bpmn2.modeler.core" exporterVersion="1.5.4.RC1-v20220528-0836-B1" targetNamespace="http://www.imixs.org/bpmn2">
|
||||
<bpmn2:extensionElements>
|
||||
<imixs:item name="txtworkflowmodelversion" type="xs:string">
|
||||
<imixs:value><![CDATA[rechnungsausgang-de-1.0]]></imixs:value>
|
||||
|
|
@ -2278,6 +2278,7 @@ Wiedervorlage wird um 7 bzw. 5 Tage erhöht</bpmn2:text>
|
|||
<bpmn2:association id="Association_7" sourceRef="DataObject_2" targetRef="Task_5005"/>
|
||||
<bpmn2:association id="Association_8" sourceRef="DataObject_2" targetRef="Task_3"/>
|
||||
<bpmn2:association id="Association_9" sourceRef="DataObject_2" targetRef="Task_4"/>
|
||||
<bpmn2:association id="Association_10" sourceRef="DataObject_2" targetRef="Task_6"/>
|
||||
</bpmn2:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_Process_1" bpmnElement="Collaboration_1">
|
||||
|
|
@ -2999,6 +3000,12 @@ Wiedervorlage wird um 7 bzw. 5 Tage erhöht</bpmn2:text>
|
|||
<di:waypoint xsi:type="dc:Point" x="573.0" y="728.0"/>
|
||||
<bpmndi:BPMNLabel id="BPMNLabel_93"/>
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="BPMNEdge_Association_10" bpmnElement="Association_10" sourceElement="BPMNShape_DataObject_1" targetElement="BPMNShape_Task_1">
|
||||
<di:waypoint xsi:type="dc:Point" x="897.0" y="589.0"/>
|
||||
<di:waypoint xsi:type="dc:Point" x="1410.0" y="589.0"/>
|
||||
<di:waypoint xsi:type="dc:Point" x="1410.0" y="490.0"/>
|
||||
<bpmndi:BPMNLabel id="BPMNLabel_94"/>
|
||||
</bpmndi:BPMNEdge>
|
||||
</bpmndi:BPMNPlane>
|
||||
<bpmndi:BPMNLabelStyle id="BPMNLabelStyle_1">
|
||||
<dc:Font name="arial" size="9.0"/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue