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 359caaf..69d16fe 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 @@ -174,7 +174,6 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter { } } } - // Finally process POI instructions processPOIUpdate(document, event, targetName); @@ -273,8 +272,6 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter { XSSFRow referenceRowValues = sheet.getRow(11); XSSFRow referenceRowCurrentWeek = sheet.getRow(12); - XSSFRow referenceRowTotal = sheet.getRow(15); - // Aktuelle KW berechnen Calendar calendar = new GregorianCalendar(); calendar.setTime(new Date()); @@ -310,36 +307,6 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter { totalDataMapFaellig.put("TOTAL", new TotalInvoiceData("TOTAL")); totalDataMapUeberFaellig.put("TOTAL", new TotalInvoiceData("TOTAL")); - /* - * --- Phase 2 ------------------------------------------------------- - * Nun bilden wir nochmal 2 weitere Spalten am Ende um eine Summenbildung in - * EUR/USD pro KW zu ermöglichen - */ - // XSSFCell cell = null; - // column++; - // // Space currency EUR - // cell = referenceRowSpacesCurrencies.getCell(column, - // MissingCellPolicy.CREATE_NULL_AS_BLANK); - // cell.copyCellFrom(cellKWTotalReference, new CellCopyPolicy()); - // cell.setCellValue(currency1); - // cell = rowSpacesLabels.getCell(column, - // MissingCellPolicy.CREATE_NULL_AS_BLANK); - // cell.copyCellFrom(cellKWTotalReference, new CellCopyPolicy()); - // cell.setCellValue(""); - - // Space currency USD - // column++; - // cell = referenceRowSpacesCurrencies.getCell(column, - // MissingCellPolicy.CREATE_NULL_AS_BLANK); - // cell.copyCellFrom(cellKWTotalReference, new CellCopyPolicy()); - // cell.setCellValue(currency2); - - // // Space Label - // cell = rowSpacesLabels.getCell(column, - // MissingCellPolicy.CREATE_NULL_AS_BLANK); - // cell.copyCellFrom(cellKWTotalReference, new CellCopyPolicy()); - // cell.setCellValue("Total"); - /* * --- Phase 3 ------------------------------------------------------- * now build a new row for each week and print out the collected invoice data @@ -391,8 +358,6 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter { // iterate over all spaceNames and test if we have any data to put it into the // row cells.... column = 1; - double kwTotalEUR = 0; - double kwTotalUSD = 0; WeekInvoiceData weekDataTotal = weekDataMap.get("TOTAL/" + week); for (String name : spaceNames) { String key = name + "/" + week; @@ -416,36 +381,9 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter { totalDataMapFaellig.get(name).add(betrag, currency); } weekDataTotal.add(betrag, currency); - column++; - } - // row.getCell(column).setCellValue(weekData.totalCurrency1); - // column++; - // row.getCell(column).setCellValue(weekData.totalCurrency2); - // if (ueberFaellig) { - // 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 = 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.totalCurrency1; - // kwTotalUSD = kwTotalUSD + weekData.totalCurrency2; - // column++; } else { logger.info("...... NOT FOUND"); // skip columns @@ -455,58 +393,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()); - // kwTotalCell.setCellValue(kwTotalEUR); - - // column++; - // // row.getCell(column).setCellValue(kwTotalUSD); - // kwTotalCell = row.getCell(column); - // // kwTotalCell.copyCellFrom(cellKWTotalReference, new CellCopyPolicy()); - // kwTotalCell.setCellValue(kwTotalUSD); - - // } else { - // XSSFCell kwTotalCell = row.getCell(column); - // kwTotalCell.copyCellFrom(cellKWTotalReference, new CellCopyPolicy()); - // kwTotalCell.setCellValue(kwTotalEUR); - - // column++; - // // row.getCell(column).setCellValue(kwTotalUSD); - // kwTotalCell = row.getCell(column); - // kwTotalCell.copyCellFrom(cellKWTotalReference, new CellCopyPolicy()); - // kwTotalCell.setCellValue(kwTotalUSD); - - // } - - // store totals - // if (ueberFaellig) { - // double eur = totalsUeberfaelligCurrency1.get("TOTAL"); - // eur = InvoiceUtil.round(eur + kwTotalEUR); - // totalsUeberfaelligCurrency1.put("TOTAL", eur); - // double usd = totalsUeberfaelligCurrency2.get("TOTAL"); - // usd = InvoiceUtil.round(usd + kwTotalUSD); - // totalsUeberfaelligCurrency2.put("TOTAL", usd); - // } else { - // double eur = totalsFaelligCurrency1.get("TOTAL"); - // eur = InvoiceUtil.round(eur + kwTotalEUR); - // totalsFaelligCurrency1.put("TOTAL", eur); - // double usd = totalsFaelligCurrency2.get("TOTAL"); - // usd = InvoiceUtil.round(usd + kwTotalUSD); - // totalsFaelligCurrency2.put("TOTAL", usd); - // } - } - // delete reference rows - // logger.info("..shift 12 to " + rowPos); - // sheet.shiftRows(12, rowPos, -1, true, true); - // sheet.shiftRows(rowPos + 2, rowPos + 6, -3, true, true); /* * --- Phase 6 ------------------------------------------------------- @@ -519,6 +411,11 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter { XSSFRow rowTotal = sheet.getRow(_rowNo + 2); column = 1; XSSFCell totalCell = null; + + WeekInvoiceData superTotalUeberfaellig = new WeekInvoiceData("SUPERTOTAL", "0"); + WeekInvoiceData superTotalFaellig = new WeekInvoiceData("SUPERTOTAL", "0"); + WeekInvoiceData superTotalSuper = new WeekInvoiceData("SUPERTOTAL", "0"); + for (String name : spaceNames) { TotalInvoiceData totalDataUeberFaellig = totalDataMapUeberFaellig.get(name); @@ -527,34 +424,34 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter { // überfällig totalCell = rowUeberFaellig.getCell(column); totalCell.setCellValue(totalDataUeberFaellig.getTotal(currency)); + superTotalUeberfaellig.add(totalDataUeberFaellig.getTotal(currency), currency); + // noch nicht fällig totalCell = rowFaellig.getCell(column); totalCell.setCellValue(totalDataFaellig.getTotal(currency)); + superTotalFaellig.add(totalDataFaellig.getTotal(currency), currency); + // total... totalCell = rowTotal.getCell(column); totalCell.setCellValue(InvoiceUtil .round(totalDataUeberFaellig.getTotal(currency) + totalDataFaellig.getTotal(currency))); - + superTotalSuper.add(totalDataUeberFaellig.getTotal(currency) + totalDataFaellig.getTotal(currency), + currency); column++; } } - // // totals - // totalCell = rowUeberFaellig.getCell(column); - // totalCell.setCellValue(totalsUeberfaellig.get("TOTAL")); - // totalCell = rowFaellig.getCell(column); - // totalCell.setCellValue(totalsFaelligCurrency1.get("TOTAL")); - // totalCell = rowTotal.getCell(column); - // totalCell.setCellValue(totalsUeberfaelligCurrency1.get("TOTAL") + - // totalsFaelligCurrency1.get("TOTAL")); - // column++; - // totalCell = rowUeberFaellig.getCell(column); - // totalCell.setCellValue(totalsUeberfaelligCurrency2.get("TOTAL")); - // totalCell = rowFaellig.getCell(column); - // totalCell.setCellValue(totalsFaelligCurrency2.get("TOTAL")); - // totalCell = rowTotal.getCell(column); - // totalCell.setCellValue(totalsUeberfaelligCurrency2.get("TOTAL") + - // totalsFaelligCurrency2.get("TOTAL")); + // Fill Super Totals + + for (String currency : currencyList) { + totalCell = rowUeberFaellig.getCell(column); + totalCell.setCellValue(superTotalUeberfaellig.getTotal(currency)); + totalCell = rowFaellig.getCell(column); + totalCell.setCellValue(superTotalFaellig.getTotal(currency)); + totalCell = rowTotal.getCell(column); + totalCell.setCellValue(superTotalSuper.getTotal(currency)); + column++; + } // delete placeholder rows (Never change these lines) sheet.shiftRows(_rowNo, _rowNo + 3, -1);