From 406f0a415b6ddea5cada923d9c702213ca861adb Mon Sep 17 00:00:00 2001 From: Ralph Soika Date: Thu, 8 Sep 2022 17:12:35 +0200 Subject: [PATCH] update cargosoft export --- .../datev/CargosoftExportController.java | 81 ++++++ .../datev/CargosoftExportScheduler.java | 162 +++++++++++ .../datev/DatevCargosoftImportAdapter.java | 15 +- .../layout/commandbox_admin_custom.xhtml | 2 +- .../webapp/pages/admin/cargosoft_export.xhtml | 149 ++++++++++ .../webapp/pages/admin/datev_config.xhtml | 263 ------------------ 6 files changed, 404 insertions(+), 268 deletions(-) create mode 100644 office-alexander-logistics-app/src/main/java/com/alexanderlogistics/datev/CargosoftExportController.java create mode 100644 office-alexander-logistics-app/src/main/java/com/alexanderlogistics/datev/CargosoftExportScheduler.java create mode 100644 office-alexander-logistics-app/src/main/webapp/pages/admin/cargosoft_export.xhtml delete mode 100644 office-alexander-logistics-app/src/main/webapp/pages/admin/datev_config.xhtml diff --git a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/datev/CargosoftExportController.java b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/datev/CargosoftExportController.java new file mode 100644 index 0000000..a78c5b3 --- /dev/null +++ b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/datev/CargosoftExportController.java @@ -0,0 +1,81 @@ +package com.alexanderlogistics.datev; +/******************************************************************************* + * Imixs Workflow Technology + * Copyright (C) 2003, 2008 Imixs Software Solutions GmbH, + * http://www.imixs.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You can receive a copy of the GNU General Public + * License at http://www.gnu.org/licenses/gpl.html + * + * Contributors: + * Imixs Software Solutions GmbH - initial API and implementation + * Ralph Soika + * + *******************************************************************************/ + +import java.util.logging.Logger; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Named; + +import org.imixs.workflow.datev.imports.DatevImportScheduler; +import org.imixs.workflow.engine.scheduler.SchedulerController; + +/** + * The DatevController is used to configure the DatevScheduler. This service is + * used to generate datev export workitems. + *

+ * The Controller creates a configuration entity "type=configuration; + * txtname=datev". + *

+ * The following config items are defined: + * + * The following config items are defined: + * + *

+ * _model_version = model version for the SEPA export
+ * _initial_task = inital task ID
+ * 
+ * + * + * @author rsoika + * + */ +@Named +@RequestScoped +public class CargosoftExportController extends SchedulerController { + + public static final String CARGOSOFT_EXPORT_CONFIGURATION = "CARGOSOFT_EXPORT_CONFIGURATION"; + + private static final long serialVersionUID = 1L; + private static Logger logger = Logger.getLogger(CargosoftExportController.class.getName()); + + @Override + public String getName() { + return CARGOSOFT_EXPORT_CONFIGURATION; + } + + /** + * Returns the sepa scheduler class name. This name depends on the _export_type. + * + * There are two export interfaces available - csv and XML + * + */ + @Override + public String getSchedulerClass() { + String schedulerClass = CargosoftExportScheduler.class.getName(); + logger.finest("...... scheduler: " + schedulerClass); + return schedulerClass; + } + +} diff --git a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/datev/CargosoftExportScheduler.java b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/datev/CargosoftExportScheduler.java new file mode 100644 index 0000000..74dbf44 --- /dev/null +++ b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/datev/CargosoftExportScheduler.java @@ -0,0 +1,162 @@ +/******************************************************************************* + * Imixs Workflow Technology + * Copyright (C) 2001, 2008 Imixs Software Solutions GmbH, + * http://www.imixs.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You can receive a copy of the GNU General Public + * License at http://www.gnu.org/licenses/gpl.html + * + * Contributors: + * Imixs Software Solutions GmbH - initial API and implementation + * Ralph Soika + *******************************************************************************/ +package com.alexanderlogistics.datev; + +import java.io.ByteArrayOutputStream; +import java.text.DateFormat; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.List; +import java.util.logging.Logger; + +import javax.ejb.EJB; + +import org.imixs.workflow.ItemCollection; +import org.imixs.workflow.engine.DocumentService; +import org.imixs.workflow.engine.ModelService; +import org.imixs.workflow.engine.ReportService; +import org.imixs.workflow.engine.WorkflowService; +import org.imixs.workflow.engine.scheduler.Scheduler; +import org.imixs.workflow.engine.scheduler.SchedulerException; +import org.imixs.workflow.engine.scheduler.SchedulerService; +import org.imixs.workflow.exceptions.QueryException; + +/** + * The CargosoftExportScheduler exports a csv file with kreditor data + *

+ * The class implements the interface + * _org.imixs.workflow.engine.scheduler.Scheduler_ and can be used in + * combination with the Imxis-Workflow Scheduler Service. + * + * @see SchedulerService + * @author rsoika + * + */ +public class CargosoftExportScheduler implements Scheduler { + + public static final int MAX_COUNT = 999; + + public static DateFormat dateFormat = new SimpleDateFormat("ddMMyyyy"); + public static DecimalFormat decimalFormat = new DecimalFormat("0.00"); + public static DecimalFormat rateFormat = new DecimalFormat("0.000000"); + + @EJB + DocumentService documentService; + + @EJB + WorkflowService workflowService; + + @EJB + ModelService modelService; + + @EJB + ReportService reportService; + + private static Logger logger = Logger.getLogger(CargosoftExportScheduler.class.getName()); + + /** + * This is the method which processes the timeout event depending on the running + * timer settings. + * + * + * + * @param timer + * @throws QueryException + */ + public ItemCollection run(ItemCollection configuration) throws SchedulerException { + ByteArrayOutputStream outputStream = null; + List invoices = null; + String reportName = ""; + ItemCollection datevExport = null; + int maxCount = configuration.getItemValueInteger("_maxcount"); + if (maxCount == 0) { + maxCount = -1; + } + + logger.info("....export to Cargosoft..."); + // $taskID<5900 + String sQuery = "(type:workitem AND $modelversion:rechnungsausgang* AND $taskid:[5000 TO 5899])"; + + try { + // find the textblock... + invoices = documentService.find(sQuery, 9999, 0); + } catch (QueryException e) { + logger.warning("failed to search invoices by query: " + e.getMessage()); + } + + if (invoices != null && invoices.size() > 0) { + // File csvOutputFile = new File(CSV_FILE_NAME); + for (ItemCollection doc : invoices) { + String line = ""; + line = line + doc.getItemValueString("dbtr.number") + ";"; + line = line + "\"" + doc.getItemValueString("dbtr.name") + "\";"; + line = line + "\"" + doc.getItemValueString("invoice.number") + "\";"; + line = line + dateFormat.format(doc.getItemValueDate("invoice.date")) + ";"; + line = line + dateFormat.format(doc.getItemValueDate("invoice.duedate")) + ";"; + + // Betrag soll; Betrag Haben; + double betrag = doc.getItemValueDouble("invoice.total"); + if (betrag >= 0) { + // Soll + line = line + decimalFormat.format(betrag) + ";0,00;"; + } else { + // Haben + line = line + "0,00;" + decimalFormat.format(Math.abs(betrag)) + ";"; + + } + // Saldo; S/H Saldo + betrag = doc.getItemValueDouble("invoice.saldo"); + if (betrag >= 0) { + // Soll + line = line + decimalFormat.format(betrag) + ";S;"; + } else { + // Haben + line = line + decimalFormat.format(Math.abs(betrag)) + ";H;"; + } + + // WKZ + String wkz = doc.getItemValueString("invoice.currency"); + if (!"EUR".equals(wkz)) { + line = line + wkz + ";" + rateFormat.format(doc.getItemValueDouble("invoice.rate")) + ";" + + decimalFormat.format(doc.getItemValueDouble("invoice.base.amount")) + ";"; + } else { + line = line + ";0,000000;0,00;"; + } + + + //77 ; + int i=77; + while(i>0) { + line = line + ";"; + i--; + } + + logger.info(line); + } + + } + + return configuration; + } + +} diff --git a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/datev/DatevCargosoftImportAdapter.java b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/datev/DatevCargosoftImportAdapter.java index 49c4abf..557905b 100644 --- a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/datev/DatevCargosoftImportAdapter.java +++ b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/datev/DatevCargosoftImportAdapter.java @@ -152,7 +152,9 @@ public class DatevCargosoftImportAdapter implements SignalAdapter { String paymentTerm= DatevImportAdapter.csvVal(header1List[31]); String waehrung = DatevImportAdapter.csvVal(header1List[2]); - + // kurse + double kurs=parseBetrag(DatevImportAdapter.csvVal(header1List[3])); + double basisumsatz= parseBetrag(DatevImportAdapter.csvVal(header1List[4])); // Skip Eingangsrechnungen if (!gegenKonto.startsWith("1")) { @@ -181,7 +183,7 @@ public class DatevCargosoftImportAdapter implements SignalAdapter { if (invoiceWorkitem == null) { logger.info("...create new workitem...."); // erzeuge ein neues - invoiceWorkitem =createEmptyInvoice(belegNummer,text,gegenKonto,dateBuchung,dueDate,paymentTerm,waehrung ); + invoiceWorkitem =createEmptyInvoice(belegNummer,text,gegenKonto,dateBuchung,dueDate,paymentTerm,waehrung,kurs,basisumsatz ); } // ist es noch die selbe Belegnummer? @@ -199,7 +201,7 @@ public class DatevCargosoftImportAdapter implements SignalAdapter { splitBuchungen = new ArrayList(); // invoice zurücksetzten // erzeuge ein neues - invoiceWorkitem =createEmptyInvoice(belegNummer,text,gegenKonto,dateBuchung,dueDate,paymentTerm,waehrung ); + invoiceWorkitem =createEmptyInvoice(belegNummer,text,gegenKonto,dateBuchung,dueDate,paymentTerm,waehrung,kurs,basisumsatz ); splitBuchungen.add(dataItemCol); } @@ -213,7 +215,8 @@ public class DatevCargosoftImportAdapter implements SignalAdapter { } - private ItemCollection createEmptyInvoice(String belegNummer, String text, String gegenKonto, Date dateBuchung,Date dueDate,String paymentTerm,String currency) { + private ItemCollection createEmptyInvoice(String belegNummer, String text, String gegenKonto, Date dateBuchung,Date dueDate,String paymentTerm,String currency, + double kurs,double basisUmsatz) { ItemCollection invoiceWorkitem = new ItemCollection(); invoiceWorkitem.setItemValue("invoice.number", belegNummer); invoiceWorkitem.setItemValue("invoice.currency", currency); @@ -224,6 +227,10 @@ public class DatevCargosoftImportAdapter implements SignalAdapter { invoiceWorkitem.setItemValue("invoice.reminder", dueDate); invoiceWorkitem.setItemValue("payment.term",paymentTerm); + + invoiceWorkitem.setItemValue("invoice.rate",kurs); + invoiceWorkitem.setItemValue("invoice.base.amount",basisUmsatz); + return invoiceWorkitem; } diff --git a/office-alexander-logistics-app/src/main/webapp/layout/commandbox_admin_custom.xhtml b/office-alexander-logistics-app/src/main/webapp/layout/commandbox_admin_custom.xhtml index 6cad4aa..5c4a886 100644 --- a/office-alexander-logistics-app/src/main/webapp/layout/commandbox_admin_custom.xhtml +++ b/office-alexander-logistics-app/src/main/webapp/layout/commandbox_admin_custom.xhtml @@ -6,7 +6,7 @@

diff --git a/office-alexander-logistics-app/src/main/webapp/pages/admin/cargosoft_export.xhtml b/office-alexander-logistics-app/src/main/webapp/pages/admin/cargosoft_export.xhtml new file mode 100644 index 0000000..29f9c23 --- /dev/null +++ b/office-alexander-logistics-app/src/main/webapp/pages/admin/cargosoft_export.xhtml @@ -0,0 +1,149 @@ + + + + + + + + + +
+
+

Ausgangsrechnungen

+ + + + +
+ + + +
+ + +
+ + + +
+ + +
+ + + +
+
+
FTP Server / Port
+
+ + + + : + + + +
+
+
+
FTP UserID / Passwort
+
+ + + + / + + +
+
+
+ + +
+
+
FTP Verzeichnis Buchungsstapel
+
+ + +
+
+
+
FTP Verzeichnis
+
+ + +
+
+

+ Die Verzeichnisse + werden mit der DATEV Mandanten ID ergänzt und müssen vor dem + Export angelegt worden sein! +

+
+

Scheduler

+ + + + +
+
+
+
+ + + +
+
+
+
+ + + +
diff --git a/office-alexander-logistics-app/src/main/webapp/pages/admin/datev_config.xhtml b/office-alexander-logistics-app/src/main/webapp/pages/admin/datev_config.xhtml deleted file mode 100644 index 8d958d3..0000000 --- a/office-alexander-logistics-app/src/main/webapp/pages/admin/datev_config.xhtml +++ /dev/null @@ -1,263 +0,0 @@ - - - - - - - - - - - - - - - -
-
-

DATEV

- - - - -
- - - -
- - -
- - - -
- - -
-
-

Import DATEV Buchungsstapel

-

Definieren Sie hier den Inport eines Buchunsstapel. Der - Import erfolgt im DATEV Standardformat (CSV Datei)

-

Das Workflow Modell gibt an mit welchem Worklfow die - Datensätze importiert werden sollen

-
- -
- -
-
- Workflow Model Version * -
-
- - -
-
- -
-
- Initial Task * -
-
- - -
-
- -
- - - - -
-

- The initial task - must define a report containing the query and style sheet - information. Invoices will be automatically grouped by the - optional attribute "_datev_client_id". The datev workflow may - optional include a "invoice_update" item definition. -

-
- - - -
-
-
FTP Server / Port
-
- - - - : - - - -
-
-
-
FTP UserID / Passwort
-
- - - - / - - -
-
-
- - -
-
-
FTP Verzeichnis Buchungsstapel
-
- - -
-
-
-
FTP Verzeichnis Belege
-
- - -
-
-

- Die Verzeichnisse - werden mit der DATEV Mandanten ID ergänzt und müssen vor dem - Export angelegt worden sein! -

-
- - - -

Scheduler

- - - - -
- -
- -
- -
-
-

Import DATEV Stammdaten

-
    -
  • Fügen Sie hier die zu importierende DATEV Datei an.
  • -
  • Die Datei muss im CSV Format vorliegen.
  • - -
  • Die Datei muss zwei Header Zeilen enthalten: -
      -
    1. Zeile: Datenart - z.B. "Kontobeschriftungen"
    2. -
    3. Zeile: Feldbezeichnungen - z.B. "Konto, - Kontobezeichnung"
    4. -
    -
  • -
  • Fügen Sie immer nur eine Datei für den Import an!
  • -
  • Der Import kann einige Minuten in Anspruch nehmen.
  • -
  • Brechen Sie den Vorgang nicht ab und warten Sie bis - der Import vollständig abgeschlossen ist.
  • -
-
- -
-
Importdatei wählen:
-
- - -
#{kriegerImportController.importData.item['log']}
- -
-
-
- - - - -
- -
- -
- - -
- - - - - - -
-
-
-
- - - -