Skip to content

Commit

Permalink
improvements, minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rsoika committed Feb 5, 2025
1 parent 7a38eff commit cbfbc09
Show file tree
Hide file tree
Showing 6 changed files with 540 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*******************************************************************************/

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;

Expand All @@ -39,29 +40,22 @@
import org.imixs.workflow.engine.scheduler.Scheduler;
import org.imixs.workflow.exceptions.AccessDeniedException;
import org.imixs.workflow.exceptions.PluginException;
import org.imixs.workflow.faces.data.WorkflowController;
import org.imixs.workflow.faces.fileupload.FileUploadController;

import jakarta.annotation.PostConstruct;
import jakarta.enterprise.context.SessionScoped;
import jakarta.faces.model.SelectItem;
import jakarta.inject.Inject;
import jakarta.inject.Named;

/**
* The DatevController is used to configure the DatevScheduler. This service is
* used to generate datev export workitems.
* <p>
* The Controller creates a configuration entity "type=configuration;
* name=datev".
* The Controller creates a configuration entity:
* type=configuration name=datev
* <p>
* The following config items are defined:
*
* The following config items are defined:
*
* <pre>
* _model_version = model version for the SEPA export
* _initial_task = inital task ID
* </pre>
*
*
* @author rsoika
*
Expand Down Expand Up @@ -91,6 +85,9 @@ public class DatevController implements Serializable {
@Inject
DatevImportService datevImportService;

@Inject
WorkflowController workflowController;

@Inject
protected FileUploadController fileUploadController;

Expand Down Expand Up @@ -149,14 +146,220 @@ public ItemCollection loadConfiguration(String name) {
* @throws AccessDeniedException
*/
public ItemCollection saveConfiguration() {

configuration = datevService.saveConfiguration(configuration);

return configuration;
}

/**
* Itemcollection containing file import data
* Diese Methode liefert eine liste von SelectItem Elementen mit den Werten des
* Buchungsschlüssels zurück.
* <p>
* Der Buchungschlüssel wird in folgendem Format im config entity
* DATEV_CONFIGURATION gespeichert
*
* {@code
* BEZEICHNUNG | DATEV_BU_SCHLUESSEL | PROZENTSATZ
* }
*
* <p>
*
* @return
* @throws Exception
*/
@SuppressWarnings("unchecked")
public List<SelectItem> getBuSchluesel() throws Exception {

ArrayList<SelectItem> selection;
selection = new ArrayList<SelectItem>();

// check if a value for this param is available...
// if not return an empty list
if (!this.configuration.hasItem("datev.buschluessel")) {
return selection;
}

// get value list first value from vector if size >0
List<String> valueList = this.configuration.getItemValue("datev.buschluessel");
for (String aValue : valueList) {

String[] parts = aValue.split("\\|");

if (parts == null || parts.length < 3) {
logger.warning(
"Falsche Konfiguration der _buschluessel - Format: BEZEICHNUNG | DATEV_BU_SCHLUESSEL | PROZENTSATZ");
continue;
}
// Es wird hier der DATEV BU Schlüssel ausgegeben. Das MandantPlugin errechnet
// später den Prozentzsatz.
selection.add(new SelectItem(parts[1].trim(), parts[0].trim()));

}
return selection;
}

/**
* Returns costcentre1 from the Corporate Space as an ArrayList of SelectItems
* objects. A param entry can be devided by a | into a label and a value
* component. Example:
*
* <code>
* 17431 | Blaue Stadt I
17435 | Blaue Stadt I
17400 | Overhead/General
* </code>
*
* <code>
* <f:selectItems value="#{datevController.costcentre2}" />
* </code>
*
* @return
* @throws Exception
*/
public List<SelectItem> getCostcentre1() throws Exception {

ArrayList<SelectItem> selection;
selection = new ArrayList<SelectItem>();

// check if we have a workitem and space
if (workflowController.getWorkitem() == null) {
return selection;
}

// get value list first value from vector if size >0
List<?> valueList = configuration.getItemValue("datev.kostenstell1");
for (Object aValue : valueList) {
// test if aValue has a | as an delimiter
String sValue = aValue.toString();
String sName = sValue;

if (sValue.indexOf("|") > -1) {
sValue = sValue.substring(0, sValue.indexOf("|"));
sName = sName.substring(sName.indexOf("|") + 1);
}
selection.add(new SelectItem(sValue.trim(), sName.trim()));

}

return selection;
}

/**
* Gibt die Bezeichnung der Kostenstelle mit nummer - so wie bei suche
*
* @param value
* @return
*/
public String getCostcentre1Read(String value) {

// get value list first value from vector if size >0
List<String> valueList = configuration.getItemValue("datev.kostenstell1");

for (String aValue : valueList) {
String[] parts = aValue.split("\\|");
if (parts == null || parts.length < 1) {
return value;
}
String nummer = parts[0];
String bez = nummer;
if (parts.length > 1) {
bez = parts[1];
}

if (value.equals(nummer)) {
if (bez.startsWith(nummer)) {
return bez;
} else {
return nummer + " " + bez;
}
}
}

return value;
}

/**
* Returns costcentre2 from the Object Space as an ArrayList of SelectItems
* objects. A param entry can be devided by a | into a label and a value
* component. Example:
*
* <code>
* 17431 | Blaue Stadt I
17435 | Blaue Stadt I
17400 | Overhead/General
* </code>
*
* <code>
* <f:selectItems value="#{datevController.costcentre2}" />
* </code>
*
* @return
* @throws Exception
*/
public List<SelectItem> getCostcentre2() throws Exception {

ArrayList<SelectItem> selection;
selection = new ArrayList<SelectItem>();

// check if we have a workitem and space
if (workflowController.getWorkitem() == null) {
return selection;
}

// get value list first value from vector if size >0
List<?> valueList = configuration.getItemValue("datev.kostenstell2");
for (Object aValue : valueList) {
// test if aValue has a | as an delimiter
String sValue = aValue.toString();
String sName = sValue;

if (sValue.indexOf("|") > -1) {
sValue = sValue.substring(0, sValue.indexOf("|"));
sName = sName.substring(sName.indexOf("|") + 1);
}
selection.add(new SelectItem(sValue.trim(), sName.trim()));

}

return selection;
}

/**
* Gibt die Bezeichnung der Kostenstelle mit nummer - so wie bei suche
*
* @param value
* @return
*/
public String getCostcentre2Read(String value) {

// get value list first value from vector if size >0
List<String> valueList = configuration.getItemValue("datev.kostenstell2");

for (String aValue : valueList) {
String[] parts = aValue.split("\\|");
if (parts == null || parts.length < 1) {
return value;
}
String nummer = parts[0];
String bez = nummer;
if (parts.length > 1) {
bez = parts[1];
}

if (value.equals(nummer)) {
if (bez.startsWith(nummer)) {
return bez;
} else {
return nummer + " " + bez;
}
}
}

return value;
}

/**
* Itemcollection containing file import
* data
*
* @return
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,17 @@
import jakarta.xml.bind.JAXBException;

/**
* Der DatevExportService stellt methoden für den Datev export bereit
* Der DatevExportService stellt Methoden für den Datev export bereit
* <p>
* Unter anderem werden metadaten berechnet.
* Unter anderem werden Metadaten berechnet.
* <p>
* _stapelzeitraum_start und _stapelzeitraum_ende markieren die äterste und die
* jüngste Rechnung. Diese Daten weren für die DATEV Kopf Datei benötigt.
* _stapelzeitraum_start und _stapelzeitraum_ende markieren die älterste und die
* jüngste Rechnung. Diese Daten werden für die DATEV Kopf Datei benötigt.
* <p>
* Change: 13.01.2021
* <p>
* Belegbilder dürfen immer nur einmal in der documents.xml drin stehen auch
* wenn diese mehrfach in verschiedenne Buchungssätzen verwendet werden. Daher
* wenn diese mehrfach in verschiedene Buchungssätzen verwendet werden. Daher
* prüfen wir beim Aufbau der documents.xml ob das belegbild schon generiert
* wurde.
*
Expand Down Expand Up @@ -390,14 +390,14 @@ public void buildCSVFile(ItemCollection datevExport, List<ItemCollection> data,
stapelZeitraumEnde = invoiceDate;
}
}
// update Stapelzeitruam begin und Ende
// update Stapelzeitraum begin und Ende
if (stapelZeitraumStart != null) {
// Begin stapelzeitrum
datevExport.replaceItemValue("_stapelzeitraum_start",
datevExport.replaceItemValue("datev.stapelzeitraum.start",
Date.from(stapelZeitraumStart.atZone(ZoneId.systemDefault()).toInstant()));

// Ende Stapelzeitraum
datevExport.replaceItemValue("_stapelzeitraum_ende",
datevExport.replaceItemValue("datev.stapelzeitraum.ende",
Date.from(stapelZeitraumEnde.atZone(ZoneId.systemDefault()).toInstant()));

}
Expand Down Expand Up @@ -531,7 +531,7 @@ public boolean putFileData(FileData fileData, ItemCollection configuration, Stri

if (result == true) {
DatevHelper.logMessage(
"...FTP file transfer '" + ftpPathReports + fileData.getName() + "' successfull", configuration,
"...FTP file transfer '" + ftpPathReports + fileData.getName() + "' successful", configuration,
datevExport);
} else {
throw new PluginException(DatevExportService.class.getName(), ITEM_FTP_ERROR,
Expand Down
Loading

0 comments on commit cbfbc09

Please sign in to comment.