neues OP Listen Template

This commit is contained in:
Ralph Soika 2024-06-06 11:39:36 +02:00
parent 3631fed1c6
commit 9a6c7e0741
2 changed files with 81 additions and 19 deletions

View file

@ -159,8 +159,8 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
double saldoEUR1 = 0;
double saldoUSD2 = 0;
double saldoEUR2 = 0;
double saldoUSD3 = 0;
double saldoEUR3 = 0;
// double saldoUSD3 = 0;
// double saldoEUR3 = 0;
List<String> spaceNames = new ArrayList<String>();
// compute all departments
@ -203,6 +203,8 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
XSSFRow referenceRowValues = sheet.getRow(11);
XSSFRow referenceRowCurrentWeek = sheet.getRow(12);
XSSFRow referenceRowTotal = sheet.getRow(15);
// Aktuelle KW berechnen
calendar.setTime(new Date());
int currentWeekNumber = calendar.get(Calendar.WEEK_OF_YEAR);
@ -214,9 +216,16 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
currentWeekCategory = currentWeekCategory + currentWeekNumber;
}
/*
* --- Phase 1 -------------------------------------------------------
* Im folgenden fügen wir erst einmal in der Kopfzeile zusätzlich
* Spaltenüberschriften für jede Abteilung ein
*/
XSSFCell cellSpaceLabelReference = rowSpacesLabels.getCell(2);
XSSFCell cellSpaceCurrencyReference = referenceRowSpacesCurrencies.getCell(1);
int column = 1;
// XSSFCell cellKWTotalReference = referenceRowCurrentWeek.getCell(1);
XSSFCell cellKWTotalReference = referenceRowTotal.getCell(14);
int column = 1; // beginn in der 2. Spalte!
for (ItemCollection space : spaces) {
XSSFCell cell = null;
String spaceName = space.getItemValueString("space.name");
@ -251,12 +260,40 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
logger.info("...grouping invoices by week...");
// collect all invoices for this space grouped by week....
groupInvoicesByWeek(spaceID, spaceName, weekDataMap);
}
// now build a new row for each week and print out the collected invoice data
// first iterate over all objects and collect all known weeks and sort them into
// a ordered list....
/*
* --- 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);
cell.copyCellFrom(cellKWTotalReference, new CellCopyPolicy());
cell.setCellValue("EUR");
cell = rowSpacesLabels.getCell(column);
cell.copyCellFrom(cellKWTotalReference, new CellCopyPolicy());
cell.setCellValue("");
// Space currency USD
column++;
cell = referenceRowSpacesCurrencies.getCell(column);
cell.copyCellFrom(cellKWTotalReference, new CellCopyPolicy());
cell.setCellValue("USD");
// Space Label
cell = rowSpacesLabels.getCell(column);
cell.copyCellFrom(cellKWTotalReference, new CellCopyPolicy());
cell.setCellValue("Gesamt");
/*
* --- Phase 3 -------------------------------------------------------
* now build a new row for each week and print out the collected invoice data
* first iterate over all objects and collect all known weeks and sort them into
* a ordered list....
*/
List<String> sortedWeekList = new ArrayList<String>();
Iterator<Map.Entry<String, WeekInvoiceData>> iterator = weekDataMap.entrySet().iterator();
while (iterator.hasNext()) {
@ -268,18 +305,19 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
}
Collections.sort(sortedWeekList);
int rowPos = 11;
/*
* --- Phase 4 -------------------------------------------------------
* Nun müssen wir so viele Zeilen nach unten schieben wie wir gleich einfügen.
* Dazu müssen wir kurz einen Probelauf machen um die geplante Anzahl zu
* errechnen....
*/
int rowPos = 11;
int insertCount = sortedWeekList.size();
sheet.shiftRows(rowPos + 1, 2999, insertCount, true, true);
/*
* Jetzt Zeile für Zeile einfügen....
* --- Phase 5 -------------------------------------------------------
* Jetzt Zahlen Zeile für Zeile einfügen....
*/
boolean ueberFaellig = true;
for (String week : sortedWeekList) {
@ -301,6 +339,8 @@ 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;
for (String name : spaceNames) {
String key = name + "/" + week;
logger.info("search WeekInvoiceData for " + key);
@ -309,29 +349,48 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
if (weekData != null) {
logger.info(" EUR=" + weekData.totalEUR + " USD=" + weekData.totalUSD);
row.getCell(column).setCellValue(weekData.totalEUR);
column++;
row.getCell(column).setCellValue(weekData.totalUSD);
saldoUSD3 = InvoiceUtil.round(saldoUSD3 + weekData.totalUSD);
if (ueberFaellig) {
saldoEUR1 = InvoiceUtil.round(saldoEUR1 + weekData.totalEUR);
saldoUSD1 = InvoiceUtil.round(saldoUSD1 + weekData.totalUSD);
} else {
saldoEUR2 = InvoiceUtil.round(saldoEUR2 + weekData.totalEUR);
saldoUSD2 = InvoiceUtil.round(saldoUSD2 + weekData.totalUSD);
}
kwTotalEUR = kwTotalEUR + weekData.totalEUR;
kwTotalUSD = kwTotalUSD + weekData.totalUSD;
column++;
} else {
logger.info("...... NOT FOUND");
// skip columns
column = column + 2;
}
}
// KW Summe anzeigen
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);
}
}
// delete reference rows
@ -339,8 +398,11 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
sheet.shiftRows(12, rowPos, -1, true, true);
sheet.shiftRows(rowPos + 2, rowPos + 6, -3, true, true);
// now lets update the totals...
// Überfällig
/*
* --- Phase 6 -------------------------------------------------------
* now lets update the totals...
* Überfällig
*/
XSSFCell cTotalEUR1 = getCellByRef(doc, sheet, "TOTALEUR1");
XSSFCell cTotalUSD1 = getCellByRef(doc, sheet, "TOTALUSD1");
cTotalEUR1.setCellValue(saldoEUR1);

Binary file not shown.