udpate
This commit is contained in:
parent
995c9311aa
commit
51da411232
3 changed files with 93 additions and 73 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -21,3 +21,4 @@ docker/deployments/
|
|||
reports/sepa/result_sepa*
|
||||
reports/sepa/result_sepa02.xml
|
||||
reports/sepa/result_sepa01.xml
|
||||
reports/sepa/result_sepa01.xml
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import org.imixs.workflow.engine.WorkflowService;
|
|||
import org.imixs.workflow.exceptions.AdapterException;
|
||||
import org.imixs.workflow.exceptions.PluginException;
|
||||
import org.imixs.workflow.exceptions.QueryException;
|
||||
import org.imixs.workflow.office.config.ConfigService;
|
||||
import org.imixs.workflow.poi.POIFindReplaceAdapter;
|
||||
|
||||
/**
|
||||
|
|
@ -88,6 +89,9 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
|
|||
@Inject
|
||||
TeamService teamService;
|
||||
|
||||
@Inject
|
||||
ConfigService configService;
|
||||
|
||||
// cache for all invoices grouped by week
|
||||
Map<String, List<ItemCollection>> invoiceMap = null;
|
||||
|
||||
|
|
@ -108,6 +112,17 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
|
|||
throw new PluginException(OPListExportAdapterByWeek.class.getSimpleName(), ERROR_CONFIG,
|
||||
"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 template = evalItemCollection.getItemValueString("template");
|
||||
String targetName = evalItemCollection.getItemValueString("target-name");
|
||||
|
|
@ -129,7 +144,7 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
|
|||
logger.info("... update template with normal poi information..");
|
||||
this.updateFileData(document.getFileData(targetName), document, replaceDevList, eval);
|
||||
|
||||
insertInvoiceRows(document, targetName);
|
||||
insertInvoiceRows(document, targetName, currency1, currency2);
|
||||
} catch (PluginException | IOException | QueryException e) {
|
||||
throw new PluginException(OPListExportAdapterByWeek.class.getSimpleName(), ERROR_CONFIG,
|
||||
"failed to update op-liste: " + e.getMessage());
|
||||
|
|
@ -152,21 +167,14 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
|
|||
* @throws PluginException
|
||||
* @throws QueryException
|
||||
*/
|
||||
private void insertInvoiceRows(ItemCollection document, String fileName)
|
||||
private void insertInvoiceRows(ItemCollection document, String fileName, String currency1,
|
||||
String currency2)
|
||||
throws PluginException, QueryException {
|
||||
|
||||
// double saldoUSD1 = 0;
|
||||
// double saldoEUR1 = 0;
|
||||
// double saldoUSD2 = 0;
|
||||
// double saldoEUR2 = 0;
|
||||
|
||||
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;
|
||||
Map<String, Double> totalsUeberfaelligCurrency1 = new HashMap<String, Double>();
|
||||
Map<String, Double> totalsFaelligCurrency1 = new HashMap<String, Double>();
|
||||
Map<String, Double> totalsUeberfaelligCurrency2 = new HashMap<String, Double>();
|
||||
Map<String, Double> totalsFaelligCurrency2 = new HashMap<String, Double>();
|
||||
List<String> spaceNames = new ArrayList<String>();
|
||||
|
||||
// compute all departments
|
||||
|
|
@ -241,13 +249,13 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
|
|||
// Space currency EUR
|
||||
cell = referenceRowSpacesCurrencies.getCell(column);
|
||||
cell.copyCellFrom(cellSpaceCurrencyReference, new CellCopyPolicy());
|
||||
cell.setCellValue("EUR");
|
||||
cell.setCellValue(currency1);
|
||||
|
||||
// Space currency USD
|
||||
column++;
|
||||
cell = referenceRowSpacesCurrencies.getCell(column);
|
||||
cell.copyCellFrom(cellSpaceCurrencyReference, new CellCopyPolicy());
|
||||
cell.setCellValue("USD");
|
||||
cell.setCellValue(currency2);
|
||||
|
||||
// Space Label
|
||||
cell = rowSpacesLabels.getCell(column);
|
||||
|
|
@ -265,20 +273,20 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
|
|||
|
||||
logger.info("...grouping invoices by week...");
|
||||
// collect all invoices for this space grouped by week....
|
||||
groupInvoicesByWeek(spaceID, spaceName, weekDataMap);
|
||||
groupInvoicesByWeek(spaceID, spaceName, weekDataMap, currency1);
|
||||
|
||||
// init totals
|
||||
for (String name : spaceNames) {
|
||||
totalsUeberfaelligEUR.put(name, 0.0);
|
||||
totalsFaelligEUR.put(name, 0.0);
|
||||
totalsUeberfaelligUSD.put(name, 0.0);
|
||||
totalsFaelligUSD.put(name, 0.0);
|
||||
totalsUeberfaelligCurrency1.put(name, 0.0);
|
||||
totalsFaelligCurrency1.put(name, 0.0);
|
||||
totalsUeberfaelligCurrency2.put(name, 0.0);
|
||||
totalsFaelligCurrency2.put(name, 0.0);
|
||||
}
|
||||
}
|
||||
totalsUeberfaelligEUR.put("TOTAL", 0.0);
|
||||
totalsFaelligEUR.put("TOTAL", 0.0);
|
||||
totalsUeberfaelligUSD.put("TOTAL", 0.0);
|
||||
totalsFaelligUSD.put("TOTAL", 0.0);
|
||||
totalsUeberfaelligCurrency1.put("TOTAL", 0.0);
|
||||
totalsFaelligCurrency1.put("TOTAL", 0.0);
|
||||
totalsUeberfaelligCurrency2.put("TOTAL", 0.0);
|
||||
totalsFaelligCurrency2.put("TOTAL", 0.0);
|
||||
/*
|
||||
* --- Phase 2 -------------------------------------------------------
|
||||
* 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
|
||||
cell = referenceRowSpacesCurrencies.getCell(column);
|
||||
cell.copyCellFrom(cellKWTotalReference, new CellCopyPolicy());
|
||||
cell.setCellValue("EUR");
|
||||
cell.setCellValue(currency1);
|
||||
cell = rowSpacesLabels.getCell(column);
|
||||
cell.copyCellFrom(cellKWTotalReference, new CellCopyPolicy());
|
||||
cell.setCellValue("");
|
||||
|
|
@ -298,12 +306,12 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
|
|||
column++;
|
||||
cell = referenceRowSpacesCurrencies.getCell(column);
|
||||
cell.copyCellFrom(cellKWTotalReference, new CellCopyPolicy());
|
||||
cell.setCellValue("USD");
|
||||
cell.setCellValue(currency2);
|
||||
|
||||
// Space Label
|
||||
cell = rowSpacesLabels.getCell(column);
|
||||
cell.copyCellFrom(cellKWTotalReference, new CellCopyPolicy());
|
||||
cell.setCellValue("Gesamt");
|
||||
cell.setCellValue("Total");
|
||||
|
||||
/*
|
||||
* --- Phase 3 -------------------------------------------------------
|
||||
|
|
@ -365,31 +373,32 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
|
|||
// list of invoices
|
||||
WeekInvoiceData weekData = weekDataMap.get(key);
|
||||
if (weekData != null) {
|
||||
logger.fine(" EUR=" + weekData.totalEUR + " USD=" + weekData.totalUSD);
|
||||
row.getCell(column).setCellValue(weekData.totalEUR);
|
||||
logger.fine(" " + currency1 + "=" + weekData.totalCurrency1 + " " + currency2 + "="
|
||||
+ weekData.totalCurrency2);
|
||||
row.getCell(column).setCellValue(weekData.totalCurrency1);
|
||||
column++;
|
||||
row.getCell(column).setCellValue(weekData.totalUSD);
|
||||
row.getCell(column).setCellValue(weekData.totalCurrency2);
|
||||
if (ueberFaellig) {
|
||||
double eur = totalsUeberfaelligEUR.get(name);
|
||||
eur = InvoiceUtil.round(eur + weekData.totalEUR);
|
||||
totalsUeberfaelligEUR.put(name, eur);
|
||||
double usd = totalsUeberfaelligUSD.get(name);
|
||||
usd = InvoiceUtil.round(usd + weekData.totalUSD);
|
||||
totalsUeberfaelligUSD.put(name, usd);
|
||||
double eur = totalsUeberfaelligCurrency1.get(name);
|
||||
eur = InvoiceUtil.round(eur + weekData.totalCurrency1);
|
||||
totalsUeberfaelligCurrency1.put(name, eur);
|
||||
double usd = totalsUeberfaelligCurrency2.get(name);
|
||||
usd = InvoiceUtil.round(usd + weekData.totalCurrency2);
|
||||
totalsUeberfaelligCurrency2.put(name, usd);
|
||||
// saldoEUR1 = InvoiceUtil.round(saldoEUR1 + weekData.totalEUR);
|
||||
// saldoUSD1 = InvoiceUtil.round(saldoUSD1 + weekData.totalUSD);
|
||||
} else {
|
||||
double eur = totalsFaelligEUR.get(name);
|
||||
eur = InvoiceUtil.round(eur + weekData.totalEUR);
|
||||
totalsFaelligEUR.put(name, eur);
|
||||
double usd = totalsFaelligUSD.get(name);
|
||||
usd = InvoiceUtil.round(usd + weekData.totalUSD);
|
||||
totalsFaelligUSD.put(name, usd);
|
||||
double eur = totalsFaelligCurrency1.get(name);
|
||||
eur = InvoiceUtil.round(eur + weekData.totalCurrency1);
|
||||
totalsFaelligCurrency1.put(name, eur);
|
||||
double usd = totalsFaelligCurrency2.get(name);
|
||||
usd = InvoiceUtil.round(usd + weekData.totalCurrency2);
|
||||
totalsFaelligCurrency2.put(name, usd);
|
||||
// saldoEUR2 = InvoiceUtil.round(saldoEUR2 + weekData.totalEUR);
|
||||
// saldoUSD2 = InvoiceUtil.round(saldoUSD2 + weekData.totalUSD);
|
||||
}
|
||||
kwTotalEUR = kwTotalEUR + weekData.totalEUR;
|
||||
kwTotalUSD = kwTotalUSD + weekData.totalUSD;
|
||||
kwTotalEUR = kwTotalEUR + weekData.totalCurrency1;
|
||||
kwTotalUSD = kwTotalUSD + weekData.totalCurrency2;
|
||||
column++;
|
||||
} else {
|
||||
logger.fine("...... NOT FOUND");
|
||||
|
|
@ -424,19 +433,19 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
|
|||
|
||||
// store totals
|
||||
if (ueberFaellig) {
|
||||
double eur = totalsUeberfaelligEUR.get("TOTAL");
|
||||
double eur = totalsUeberfaelligCurrency1.get("TOTAL");
|
||||
eur = InvoiceUtil.round(eur + kwTotalEUR);
|
||||
totalsUeberfaelligEUR.put("TOTAL", eur);
|
||||
double usd = totalsUeberfaelligUSD.get("TOTAL");
|
||||
totalsUeberfaelligCurrency1.put("TOTAL", eur);
|
||||
double usd = totalsUeberfaelligCurrency2.get("TOTAL");
|
||||
usd = InvoiceUtil.round(usd + kwTotalUSD);
|
||||
totalsUeberfaelligUSD.put("TOTAL", usd);
|
||||
totalsUeberfaelligCurrency2.put("TOTAL", usd);
|
||||
} else {
|
||||
double eur = totalsFaelligEUR.get("TOTAL");
|
||||
double eur = totalsFaelligCurrency1.get("TOTAL");
|
||||
eur = InvoiceUtil.round(eur + kwTotalEUR);
|
||||
totalsFaelligEUR.put("TOTAL", eur);
|
||||
double usd = totalsFaelligUSD.get("TOTAL");
|
||||
totalsFaelligCurrency1.put("TOTAL", eur);
|
||||
double usd = totalsFaelligCurrency2.get("TOTAL");
|
||||
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;
|
||||
for (String name : spaceNames) {
|
||||
totalCell = rowUeberFaellig.getCell(column);
|
||||
totalCell.setCellValue(totalsUeberfaelligEUR.get(name));
|
||||
totalCell.setCellValue(totalsUeberfaelligCurrency1.get(name));
|
||||
totalCell = rowFaellig.getCell(column);
|
||||
totalCell.setCellValue(totalsFaelligEUR.get(name));
|
||||
totalCell.setCellValue(totalsFaelligCurrency1.get(name));
|
||||
totalCell = rowTotal.getCell(column);
|
||||
totalCell.setCellValue(totalsUeberfaelligEUR.get(name) + totalsFaelligEUR.get(name));
|
||||
totalCell.setCellValue(totalsUeberfaelligCurrency1.get(name) + totalsFaelligCurrency1.get(name));
|
||||
column++;
|
||||
totalCell = rowUeberFaellig.getCell(column);
|
||||
totalCell.setCellValue(totalsUeberfaelligUSD.get(name));
|
||||
totalCell.setCellValue(totalsUeberfaelligCurrency2.get(name));
|
||||
totalCell = rowFaellig.getCell(column);
|
||||
totalCell.setCellValue(totalsFaelligUSD.get(name));
|
||||
totalCell.setCellValue(totalsFaelligCurrency2.get(name));
|
||||
totalCell = rowTotal.getCell(column);
|
||||
totalCell.setCellValue(totalsUeberfaelligUSD.get(name) + totalsFaelligUSD.get(name));
|
||||
totalCell.setCellValue(totalsUeberfaelligCurrency2.get(name) + totalsFaelligCurrency2.get(name));
|
||||
column++;
|
||||
}
|
||||
// totals
|
||||
totalCell = rowUeberFaellig.getCell(column);
|
||||
totalCell.setCellValue(totalsUeberfaelligEUR.get("TOTAL"));
|
||||
totalCell.setCellValue(totalsUeberfaelligCurrency1.get("TOTAL"));
|
||||
totalCell = rowFaellig.getCell(column);
|
||||
totalCell.setCellValue(totalsFaelligEUR.get("TOTAL"));
|
||||
totalCell.setCellValue(totalsFaelligCurrency1.get("TOTAL"));
|
||||
totalCell = rowTotal.getCell(column);
|
||||
totalCell.setCellValue(totalsUeberfaelligEUR.get("TOTAL") + totalsFaelligEUR.get("TOTAL"));
|
||||
totalCell.setCellValue(totalsUeberfaelligCurrency1.get("TOTAL") + totalsFaelligCurrency1.get("TOTAL"));
|
||||
column++;
|
||||
totalCell = rowUeberFaellig.getCell(column);
|
||||
totalCell.setCellValue(totalsUeberfaelligUSD.get("TOTAL"));
|
||||
totalCell.setCellValue(totalsUeberfaelligCurrency2.get("TOTAL"));
|
||||
totalCell = rowFaellig.getCell(column);
|
||||
totalCell.setCellValue(totalsFaelligUSD.get("TOTAL"));
|
||||
totalCell.setCellValue(totalsFaelligCurrency2.get("TOTAL"));
|
||||
totalCell = rowTotal.getCell(column);
|
||||
totalCell.setCellValue(totalsUeberfaelligUSD.get("TOTAL") + totalsFaelligUSD.get("TOTAL"));
|
||||
totalCell.setCellValue(totalsUeberfaelligCurrency2.get("TOTAL") + totalsFaelligCurrency2.get("TOTAL"));
|
||||
|
||||
// delete placeholder row
|
||||
sheet.shiftRows(_rowNo, _rowNo + 3, -1);
|
||||
|
|
@ -587,7 +596,7 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
|
|||
*
|
||||
*/
|
||||
private void groupInvoicesByWeek(String spaceID, String spaceName,
|
||||
Map<String, WeekInvoiceData> cache) {
|
||||
Map<String, WeekInvoiceData> cache, String currency1) {
|
||||
|
||||
logger.info("...group invoices for " + spaceName + "/" + spaceID);
|
||||
try {
|
||||
|
|
@ -619,7 +628,7 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
|
|||
weekData = new WeekInvoiceData(spaceName, weekCategory);
|
||||
}
|
||||
// Jetzt Rechnung addieren
|
||||
weekData.add(invoice);
|
||||
weekData.add(invoice, currency1);
|
||||
cache.put(key, weekData);
|
||||
}
|
||||
|
||||
|
|
@ -639,23 +648,23 @@ class WeekInvoiceData {
|
|||
|
||||
String week;
|
||||
String spaceName;
|
||||
double totalEUR;
|
||||
double totalUSD;
|
||||
double totalCurrency1;
|
||||
double totalCurrency2;
|
||||
|
||||
public WeekInvoiceData(String spaceName, String week) {
|
||||
this.spaceName = spaceName;
|
||||
this.week = week;
|
||||
}
|
||||
|
||||
public void add(ItemCollection invoice) {
|
||||
public void add(ItemCollection invoice, String currency1) {
|
||||
String spaceName = invoice.getItemValueString("space.name");
|
||||
String currency = invoice.getItemValueString("invoice.currency");
|
||||
// Double total = invoice.getItemValueDouble("invoice.total");
|
||||
Double total = invoice.getItemValueDouble("invoice.saldo");
|
||||
if ("EUR".equals(currency)) {
|
||||
totalEUR = totalEUR + total;
|
||||
if (currency1.equals(currency)) {
|
||||
totalCurrency1 = totalCurrency1 + total;
|
||||
} else {
|
||||
totalUSD = totalUSD + total;
|
||||
totalCurrency2 = totalCurrency2 + total;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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:value><![CDATA[1]]></imixs:value>
|
||||
</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:incoming>SequenceFlow_2</bpmn2:incoming>
|
||||
<bpmn2:outgoing>SequenceFlow_6</bpmn2:outgoing>
|
||||
|
|
|
|||
Loading…
Reference in a new issue