This commit is contained in:
Ralph Soika 2024-07-11 14:45:41 +02:00
parent 995c9311aa
commit 51da411232
3 changed files with 93 additions and 73 deletions

1
.gitignore vendored
View file

@ -21,3 +21,4 @@ docker/deployments/
reports/sepa/result_sepa* reports/sepa/result_sepa*
reports/sepa/result_sepa02.xml reports/sepa/result_sepa02.xml
reports/sepa/result_sepa01.xml reports/sepa/result_sepa01.xml
reports/sepa/result_sepa01.xml

View file

@ -36,6 +36,7 @@ import org.imixs.workflow.engine.WorkflowService;
import org.imixs.workflow.exceptions.AdapterException; import org.imixs.workflow.exceptions.AdapterException;
import org.imixs.workflow.exceptions.PluginException; import org.imixs.workflow.exceptions.PluginException;
import org.imixs.workflow.exceptions.QueryException; import org.imixs.workflow.exceptions.QueryException;
import org.imixs.workflow.office.config.ConfigService;
import org.imixs.workflow.poi.POIFindReplaceAdapter; import org.imixs.workflow.poi.POIFindReplaceAdapter;
/** /**
@ -88,6 +89,9 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
@Inject @Inject
TeamService teamService; TeamService teamService;
@Inject
ConfigService configService;
// cache for all invoices grouped by week // cache for all invoices grouped by week
Map<String, List<ItemCollection>> invoiceMap = null; Map<String, List<ItemCollection>> invoiceMap = null;
@ -108,6 +112,17 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
throw new PluginException(OPListExportAdapterByWeek.class.getSimpleName(), ERROR_CONFIG, throw new PluginException(OPListExportAdapterByWeek.class.getSimpleName(), ERROR_CONFIG,
"missing op-list configuration in model event - please check model configuration"); "missing op-list configuration in model event - please check model configuration");
} }
// ermittle die Hauptwährungen
ItemCollection configItemCollection = configService.loadConfiguration("AGL_CONFIGURATION");
List<String> currencyList = configItemCollection.getItemValue("currency.out");
if (currencyList == null || currencyList.size() < 2) {
throw new PluginException(OPListExportAdapter.class.getSimpleName(), ERROR_CONFIG,
"missing Currency configuration - please check parameters");
}
String currency1 = currencyList.get(0);
String currency2 = currencyList.get(1);
String textblock = evalItemCollection.getItemValueString("textblock"); String textblock = evalItemCollection.getItemValueString("textblock");
String template = evalItemCollection.getItemValueString("template"); String template = evalItemCollection.getItemValueString("template");
String targetName = evalItemCollection.getItemValueString("target-name"); String targetName = evalItemCollection.getItemValueString("target-name");
@ -129,7 +144,7 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
logger.info("... update template with normal poi information.."); logger.info("... update template with normal poi information..");
this.updateFileData(document.getFileData(targetName), document, replaceDevList, eval); this.updateFileData(document.getFileData(targetName), document, replaceDevList, eval);
insertInvoiceRows(document, targetName); insertInvoiceRows(document, targetName, currency1, currency2);
} catch (PluginException | IOException | QueryException e) { } catch (PluginException | IOException | QueryException e) {
throw new PluginException(OPListExportAdapterByWeek.class.getSimpleName(), ERROR_CONFIG, throw new PluginException(OPListExportAdapterByWeek.class.getSimpleName(), ERROR_CONFIG,
"failed to update op-liste: " + e.getMessage()); "failed to update op-liste: " + e.getMessage());
@ -152,21 +167,14 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
* @throws PluginException * @throws PluginException
* @throws QueryException * @throws QueryException
*/ */
private void insertInvoiceRows(ItemCollection document, String fileName) private void insertInvoiceRows(ItemCollection document, String fileName, String currency1,
String currency2)
throws PluginException, QueryException { throws PluginException, QueryException {
// double saldoUSD1 = 0; Map<String, Double> totalsUeberfaelligCurrency1 = new HashMap<String, Double>();
// double saldoEUR1 = 0; Map<String, Double> totalsFaelligCurrency1 = new HashMap<String, Double>();
// double saldoUSD2 = 0; Map<String, Double> totalsUeberfaelligCurrency2 = new HashMap<String, Double>();
// double saldoEUR2 = 0; Map<String, Double> totalsFaelligCurrency2 = new HashMap<String, Double>();
Map<String, Double> totalsUeberfaelligEUR = new HashMap<String, Double>();
Map<String, Double> totalsFaelligEUR = new HashMap<String, Double>();
Map<String, Double> totalsUeberfaelligUSD = new HashMap<String, Double>();
Map<String, Double> totalsFaelligUSD = new HashMap<String, Double>();
// double saldoUSD3 = 0;
// double saldoEUR3 = 0;
List<String> spaceNames = new ArrayList<String>(); List<String> spaceNames = new ArrayList<String>();
// compute all departments // compute all departments
@ -241,13 +249,13 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
// Space currency EUR // Space currency EUR
cell = referenceRowSpacesCurrencies.getCell(column); cell = referenceRowSpacesCurrencies.getCell(column);
cell.copyCellFrom(cellSpaceCurrencyReference, new CellCopyPolicy()); cell.copyCellFrom(cellSpaceCurrencyReference, new CellCopyPolicy());
cell.setCellValue("EUR"); cell.setCellValue(currency1);
// Space currency USD // Space currency USD
column++; column++;
cell = referenceRowSpacesCurrencies.getCell(column); cell = referenceRowSpacesCurrencies.getCell(column);
cell.copyCellFrom(cellSpaceCurrencyReference, new CellCopyPolicy()); cell.copyCellFrom(cellSpaceCurrencyReference, new CellCopyPolicy());
cell.setCellValue("USD"); cell.setCellValue(currency2);
// Space Label // Space Label
cell = rowSpacesLabels.getCell(column); cell = rowSpacesLabels.getCell(column);
@ -265,20 +273,20 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
logger.info("...grouping invoices by week..."); logger.info("...grouping invoices by week...");
// collect all invoices for this space grouped by week.... // collect all invoices for this space grouped by week....
groupInvoicesByWeek(spaceID, spaceName, weekDataMap); groupInvoicesByWeek(spaceID, spaceName, weekDataMap, currency1);
// init totals // init totals
for (String name : spaceNames) { for (String name : spaceNames) {
totalsUeberfaelligEUR.put(name, 0.0); totalsUeberfaelligCurrency1.put(name, 0.0);
totalsFaelligEUR.put(name, 0.0); totalsFaelligCurrency1.put(name, 0.0);
totalsUeberfaelligUSD.put(name, 0.0); totalsUeberfaelligCurrency2.put(name, 0.0);
totalsFaelligUSD.put(name, 0.0); totalsFaelligCurrency2.put(name, 0.0);
} }
} }
totalsUeberfaelligEUR.put("TOTAL", 0.0); totalsUeberfaelligCurrency1.put("TOTAL", 0.0);
totalsFaelligEUR.put("TOTAL", 0.0); totalsFaelligCurrency1.put("TOTAL", 0.0);
totalsUeberfaelligUSD.put("TOTAL", 0.0); totalsUeberfaelligCurrency2.put("TOTAL", 0.0);
totalsFaelligUSD.put("TOTAL", 0.0); totalsFaelligCurrency2.put("TOTAL", 0.0);
/* /*
* --- Phase 2 ------------------------------------------------------- * --- Phase 2 -------------------------------------------------------
* Nun bilden wir nochmal 2 weitere Spalten am Ende um eine Summenbildung in * Nun bilden wir nochmal 2 weitere Spalten am Ende um eine Summenbildung in
@ -289,7 +297,7 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
// Space currency EUR // Space currency EUR
cell = referenceRowSpacesCurrencies.getCell(column); cell = referenceRowSpacesCurrencies.getCell(column);
cell.copyCellFrom(cellKWTotalReference, new CellCopyPolicy()); cell.copyCellFrom(cellKWTotalReference, new CellCopyPolicy());
cell.setCellValue("EUR"); cell.setCellValue(currency1);
cell = rowSpacesLabels.getCell(column); cell = rowSpacesLabels.getCell(column);
cell.copyCellFrom(cellKWTotalReference, new CellCopyPolicy()); cell.copyCellFrom(cellKWTotalReference, new CellCopyPolicy());
cell.setCellValue(""); cell.setCellValue("");
@ -298,12 +306,12 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
column++; column++;
cell = referenceRowSpacesCurrencies.getCell(column); cell = referenceRowSpacesCurrencies.getCell(column);
cell.copyCellFrom(cellKWTotalReference, new CellCopyPolicy()); cell.copyCellFrom(cellKWTotalReference, new CellCopyPolicy());
cell.setCellValue("USD"); cell.setCellValue(currency2);
// Space Label // Space Label
cell = rowSpacesLabels.getCell(column); cell = rowSpacesLabels.getCell(column);
cell.copyCellFrom(cellKWTotalReference, new CellCopyPolicy()); cell.copyCellFrom(cellKWTotalReference, new CellCopyPolicy());
cell.setCellValue("Gesamt"); cell.setCellValue("Total");
/* /*
* --- Phase 3 ------------------------------------------------------- * --- Phase 3 -------------------------------------------------------
@ -365,31 +373,32 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
// list of invoices // list of invoices
WeekInvoiceData weekData = weekDataMap.get(key); WeekInvoiceData weekData = weekDataMap.get(key);
if (weekData != null) { if (weekData != null) {
logger.fine(" EUR=" + weekData.totalEUR + " USD=" + weekData.totalUSD); logger.fine(" " + currency1 + "=" + weekData.totalCurrency1 + " " + currency2 + "="
row.getCell(column).setCellValue(weekData.totalEUR); + weekData.totalCurrency2);
row.getCell(column).setCellValue(weekData.totalCurrency1);
column++; column++;
row.getCell(column).setCellValue(weekData.totalUSD); row.getCell(column).setCellValue(weekData.totalCurrency2);
if (ueberFaellig) { if (ueberFaellig) {
double eur = totalsUeberfaelligEUR.get(name); double eur = totalsUeberfaelligCurrency1.get(name);
eur = InvoiceUtil.round(eur + weekData.totalEUR); eur = InvoiceUtil.round(eur + weekData.totalCurrency1);
totalsUeberfaelligEUR.put(name, eur); totalsUeberfaelligCurrency1.put(name, eur);
double usd = totalsUeberfaelligUSD.get(name); double usd = totalsUeberfaelligCurrency2.get(name);
usd = InvoiceUtil.round(usd + weekData.totalUSD); usd = InvoiceUtil.round(usd + weekData.totalCurrency2);
totalsUeberfaelligUSD.put(name, usd); totalsUeberfaelligCurrency2.put(name, usd);
// saldoEUR1 = InvoiceUtil.round(saldoEUR1 + weekData.totalEUR); // saldoEUR1 = InvoiceUtil.round(saldoEUR1 + weekData.totalEUR);
// saldoUSD1 = InvoiceUtil.round(saldoUSD1 + weekData.totalUSD); // saldoUSD1 = InvoiceUtil.round(saldoUSD1 + weekData.totalUSD);
} else { } else {
double eur = totalsFaelligEUR.get(name); double eur = totalsFaelligCurrency1.get(name);
eur = InvoiceUtil.round(eur + weekData.totalEUR); eur = InvoiceUtil.round(eur + weekData.totalCurrency1);
totalsFaelligEUR.put(name, eur); totalsFaelligCurrency1.put(name, eur);
double usd = totalsFaelligUSD.get(name); double usd = totalsFaelligCurrency2.get(name);
usd = InvoiceUtil.round(usd + weekData.totalUSD); usd = InvoiceUtil.round(usd + weekData.totalCurrency2);
totalsFaelligUSD.put(name, usd); totalsFaelligCurrency2.put(name, usd);
// saldoEUR2 = InvoiceUtil.round(saldoEUR2 + weekData.totalEUR); // saldoEUR2 = InvoiceUtil.round(saldoEUR2 + weekData.totalEUR);
// saldoUSD2 = InvoiceUtil.round(saldoUSD2 + weekData.totalUSD); // saldoUSD2 = InvoiceUtil.round(saldoUSD2 + weekData.totalUSD);
} }
kwTotalEUR = kwTotalEUR + weekData.totalEUR; kwTotalEUR = kwTotalEUR + weekData.totalCurrency1;
kwTotalUSD = kwTotalUSD + weekData.totalUSD; kwTotalUSD = kwTotalUSD + weekData.totalCurrency2;
column++; column++;
} else { } else {
logger.fine("...... NOT FOUND"); logger.fine("...... NOT FOUND");
@ -424,19 +433,19 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
// store totals // store totals
if (ueberFaellig) { if (ueberFaellig) {
double eur = totalsUeberfaelligEUR.get("TOTAL"); double eur = totalsUeberfaelligCurrency1.get("TOTAL");
eur = InvoiceUtil.round(eur + kwTotalEUR); eur = InvoiceUtil.round(eur + kwTotalEUR);
totalsUeberfaelligEUR.put("TOTAL", eur); totalsUeberfaelligCurrency1.put("TOTAL", eur);
double usd = totalsUeberfaelligUSD.get("TOTAL"); double usd = totalsUeberfaelligCurrency2.get("TOTAL");
usd = InvoiceUtil.round(usd + kwTotalUSD); usd = InvoiceUtil.round(usd + kwTotalUSD);
totalsUeberfaelligUSD.put("TOTAL", usd); totalsUeberfaelligCurrency2.put("TOTAL", usd);
} else { } else {
double eur = totalsFaelligEUR.get("TOTAL"); double eur = totalsFaelligCurrency1.get("TOTAL");
eur = InvoiceUtil.round(eur + kwTotalEUR); eur = InvoiceUtil.round(eur + kwTotalEUR);
totalsFaelligEUR.put("TOTAL", eur); totalsFaelligCurrency1.put("TOTAL", eur);
double usd = totalsFaelligUSD.get("TOTAL"); double usd = totalsFaelligCurrency2.get("TOTAL");
usd = InvoiceUtil.round(usd + kwTotalUSD); usd = InvoiceUtil.round(usd + kwTotalUSD);
totalsFaelligUSD.put("TOTAL", usd); totalsFaelligCurrency2.put("TOTAL", usd);
} }
} }
@ -458,34 +467,34 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
XSSFCell totalCell = null; XSSFCell totalCell = null;
for (String name : spaceNames) { for (String name : spaceNames) {
totalCell = rowUeberFaellig.getCell(column); totalCell = rowUeberFaellig.getCell(column);
totalCell.setCellValue(totalsUeberfaelligEUR.get(name)); totalCell.setCellValue(totalsUeberfaelligCurrency1.get(name));
totalCell = rowFaellig.getCell(column); totalCell = rowFaellig.getCell(column);
totalCell.setCellValue(totalsFaelligEUR.get(name)); totalCell.setCellValue(totalsFaelligCurrency1.get(name));
totalCell = rowTotal.getCell(column); totalCell = rowTotal.getCell(column);
totalCell.setCellValue(totalsUeberfaelligEUR.get(name) + totalsFaelligEUR.get(name)); totalCell.setCellValue(totalsUeberfaelligCurrency1.get(name) + totalsFaelligCurrency1.get(name));
column++; column++;
totalCell = rowUeberFaellig.getCell(column); totalCell = rowUeberFaellig.getCell(column);
totalCell.setCellValue(totalsUeberfaelligUSD.get(name)); totalCell.setCellValue(totalsUeberfaelligCurrency2.get(name));
totalCell = rowFaellig.getCell(column); totalCell = rowFaellig.getCell(column);
totalCell.setCellValue(totalsFaelligUSD.get(name)); totalCell.setCellValue(totalsFaelligCurrency2.get(name));
totalCell = rowTotal.getCell(column); totalCell = rowTotal.getCell(column);
totalCell.setCellValue(totalsUeberfaelligUSD.get(name) + totalsFaelligUSD.get(name)); totalCell.setCellValue(totalsUeberfaelligCurrency2.get(name) + totalsFaelligCurrency2.get(name));
column++; column++;
} }
// totals // totals
totalCell = rowUeberFaellig.getCell(column); totalCell = rowUeberFaellig.getCell(column);
totalCell.setCellValue(totalsUeberfaelligEUR.get("TOTAL")); totalCell.setCellValue(totalsUeberfaelligCurrency1.get("TOTAL"));
totalCell = rowFaellig.getCell(column); totalCell = rowFaellig.getCell(column);
totalCell.setCellValue(totalsFaelligEUR.get("TOTAL")); totalCell.setCellValue(totalsFaelligCurrency1.get("TOTAL"));
totalCell = rowTotal.getCell(column); totalCell = rowTotal.getCell(column);
totalCell.setCellValue(totalsUeberfaelligEUR.get("TOTAL") + totalsFaelligEUR.get("TOTAL")); totalCell.setCellValue(totalsUeberfaelligCurrency1.get("TOTAL") + totalsFaelligCurrency1.get("TOTAL"));
column++; column++;
totalCell = rowUeberFaellig.getCell(column); totalCell = rowUeberFaellig.getCell(column);
totalCell.setCellValue(totalsUeberfaelligUSD.get("TOTAL")); totalCell.setCellValue(totalsUeberfaelligCurrency2.get("TOTAL"));
totalCell = rowFaellig.getCell(column); totalCell = rowFaellig.getCell(column);
totalCell.setCellValue(totalsFaelligUSD.get("TOTAL")); totalCell.setCellValue(totalsFaelligCurrency2.get("TOTAL"));
totalCell = rowTotal.getCell(column); totalCell = rowTotal.getCell(column);
totalCell.setCellValue(totalsUeberfaelligUSD.get("TOTAL") + totalsFaelligUSD.get("TOTAL")); totalCell.setCellValue(totalsUeberfaelligCurrency2.get("TOTAL") + totalsFaelligCurrency2.get("TOTAL"));
// delete placeholder row // delete placeholder row
sheet.shiftRows(_rowNo, _rowNo + 3, -1); sheet.shiftRows(_rowNo, _rowNo + 3, -1);
@ -587,7 +596,7 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
* *
*/ */
private void groupInvoicesByWeek(String spaceID, String spaceName, private void groupInvoicesByWeek(String spaceID, String spaceName,
Map<String, WeekInvoiceData> cache) { Map<String, WeekInvoiceData> cache, String currency1) {
logger.info("...group invoices for " + spaceName + "/" + spaceID); logger.info("...group invoices for " + spaceName + "/" + spaceID);
try { try {
@ -619,7 +628,7 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
weekData = new WeekInvoiceData(spaceName, weekCategory); weekData = new WeekInvoiceData(spaceName, weekCategory);
} }
// Jetzt Rechnung addieren // Jetzt Rechnung addieren
weekData.add(invoice); weekData.add(invoice, currency1);
cache.put(key, weekData); cache.put(key, weekData);
} }
@ -639,23 +648,23 @@ class WeekInvoiceData {
String week; String week;
String spaceName; String spaceName;
double totalEUR; double totalCurrency1;
double totalUSD; double totalCurrency2;
public WeekInvoiceData(String spaceName, String week) { public WeekInvoiceData(String spaceName, String week) {
this.spaceName = spaceName; this.spaceName = spaceName;
this.week = week; this.week = week;
} }
public void add(ItemCollection invoice) { public void add(ItemCollection invoice, String currency1) {
String spaceName = invoice.getItemValueString("space.name"); String spaceName = invoice.getItemValueString("space.name");
String currency = invoice.getItemValueString("invoice.currency"); String currency = invoice.getItemValueString("invoice.currency");
// Double total = invoice.getItemValueDouble("invoice.total"); // Double total = invoice.getItemValueDouble("invoice.total");
Double total = invoice.getItemValueDouble("invoice.saldo"); Double total = invoice.getItemValueDouble("invoice.saldo");
if ("EUR".equals(currency)) { if (currency1.equals(currency)) {
totalEUR = totalEUR + total; totalCurrency1 = totalCurrency1 + total;
} else { } else {
totalUSD = totalUSD + total; totalCurrency2 = totalCurrency2 + total;
} }

View file

@ -463,6 +463,16 @@ Nach Prüfung schließen Sie bitte den Vorgang über die Schaltfläche "Erledigt
<imixs:item name="keypublicresult" type="xs:string"> <imixs:item name="keypublicresult" type="xs:string">
<imixs:value><![CDATA[1]]></imixs:value> <imixs:value><![CDATA[1]]></imixs:value>
</imixs:item> </imixs:item>
<imixs:item name="txtbusinessrule" type="xs:string">
<imixs:value><![CDATA[var result={};
result.isValid=true;
var refField='space.ref';
if (( workitem.get(refField) == null || ''==workitem.get(refField)[0])) {
result.isValid=false;
result.errorMessage='Please choose a Department.';
}
]]></imixs:value>
</imixs:item>
</bpmn2:extensionElements> </bpmn2:extensionElements>
<bpmn2:incoming>SequenceFlow_2</bpmn2:incoming> <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_6</bpmn2:outgoing> <bpmn2:outgoing>SequenceFlow_6</bpmn2:outgoing>