update oplisten formatierung

This commit is contained in:
Ralph Soika 2023-02-09 13:41:53 +01:00
parent 4f88884d71
commit 6a07ec3c18
3 changed files with 29 additions and 13 deletions

View file

@ -15,6 +15,7 @@ import javax.inject.Inject;
import org.apache.poi.ss.usermodel.CellCopyPolicy; import org.apache.poi.ss.usermodel.CellCopyPolicy;
import org.apache.poi.ss.util.CellReference; import org.apache.poi.ss.util.CellReference;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@ -132,7 +133,8 @@ public class OPListExportAdapter extends POIFindReplaceAdapter {
*/ */
private void insertInvoiceRows(ItemCollection document, String fileName) throws PluginException, QueryException { private void insertInvoiceRows(ItemCollection document, String fileName) throws PluginException, QueryException {
double saldo = 0; double saldoUSD = 0;
double saldoEUR = 0;
// load dummy rechnungen // load dummy rechnungen
String spaceID = document.getItemValueString("space.ref"); String spaceID = document.getItemValueString("space.ref");
@ -180,12 +182,20 @@ public class OPListExportAdapter extends POIFindReplaceAdapter {
categoryRow.getCell(1).setCellValue(debitorName); categoryRow.getCell(1).setCellValue(debitorName);
// calculate summ of all invoices // calculate summ of all invoices
double catSum = 0; double catSumEUR = 0;
double catSumUSD = 0;
for (ItemCollection invoice : invoices) { for (ItemCollection invoice : invoices) {
catSum = catSum + invoice.getItemValueDouble("invoice.saldo"); if ("EUR".equals(invoice.getItemValueString("invoice.currency"))) {
catSumEUR = catSumEUR + invoice.getItemValueDouble("invoice.saldo");
} else {
catSumUSD = catSumUSD + invoice.getItemValueDouble("invoice.saldo");
}
} }
logger.fine("......... sum=" + catSum);
categoryRow.getCell(10).setCellValue(catSum); categoryRow.getCell(6).setCellValue(catSumEUR);
categoryRow.getCell(8).setCellValue(catSumUSD);
rowPos++; rowPos++;
// jetzt füge alle Rechnungen an. // jetzt füge alle Rechnungen an.
@ -206,13 +216,15 @@ public class OPListExportAdapter extends POIFindReplaceAdapter {
// EUR // EUR
row.getCell(6).setCellValue(total); row.getCell(6).setCellValue(total);
row.getCell(7).setCellValue(currency); row.getCell(7).setCellValue(currency);
saldoEUR =roundD( saldoEUR + total);
} else { } else {
// USD // USD
row.getCell(8).setCellValue(total); row.getCell(8).setCellValue(total);
row.getCell(9).setCellValue(currency); row.getCell(9).setCellValue(currency);
saldoUSD = roundD( saldoUSD + total);
} }
row.getCell(10).setCellValue(invoice.getItemValueString("$workflowstatus")); row.getCell(10).setCellValue(invoice.getItemValueString("$workflowstatus"));
saldo = saldo + total;
rowPos++; rowPos++;
} }
} }
@ -220,19 +232,21 @@ public class OPListExportAdapter extends POIFindReplaceAdapter {
sheet.shiftRows(referenceRowPos, lastRow + totalRowCount, -1, true, true); sheet.shiftRows(referenceRowPos, lastRow + totalRowCount, -1, true, true);
// finally update the total formula... // finally update the total formula...
evalXSSFSheet(doc, sheet, "TOTALEUR"); XSSFCell cTotalEUR = getCellByRef(doc, sheet, "TOTALEUR");
evalXSSFSheet(doc, sheet, "TOTALUSD"); XSSFCell cTotalUSD = getCellByRef(doc, sheet, "TOTALUSD");
cTotalEUR.setCellValue(saldoEUR);
cTotalUSD.setCellValue(saldoUSD);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
// write back the file // write back the file
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
doc.write(byteArrayOutputStream); doc.write(byteArrayOutputStream);
byte[] newContent = byteArrayOutputStream.toByteArray(); byte[] newContent = byteArrayOutputStream.toByteArray();
FileData fileDataNew = new FileData(fileData.getName(), newContent, fileData.getContentType(), null); FileData fileDataNew = new FileData(fileData.getName(), newContent, fileData.getContentType(), null);
// update the fileData // update the fileData
document.addFileData(fileDataNew); document.addFileData(fileDataNew);
document.setItemValue("space.saldo", saldo); document.setItemValue("space.saldo.eur", saldoEUR);
document.setItemValue("space.saldo.usd", saldoUSD);
logger.finest("......new document added"); logger.finest("......new document added");
} catch (IOException e) { } catch (IOException e) {
@ -350,5 +364,7 @@ public class OPListExportAdapter extends POIFindReplaceAdapter {
return result; return result;
} }
private double roundD(double wert) {
return Math.round(wert * 100.0f) / 100.0f;
}
} }

View file

@ -21,7 +21,7 @@
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format> <maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
<!-- Versions --> <!-- Versions -->
<org.imixs.workflow.version>5.2.16</org.imixs.workflow.version> <org.imixs.workflow.version>5.2.18</org.imixs.workflow.version>
<org.imixs.marty.version>4.2.3</org.imixs.marty.version> <org.imixs.marty.version>4.2.3</org.imixs.marty.version>
<org.imixs.office.version>4.5.3</org.imixs.office.version> <org.imixs.office.version>4.5.3</org.imixs.office.version>
<org.imixs.adapters.version>2.3.1</org.imixs.adapters.version> <org.imixs.adapters.version>2.3.1</org.imixs.adapters.version>

Binary file not shown.