update
This commit is contained in:
parent
c3a8957c25
commit
545bd30d92
2 changed files with 28 additions and 81 deletions
|
|
@ -129,9 +129,6 @@ public class DatevCargosoftImportAdapter implements SignalAdapter {
|
|||
private String INITIAL_MODEL_VERSION_INVOICE;
|
||||
private int INITIAL_TASK_ID_INVOICE;
|
||||
private int INITIAL_EVENT_ID_INVOICE;
|
||||
private String INITIAL_MODEL_VERSION_TAX;
|
||||
private int INITIAL_TASK_ID_TAX;
|
||||
private int INITIAL_EVENT_ID_TAX;
|
||||
|
||||
/**
|
||||
* This method finds or create the Datev Export and adds a reference
|
||||
|
|
@ -149,10 +146,6 @@ public class DatevCargosoftImportAdapter implements SignalAdapter {
|
|||
INITIAL_TASK_ID_INVOICE = 5001;
|
||||
INITIAL_EVENT_ID_INVOICE = 980;
|
||||
|
||||
INITIAL_MODEL_VERSION_TAX = "zollanmeldung-de-1.0";
|
||||
INITIAL_TASK_ID_TAX = 1000;
|
||||
INITIAL_EVENT_ID_TAX = 980;
|
||||
|
||||
// Try to read the optional cargosoft import options...
|
||||
ItemCollection evalItemCollection = workflowService.evalWorkflowResult(event, "datev-cargosoft-import",
|
||||
workitem, false);
|
||||
|
|
@ -170,20 +163,6 @@ public class DatevCargosoftImportAdapter implements SignalAdapter {
|
|||
if (INITIAL_EVENT_ID_INVOICE == 0) {
|
||||
INITIAL_EVENT_ID_INVOICE = 980; // set default
|
||||
}
|
||||
|
||||
// Zollanmeldung
|
||||
INITIAL_MODEL_VERSION_TAX = evalItemCollection.getItemValueString("model-tax");
|
||||
if (INITIAL_MODEL_VERSION_TAX.isEmpty()) {
|
||||
INITIAL_MODEL_VERSION_TAX = "zollanmeldung-de-1.0"; // set default
|
||||
}
|
||||
INITIAL_TASK_ID_TAX = evalItemCollection.getItemValueInteger("task-tax");
|
||||
if (INITIAL_TASK_ID_TAX == 0) {
|
||||
INITIAL_TASK_ID_TAX = 1000; // set default
|
||||
}
|
||||
INITIAL_EVENT_ID_TAX = evalItemCollection.getItemValueInteger("event-tax");
|
||||
if (INITIAL_EVENT_ID_TAX == 0) {
|
||||
INITIAL_EVENT_ID_TAX = 980; // set default
|
||||
}
|
||||
}
|
||||
try {
|
||||
// Datei einlesen
|
||||
|
|
@ -310,8 +289,7 @@ public class DatevCargosoftImportAdapter implements SignalAdapter {
|
|||
double basisumsatz = parseBetrag(DatevImportAdapter.csvVal(dataList[4]));
|
||||
|
||||
// Skip Eingangsrechnungen
|
||||
// Wenn es aber eine ATC Belegnummer ist dann ist es doch interessant
|
||||
if (!gegenKonto.startsWith("1") && !belegNummer.startsWith("ATC")) {
|
||||
if (!gegenKonto.startsWith("1")) {
|
||||
eingangsrechnungen++;
|
||||
// skip
|
||||
continue;
|
||||
|
|
@ -451,11 +429,8 @@ public class DatevCargosoftImportAdapter implements SignalAdapter {
|
|||
throws AdapterException {
|
||||
|
||||
// test if invoice was already imported before
|
||||
// zollanmeldung
|
||||
// String sQuery = "((type:workitem OR type:workitemarchive) AND
|
||||
// $modelversion:rechnungsausgang* AND invoice.number:\""
|
||||
// + belegNummer + "\")";
|
||||
String sQuery = "((type:workitem OR type:workitemarchive) AND ($modelversion:rechnungsausgang* OR $modelversion:zollanmeldung*) AND invoice.number:\""
|
||||
|
||||
String sQuery = "((type:workitem OR type:workitemarchive) AND $modelversion:rechnungsausgang* AND invoice.number:\""
|
||||
+ belegNummer + "\")";
|
||||
try {
|
||||
// find the textblock...
|
||||
|
|
@ -572,59 +547,10 @@ public class DatevCargosoftImportAdapter implements SignalAdapter {
|
|||
}
|
||||
}
|
||||
// Processe die Invoice
|
||||
// In Abhängkeit von der Belegart 'Ausgangsrechnung' | 'Zollanmeldung' wird ein
|
||||
// neues Workitem erzeugt.
|
||||
String belegNummer = datevWorkitem.getItemValueString("invoice.number");
|
||||
if (belegNummer.startsWith("ATC")) {
|
||||
// Zollanmeldung
|
||||
// Lookup Kreditor data... and switch dbtr to cdtr
|
||||
updateATCInvoice(datevWorkitem);
|
||||
datevWorkitem.model(INITIAL_MODEL_VERSION_TAX).task(INITIAL_TASK_ID_TAX).event(INITIAL_EVENT_ID_TAX);
|
||||
} else {
|
||||
// Normale Ausgangsrechnung
|
||||
datevWorkitem.model(INITIAL_MODEL_VERSION_INVOICE).task(INITIAL_TASK_ID_INVOICE)
|
||||
.event(INITIAL_EVENT_ID_INVOICE);
|
||||
}
|
||||
datevWorkitem.model(INITIAL_MODEL_VERSION_INVOICE).task(INITIAL_TASK_ID_INVOICE)
|
||||
.event(INITIAL_EVENT_ID_INVOICE);
|
||||
workflowService.processWorkItem(datevWorkitem);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This helper method updates some attributes of a DATEV Import regarding ATC
|
||||
* Invoice (Zollanmeldungen)
|
||||
*
|
||||
* Hier handelt es sich praktisch um eine Eingangsrechnung, daher tauschen wir
|
||||
* die Vorzeichen und dbtr/cdtr
|
||||
*
|
||||
* @param datevWorkitem
|
||||
* @throws PluginException
|
||||
*/
|
||||
private void updateATCInvoice(ItemCollection datevWorkitem) throws PluginException {
|
||||
String cdtrNumber = datevWorkitem.getItemValueString("dbtr.number");
|
||||
datevWorkitem.setItemValue("cdtr.number", cdtrNumber);
|
||||
datevWorkitem.removeItem("dbtr.number");
|
||||
ItemCollection creditor = kreditorDebitorService.findCreditor(cdtrNumber);
|
||||
if (creditor != null) {
|
||||
// update name....
|
||||
datevWorkitem.setItemValue(InvoiceUtil.ITEM_CDTR_NAME, creditor.getItemValueString("_VENDOR_Name"));
|
||||
}
|
||||
// Update invoice.positions
|
||||
InvoiceUtil.updateInvoicePositions(datevWorkitem);
|
||||
|
||||
// Switch S/H
|
||||
List<ItemCollection> childs = InvoiceUtil.explodeChildList(datevWorkitem);
|
||||
for (ItemCollection posItem : childs) {
|
||||
if (posItem.hasItem("datev.shzeichen")) {
|
||||
String sh = posItem.getItemValueString("datev.shzeichen");
|
||||
if ("S".equalsIgnoreCase(sh)) {
|
||||
sh = "H";
|
||||
} else {
|
||||
sh = "S";
|
||||
}
|
||||
posItem.setItemValue("datev.shzeichen", sh);
|
||||
}
|
||||
}
|
||||
InvoiceUtil.implodeChildList(datevWorkitem, childs);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -28,14 +28,19 @@
|
|||
|
||||
package com.alexanderlogistics.xml;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.enterprise.event.Observes;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.apache.commons.net.ftp.FTP;
|
||||
import org.apache.commons.net.ftp.FTPClient;
|
||||
|
|
@ -50,6 +55,10 @@ import org.imixs.workflow.exceptions.AccessDeniedException;
|
|||
import org.imixs.workflow.exceptions.ModelException;
|
||||
import org.imixs.workflow.exceptions.PluginException;
|
||||
import org.imixs.workflow.exceptions.ProcessingErrorException;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* Der CargosoftXMLInvoiceImportImportService erweitert den FTPImportService und
|
||||
|
|
@ -58,8 +67,7 @@ import org.imixs.workflow.exceptions.ProcessingErrorException;
|
|||
* konfiguriert werden.
|
||||
* <p>
|
||||
* Im Gegensatz zum FTPImportService werden die XML Dateien nach einem
|
||||
* speziellen
|
||||
* Verfahren geparsed und dann als Ausgangsrechnungen importiert.
|
||||
* speziellen Verfahren geparsed und dann als Ausgangsrechnungen importiert.
|
||||
* Der Service ersetzt den alten DATEV Import. Falls eine Rechnung schon
|
||||
* existiert (Rechnungsnummer) wird der Datensatz vom FTP Laufwerk gelöscht und
|
||||
* nicht importiert.
|
||||
|
|
@ -291,6 +299,19 @@ public class CargosoftXMLInvoiceImportImportService {
|
|||
workitem.event(source.getItemValueInteger(DocumentImportService.SOURCE_ITEM_EVENT));
|
||||
workitem.setWorkflowGroup(source.getItemValueString("workflowgroup"));
|
||||
|
||||
// Now we parse the rawData....
|
||||
InputStream inputStream = new ByteArrayInputStream(rawData);
|
||||
InputSource inputSource = new InputSource(inputStream);
|
||||
|
||||
DocumentBuilder documentBuilder;
|
||||
try {
|
||||
documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||
Document doc = documentBuilder.parse(inputSource);
|
||||
Node node = doc.importNode(doc.getDocumentElement(), true);
|
||||
} catch (ParserConfigurationException | SAXException | IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return workitem;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue