diff --git a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/OPListExportAdapterByWeek.java b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/OPListExportAdapterByWeek.java index 7d4bf37..359caaf 100644 --- a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/OPListExportAdapterByWeek.java +++ b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/OPListExportAdapterByWeek.java @@ -393,12 +393,13 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter { column = 1; double kwTotalEUR = 0; double kwTotalUSD = 0; - + WeekInvoiceData weekDataTotal = weekDataMap.get("TOTAL/" + week); for (String name : spaceNames) { String key = name + "/" + week; logger.info("search WeekInvoiceData for " + key); // list of invoices WeekInvoiceData weekData = weekDataMap.get(key); + if (weekData != null) { // logger.fine(" " + currency1 + "=" + weekData.totalCurrency1 + " " + currency2 // + "=" @@ -414,8 +415,12 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter { } else { totalDataMapFaellig.get(name).add(betrag, currency); } + weekDataTotal.add(betrag, currency); + column++; + } + // row.getCell(column).setCellValue(weekData.totalCurrency1); // column++; // row.getCell(column).setCellValue(weekData.totalCurrency2); @@ -450,6 +455,12 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter { } } // KW Summe anzeigen + + for (String currency : currencyList) { + row.getCell(column).setCellValue(weekDataTotal.getTotal(currency)); + column++; + } + // if (week.equals(currentWeekCategory)) { // XSSFCell kwTotalCell = row.getCell(column); // // kwTotalCell.copyCellFrom(cellKWTotalReference, new CellCopyPolicy()); @@ -545,9 +556,10 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter { // totalCell.setCellValue(totalsUeberfaelligCurrency2.get("TOTAL") + // totalsFaelligCurrency2.get("TOTAL")); - // delete placeholder rows + // delete placeholder rows (Never change these lines) sheet.shiftRows(_rowNo, _rowNo + 3, -1); sheet.shiftRows(_rowNo - 1, _rowNo - 1 + 3, -1); + sheet.shiftRows(12, _rowNo + 3, -1); logger.finest("......invoices added"); } @@ -593,6 +605,11 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter { if (weekData == null) { weekData = new WeekInvoiceData(spaceName, weekCategory); } + WeekInvoiceData weekDataTotal = weekDataCache.get("TOTAL/" + weekCategory); + if (weekDataTotal == null) { + weekDataTotal = new WeekInvoiceData("TOTAL", weekCategory); + weekDataCache.put("TOTAL/" + weekCategory, weekDataTotal); + } // Jetzt Rechnung addieren weekData.add(invoice); weekDataCache.put(key, weekData); @@ -668,6 +685,15 @@ class WeekInvoiceData { totals.put(currency, InvoiceUtil.round(totalCurrency)); } + public void add(double total, String currency) { + Double totalCurrency = totals.get(currency); + if (totalCurrency == null) { + totalCurrency = 0.0; + } + totalCurrency = totalCurrency + total; + totals.put(currency, InvoiceUtil.round(totalCurrency)); + } + public double getTotal(String currency) { Double result = totals.get(currency); if (result != null) { diff --git a/templates/op-liste_kw_template.xlsx b/templates/op-liste_kw_template.xlsx index 6ba86b2..bd582ab 100644 Binary files a/templates/op-liste_kw_template.xlsx and b/templates/op-liste_kw_template.xlsx differ