From f80f1ed6eb8d5ba5d09df4cfb645c1627b74e6d0 Mon Sep 17 00:00:00 2001 From: Gauthier LO Date: Mon, 5 Aug 2024 13:36:08 +0200 Subject: [PATCH 1/2] fix again --- .../domain/invoice/AbstractInvoice.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/invoice/AbstractInvoice.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/invoice/AbstractInvoice.java index 4a137384e..2782b10ec 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/invoice/AbstractInvoice.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/invoice/AbstractInvoice.java @@ -1,5 +1,6 @@ package org.jeecg.modules.business.domain.invoice; +import com.amazonaws.services.dynamodbv2.xspec.S; import lombok.extern.slf4j.Slf4j; import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.util.CellReference; @@ -171,6 +172,7 @@ public abstract class AbstractInvoice { // si le nombre de lignes de data rentre dans 1 page A4 if(data.size() < 44) { + // Fit in A4 page" if(TOTAL_ROW > LAST_ROW + 3) { // s'il ne reste pas assez de place pour le footer // on shift le footer à la page suivante (total + signature etc..) sheet.shiftRows(startRow, fileLastRow, PAGE_ROW_MAX - LAST_ROW - 1, true, false); @@ -186,12 +188,14 @@ public abstract class AbstractInvoice { } else {// on dépasse forcément le format A4 d'un PDF if(((TOTAL_ROW - 44) % 63) < 13) { + // Not enough space for footer sheet.shiftRows(startRow, fileLastRow, TOTAL_ROW - LAST_ROW + ((TOTAL_ROW-44)%63), true, false); footerRow = additionalRowNum + ((TOTAL_ROW-44)%63) + 1; imgShift = TOTAL_ROW-44 + ((TOTAL_ROW-44)%63) -1; TOTAL_ROW += ((TOTAL_ROW-44)%63) + 1; } else { + // Enough space for footer sheet.shiftRows(startRow, fileLastRow, TOTAL_ROW - LAST_ROW, true, false); footerRow = TOTAL_ROW - LAST_ROW +1; } @@ -254,6 +258,7 @@ public abstract class AbstractInvoice { if(data.size() > dataRowNumber) { org.apache.poi.ss.usermodel.Row totalRow; + // Si ça pète c'est surement ici if(additionalRowNum%PAGE_ROW_MAX <= 13) totalRow = sheet.getRow(TOTAL_ROW-1); else @@ -322,18 +327,11 @@ public abstract class AbstractInvoice { totalDueCellStyle.setBorderTop(BorderStyle.THIN); totalDueCellStyle.setFont(arialBold); - if(((LAST_ROW+additionalRowNum - 44) % 63) < 13 && ((LAST_ROW+additionalRowNum - 44) % 63) > 0) { - totalDueRow = sheet.getRow( data.size() < 44 ? PAGE_ROW_MAX + 1 : TOTAL_ROW + 1); - Cell totalDueCell = totalDueRow.createCell(7); - totalDueCell.setCellFormula("H" + (TOTAL_ROW) + "-G" + (TOTAL_ROW)); - totalDueCell.setCellStyle(totalDueCellStyle); - } - else { - totalDueRow = sheet.getRow(data.size() < 44 ? TOTAL_ROW + 1 : TOTAL_ROW + 2); - Cell totalDueCell = totalDueRow.createCell(7); - totalDueCell.setCellFormula("H" + (data.size() < 44 ? TOTAL_ROW : TOTAL_ROW + 1) + "-G" + (data.size() < 44 ? TOTAL_ROW : TOTAL_ROW + 1)); - totalDueCell.setCellStyle(totalDueCellStyle); - } + // Si ça pète c'est pas là + totalDueRow = sheet.getRow( totalRow.getRowNum() + 2); + Cell totalDueCell = totalDueRow.createCell(7); + totalDueCell.setCellFormula("H" + (totalRow.getRowNum() + 1) + "-G" + (totalRow.getRowNum()) + 1); + totalDueCell.setCellStyle(totalDueCellStyle); } if (targetClient.getCurrency().equals("USD")) { From dd7c44fdcba05f7d75438dc5c0bca3a5f8fe20ad Mon Sep 17 00:00:00 2001 From: Gauthier LO Date: Mon, 5 Aug 2024 13:36:53 +0200 Subject: [PATCH 2/2] clean --- .../jeecg/modules/business/domain/invoice/AbstractInvoice.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/invoice/AbstractInvoice.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/invoice/AbstractInvoice.java index 2782b10ec..50deecae8 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/invoice/AbstractInvoice.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/invoice/AbstractInvoice.java @@ -1,6 +1,5 @@ package org.jeecg.modules.business.domain.invoice; -import com.amazonaws.services.dynamodbv2.xspec.S; import lombok.extern.slf4j.Slf4j; import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.util.CellReference; @@ -12,7 +11,6 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.math.BigDecimal; -import java.nio.file.Files; import java.nio.file.Path; import java.util.Date; import java.util.HashMap;