Skip to content

Commit

Permalink
datev export (Issue #171)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsoika committed Feb 11, 2025
1 parent e5b8f8b commit 711729e
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public List<SelectItem> getBuSchluesel() throws Exception {
* @return
* @throws Exception
*/
public List<SelectItem> getCostcentre1() throws Exception {
public List<SelectItem> getKostenstelle1() throws Exception {

ArrayList<SelectItem> selection;
selection = new ArrayList<SelectItem>();
Expand All @@ -224,10 +224,13 @@ public List<SelectItem> getCostcentre1() throws Exception {
}

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

if (sValue.indexOf("|") > -1) {
Expand All @@ -247,10 +250,11 @@ public List<SelectItem> getCostcentre1() throws Exception {
* @param value
* @return
*/
public String getCostcentre1Read(String value) {
@SuppressWarnings("unchecked")
public String getKostenstelle1Read(String value) {

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

for (String aValue : valueList) {
String[] parts = aValue.split("\\|");
Expand Down Expand Up @@ -293,7 +297,7 @@ public String getCostcentre1Read(String value) {
* @return
* @throws Exception
*/
public List<SelectItem> getCostcentre2() throws Exception {
public List<SelectItem> getKostenstelle2() throws Exception {

ArrayList<SelectItem> selection;
selection = new ArrayList<SelectItem>();
Expand All @@ -304,10 +308,13 @@ public List<SelectItem> getCostcentre2() throws Exception {
}

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

if (sValue.indexOf("|") > -1) {
Expand All @@ -327,10 +334,11 @@ public List<SelectItem> getCostcentre2() throws Exception {
* @param value
* @return
*/
public String getCostcentre2Read(String value) {
@SuppressWarnings("unchecked")
public String getKostenstelle2Read(String value) {

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

for (String aValue : valueList) {
String[] parts = aValue.split("\\|");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ void init() {
* }
*/
public void searchSachkonto() {
searchSachkonto(null);
}

public void searchSachkonto(String regexPattern) {

List<ItemCollection> dataList = null;
searchResult = new ArrayList<DatevSearchEntry>();
Expand All @@ -120,14 +124,28 @@ public void searchSachkonto() {
logger.finest(".......trigger searchSachkonto: " + phrase);
// DATEV Sachkonten suchen
dataList = searchEntity(phrase, "kontenbeschriftungen");

// Compile the regex pattern
logger.fine("regex=" + regexPattern);
Pattern pattern = null;
if (regexPattern != null && !regexPattern.isEmpty()) {
pattern = Pattern.compile(regexPattern);
}
for (ItemCollection dbtr : dataList) {
String kontoNumber = dbtr.getItemValueString("_konto");
String display = kontoNumber + " - " + dbtr.getItemValueString("_kontobeschriftung");
String kontoNummer = dbtr.getItemValueString("_konto");
// Prüfen, ob die Kontonummer der Regex entspricht
if (pattern != null) {
Matcher matcher = pattern.matcher(kontoNummer);
if (!matcher.matches()) {
// Kein passendes Konto
continue;
}
}

String display = kontoNummer + " - " + dbtr.getItemValueString("_kontobeschriftung");

display = display.replace("\"", "");
display = display.replace("'", "");
searchResult.add(new DatevSearchEntry(kontoNumber, display, buildSachkontoJsonData(dbtr)));
searchResult.add(new DatevSearchEntry(kontoNummer, display, buildSachkontoJsonData(dbtr)));
}
}

Expand Down Expand Up @@ -173,7 +191,6 @@ public void searchDebitorCreditor(String regexPattern) {
if (!matcher.matches()) {
// Kein passendes Konto
continue;

}
}
String kontoName = konto.getItemValueString("_name");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.logging.Logger;
Expand Down Expand Up @@ -147,7 +148,17 @@ public ItemCollection updateExportWorkitem(ItemCollection datevExport,
// copy sachkontenlaenge from first invoice..
datevExport.setItemValue(DatevService.ITEM_DATEV_KONTENLAENGE,
firstInvoice.getItemValue(DatevService.ITEM_DATEV_KONTENLAENGE));
} else {
// nein - wir haben keine also nehemen wir die Zetral gepflegte
String fs = configuration.getItemValueString(DatevService.ITEM_DATEV_FISCAL_START);
Date invoiceDate = firstInvoice.getItemValueDate("invoice.date");

Calendar calendar = Calendar.getInstance();
calendar.setTime(invoiceDate);
fs = "" + calendar.get(Calendar.YEAR) + fs;
datevExport.setItemValue(DatevService.ITEM_DATEV_FISCAL_START, fs);
}

}

// haben wir bereits eine Consultant ID von der Rechnung erhalten?
Expand All @@ -156,6 +167,7 @@ public ItemCollection updateExportWorkitem(ItemCollection datevExport,
datevExport.setItemValue(DatevService.ITEM_DATEV_CONSULTANT_ID,
configuration.getItemValue(DatevService.ITEM_DATEV_CONSULTANT_ID));
}

return datevExport;
}

Expand Down Expand Up @@ -608,30 +620,6 @@ public ItemCollection buildExportWorkitem(ItemCollection configuration, String m
return datevExport;
}

/**
* Loads the DATEV configuration entity by name. The method returns null if no
* configuration exits.
*
* @return
*/
// public ItemCollection loadConfiguration(String name) {
// try {
// // support deprecated txtname attribure
// String sQuery = "(type:\"" + DatevService.DOCUMENT_TYPE + "\" AND (name:\"" +
// name + "\" OR txtname:\""
// + name + "\" ) )";
// Collection<ItemCollection> col = documentService.find(sQuery, 1, 0);
// // check if we found a configuration
// if (col.size() > 0) {
// ItemCollection configuration = col.iterator().next();
// return configuration;
// }
// } catch (QueryException e1) {
// e1.printStackTrace();
// }
// return null;
// }

/**
* Helper Method to copute the grouping key
*
Expand Down
2 changes: 1 addition & 1 deletion imixs-adapters-datev/src/main/webapp/datev_config.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
for="fiscalstart" /></span>
</dt>
<dd>
<h:inputText value="#{datevController.configuration.item['datev..FiscalStart']}"
<h:inputText value="#{datevController.configuration.item['datev.fiscal_start']}"
id="fiscalstart" required="false"/>
</dd>
</dl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,23 @@
<h:panelGroup layout="block" styleClass="imixs-form-section" style="position: relative;"
id="bookinglist" binding="#{bookinglistContainer}">


<ui:param name="hasKostenstelle1" value="#{!empty datevController.kostenstelle1}"></ui:param>
<ui:param name="hasKostenstelle2" value="#{!empty datevController.kostenstelle2}"></ui:param>

<c:if test="#{!readonly}">
<h:commandScript name="sachkontoSearch" action="#{datevSearchController.searchSachkonto()}"
render="autocomplete-resultlist-datev-sachkonto" onevent="autocompleteShowResult" />
<table class="imixsdatatable imixs-bookingitems">
<tr>
<th style="width: 300px;">Buchungskonto</th>
<!--
<th style="width: 100px;">Kostenstelle I.</th>
<th style="width: 100px;">Kostenstelle II.</th>
-->
<th style="width: 200px;">Buchungskonto</th>
<!-- -->
<ui:fragment rendered="#{hasKostenstelle1}">
<th style="width: 140px;">Kostenstelle I.</th>
</ui:fragment>
<ui:fragment rendered="#{hasKostenstelle2}">
<th style="width: 140px;">Kostenstelle II.</th>
</ui:fragment>
<th style="width: 170px;">BU Schlüssel</th>
<th style="min-width: 120px;">Betrag</th>
<th style="width: 10px;">
Expand All @@ -42,18 +49,21 @@

</td>

<!-- Kostenstelle
<td><h:selectOneMenu style="width:100%;"
value="#{bookingItem.item['datev.kostenstelle1']}">
<f:selectItem itemLabel="" itemValue="" />
<f:selectItems value="#{datevDataController.costcentre1}"></f:selectItems>
</h:selectOneMenu></td>
<td><h:selectOneMenu style="width:100%;"
value="#{bookingItem.item['datev.kostenstelle2']}">
<f:selectItem itemLabel="" itemValue="" />
<f:selectItems value="#{datevDataController.costcentre2}"></f:selectItems>
</h:selectOneMenu></td>
-->
<!-- Kostenstelle -->
<ui:fragment rendered="#{!empty datevController.kostenstelle1}">
<td><h:selectOneMenu style="width:100%;"
value="#{bookingItem.item['datev.kostenstelle1']}">
<f:selectItem itemLabel="" itemValue="" />
<f:selectItems value="#{datevController.kostenstelle1}"></f:selectItems>
</h:selectOneMenu></td>
</ui:fragment>
<ui:fragment rendered="#{!empty datevController.kostenstelle2}">
<td><h:selectOneMenu style="width:100%;"
value="#{bookingItem.item['datev.kostenstelle2']}">
<f:selectItem itemLabel="" itemValue="" />
<f:selectItems value="#{datevController.kostenstelle2}"></f:selectItems>
</h:selectOneMenu></td>
</ui:fragment>


<td><h:selectOneMenu style="width:100%;"
Expand Down Expand Up @@ -84,6 +94,12 @@
<!-- summary -->
<tr>
<td />
<ui:fragment rendered="#{hasKostenstelle1}">
<td />
</ui:fragment>
<ui:fragment rendered="#{hasKostenstelle2}">
<td />
</ui:fragment>

<td class="bookinglist-sum"
style="text-align: right; font-weight: bold;">Summe:</td>
Expand Down
6 changes: 3 additions & 3 deletions imixs-adapters-datev/src/reports/datev_csv_invoices.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<xsl:value-of
select="item[@name='datev.client.id']/value" /><xsl:text>;</xsl:text>
<xsl:value-of
select="format-dateTime($fiscalstart, '[Y0001][M01][D01]')"></xsl:value-of><xsl:text>;</xsl:text>
select="$fiscalstart"></xsl:value-of><xsl:text>;</xsl:text>
<!-- Sachkontennumernlaenge mandantenabhaengig - defautl = 6 -->
<xsl:choose>
<xsl:when test="string-length(./item[@name='datev.sachkontennummernlaenge']/value) > 0">
Expand Down Expand Up @@ -120,15 +120,15 @@
</xsl:variable>

<xsl:variable
name="gegenkonto" select="item[@name='cdtr.number']/value" />
name="gegenkonto" select="item[@name='datev.gegenkonto']/value" />
<xsl:variable
name="subject" select="substring(item[@name='$workflowsummary']/value,1,59)" />
<xsl:variable
name="invoicenumber" select="item[@name='invoice.number']/value" />
<xsl:variable
name="uniqueid" select="item[@name='$uniqueid']/value" />
<xsl:for-each
select="item[@name='_childitems']/value">
select="item[@name='datev.booking.list']/value">
<xsl:variable name="betrag"
select="replace(./item[@name='datev.betrag']/value, '\.', ',')" />
<xsl:variable
Expand Down

0 comments on commit 711729e

Please sign in to comment.