Explorar el Código

get cell type of invoice no, if numeric, convert to int and to string, to prevent showing .0

develop
MSI\2Fi hace 4 meses
padre
commit
d85eeb8871
Se han modificado 1 ficheros con 34 adiciones y 3 borrados
  1. +34
    -3
      src/main/java/com/ffii/tsms/modules/project/service/InvoiceService.kt

+ 34
- 3
src/main/java/com/ffii/tsms/modules/project/service/InvoiceService.kt Ver fichero

@@ -380,6 +380,8 @@ open class InvoiceService(
return invoiceRepository.findInvoiceInfoByPaidAmountIsNotNull()
}



@Transactional(rollbackFor = [Exception::class])
open fun importIssueInvoice(workbook: Workbook?): InvoiceResponse {

@@ -416,7 +418,17 @@ open class InvoiceService(
// println(ExcelUtils.getCell(sheet, i, 0))
// println("sheet.physicalNumberOfRows ${sheet.physicalNumberOfRows}")
// println("sheet.lastRowNum ${sheet.lastRowNum}")
val sheetInvoice = ExcelUtils.getCell(sheet, i, 0).toString()
val sheetInvoiceCell = ExcelUtils.getCell(sheet, i, 0)
val sheetInvoice = when (sheetInvoiceCell.cellType) {
CellType.STRING -> sheetInvoiceCell.stringCellValue
CellType.NUMERIC -> {
val numericValue = sheetInvoiceCell.numericCellValue
numericValue.toInt().toString() // Return as integer string

}
CellType.BLANK -> "" // Return empty string for blank cells
else -> "Unsupported cell type"
}
val sheetProjectCode = ExcelUtils.getCell(sheet, i, 1).stringCellValue
checkInvoiceNo(sheetInvoice, invoices, invoicesResult, true)
checkProjectCode(sheetProjectCode, projects, newProjectCodes)
@@ -455,7 +467,16 @@ open class InvoiceService(
// val paymentMilestoneId = getMilestonePaymentId(ExcelUtils.getCell(sheet, i, 1).stringCellValue, ExcelUtils.getCell(sheet, i, 5).stringCellValue)
// val milestonePayment = milestonePaymentRepository.findById(paymentMilestoneId).orElseThrow()
val invoice = Invoice().apply {
invoiceNo = ExcelUtils.getCell(sheet, i, 0).toString()
invoiceNo = when (ExcelUtils.getCell(sheet, i, 0).cellType) {
CellType.STRING -> ExcelUtils.getCell(sheet, i, 0).stringCellValue
CellType.NUMERIC -> {
val numericValue = ExcelUtils.getCell(sheet, i, 0).numericCellValue
numericValue.toInt().toString() // Return as integer string

}
CellType.BLANK -> "" // Return empty string for blank cells
else -> "Unsupported cell type"
}
projectCode = ExcelUtils.getCell(sheet, i, 1).stringCellValue
// projectName = ExcelUtils.getCell(sheet, i, 2).stringCellValue
// team = ExcelUtils.getCell(sheet, i, 3).stringCellValue
@@ -513,7 +534,17 @@ open class InvoiceService(
if(ExcelUtils.getCell(sheet, i, 0).cellType == CellType.BLANK){
break
}
val sheetInvoice = ExcelUtils.getCell(sheet, i, 0).toString()
val sheetInvoiceCell = ExcelUtils.getCell(sheet, i, 0)
val sheetInvoice = when (sheetInvoiceCell.cellType) {
CellType.STRING -> sheetInvoiceCell.stringCellValue
CellType.NUMERIC -> {
val numericValue = sheetInvoiceCell.numericCellValue
numericValue.toInt().toString() // Return as integer string

}
CellType.BLANK -> "" // Return empty string for blank cells
else -> "Unsupported cell type"
}
val sheetProjectCode = ExcelUtils.getCell(sheet, i, 1).stringCellValue
checkInvoiceNo(sheetInvoice, invoices, invoicesResult, false)
checkProjectCode(sheetProjectCode, projects, newProjectCodes)


Cargando…
Cancelar
Guardar