✨ 汇总账单导出保留收货时间
This commit is contained in:
+35
-3
@@ -26,6 +26,8 @@ import com.bms.receivable.domain.ArExportTemplate;
|
||||
import com.bms.receivable.mapper.ArBillDetailFeeMapper;
|
||||
import com.bms.receivable.mapper.ArBillDetailMapper;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.apache.poi.ss.usermodel.DataFormatter;
|
||||
import org.apache.poi.ss.usermodel.DateUtil;
|
||||
import org.apache.poi.ss.usermodel.FormulaEvaluator;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
@@ -37,6 +39,36 @@ class ArBillWorkbookWriterTest {
|
||||
@TempDir
|
||||
Path temporary;
|
||||
|
||||
@Test
|
||||
void summaryDetailsKeepReceiptDateTimeAsExcelDateForNormalAndHighlightedRows() throws Exception {
|
||||
ArBillDetail normal = detail(1, "P1", "1.00");
|
||||
normal.setReceiveTime(Timestamp.valueOf("2026-10-01 21:32:51"));
|
||||
ArBillDetail failed = detail(2, "P1", "1.00");
|
||||
failed.setReceiveTime(Timestamp.valueOf("2026-10-02 00:01:02"));
|
||||
failed.setBillingFailStatus(2);
|
||||
ArBillDetail missing = detail(3, "P1", "1.00");
|
||||
missing.setReceiveTime(null);
|
||||
Path target = temporary.resolve("summary-receipt-times.xlsx");
|
||||
summaryWriter(List.of(normal, failed, missing)).write(bill(3, "3.00", "CNY"), summaryTemplate(), target);
|
||||
|
||||
try (XSSFWorkbook workbook = new XSSFWorkbook(target.toFile())) {
|
||||
XSSFSheet sheet = workbook.getSheetAt(1);
|
||||
var normalCell = sheet.getRow(4).getCell(1);
|
||||
var failedCell = sheet.getRow(5).getCell(1);
|
||||
assertEquals(CellType.NUMERIC, normalCell.getCellType());
|
||||
assertEquals(CellType.NUMERIC, failedCell.getCellType());
|
||||
assertTrue(DateUtil.isCellDateFormatted(normalCell));
|
||||
assertTrue(DateUtil.isCellDateFormatted(failedCell));
|
||||
assertEquals("yyyy/mm/dd", normalCell.getCellStyle().getDataFormatString());
|
||||
assertEquals("2026/10/01", new DataFormatter().formatCellValue(normalCell));
|
||||
assertEquals(LocalDateTime.of(2026, 10, 1, 21, 32, 51), normalCell.getLocalDateTimeCellValue());
|
||||
assertEquals("2026/10/02", new DataFormatter().formatCellValue(failedCell));
|
||||
assertEquals(LocalDateTime.of(2026, 10, 2, 0, 1, 2), failedCell.getLocalDateTimeCellValue());
|
||||
assertEquals(IndexedColors.YELLOW.getIndex(), failedCell.getCellStyle().getFillForegroundColor());
|
||||
assertEquals("", sheet.getRow(6).getCell(1).getStringCellValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void summaryAndDetailsReconcileSnapshotAmountsAndKeepFreightFormulaAndBlankFields() throws Exception {
|
||||
ArBill bill = bill(3, "13.20", "CNY");
|
||||
@@ -231,9 +263,9 @@ class ArBillWorkbookWriterTest {
|
||||
assertEquals("20261001-20261030", summary.getRow(3).getCell(3).getStringCellValue());
|
||||
assertEquals("20261001-20261030", summary.getRow(4).getCell(3).getStringCellValue());
|
||||
assertEquals("20261001-20261030", freight.getRow(2).getCell(18).getStringCellValue());
|
||||
assertEquals("2026-10-20", freight.getRow(4).getCell(1).getStringCellValue());
|
||||
assertEquals("2026-10-01", freight.getRow(5).getCell(1).getStringCellValue());
|
||||
assertEquals("2026-10-30", freight.getRow(6).getCell(1).getStringCellValue());
|
||||
assertEquals(LocalDateTime.of(2026, 10, 20, 0, 0), freight.getRow(4).getCell(1).getLocalDateTimeCellValue());
|
||||
assertEquals(LocalDateTime.of(2026, 10, 1, 0, 0), freight.getRow(5).getCell(1).getLocalDateTimeCellValue());
|
||||
assertEquals(LocalDateTime.of(2026, 10, 30, 0, 0), freight.getRow(6).getCell(1).getLocalDateTimeCellValue());
|
||||
}
|
||||
verify(writer.detailMapper, times(1)).selectReceiveTimeRangeByBillId(7L);
|
||||
assertEquals(Date.valueOf("2026-09-29"), bill.getBillPeriodStart());
|
||||
|
||||
Reference in New Issue
Block a user