| @@ -380,6 +380,8 @@ open class InvoiceService( | |||||
| return invoiceRepository.findInvoiceInfoByPaidAmountIsNotNull() | return invoiceRepository.findInvoiceInfoByPaidAmountIsNotNull() | ||||
| } | } | ||||
| @Transactional(rollbackFor = [Exception::class]) | @Transactional(rollbackFor = [Exception::class]) | ||||
| open fun importIssueInvoice(workbook: Workbook?): InvoiceResponse { | open fun importIssueInvoice(workbook: Workbook?): InvoiceResponse { | ||||
| @@ -416,7 +418,17 @@ open class InvoiceService( | |||||
| // println(ExcelUtils.getCell(sheet, i, 0)) | // println(ExcelUtils.getCell(sheet, i, 0)) | ||||
| // println("sheet.physicalNumberOfRows ${sheet.physicalNumberOfRows}") | // println("sheet.physicalNumberOfRows ${sheet.physicalNumberOfRows}") | ||||
| // println("sheet.lastRowNum ${sheet.lastRowNum}") | // 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 | val sheetProjectCode = ExcelUtils.getCell(sheet, i, 1).stringCellValue | ||||
| checkInvoiceNo(sheetInvoice, invoices, invoicesResult, true) | checkInvoiceNo(sheetInvoice, invoices, invoicesResult, true) | ||||
| checkProjectCode(sheetProjectCode, projects, newProjectCodes) | 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 paymentMilestoneId = getMilestonePaymentId(ExcelUtils.getCell(sheet, i, 1).stringCellValue, ExcelUtils.getCell(sheet, i, 5).stringCellValue) | ||||
| // val milestonePayment = milestonePaymentRepository.findById(paymentMilestoneId).orElseThrow() | // val milestonePayment = milestonePaymentRepository.findById(paymentMilestoneId).orElseThrow() | ||||
| val invoice = Invoice().apply { | 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 | projectCode = ExcelUtils.getCell(sheet, i, 1).stringCellValue | ||||
| // projectName = ExcelUtils.getCell(sheet, i, 2).stringCellValue | // projectName = ExcelUtils.getCell(sheet, i, 2).stringCellValue | ||||
| // team = ExcelUtils.getCell(sheet, i, 3).stringCellValue | // team = ExcelUtils.getCell(sheet, i, 3).stringCellValue | ||||
| @@ -513,7 +534,17 @@ open class InvoiceService( | |||||
| if(ExcelUtils.getCell(sheet, i, 0).cellType == CellType.BLANK){ | if(ExcelUtils.getCell(sheet, i, 0).cellType == CellType.BLANK){ | ||||
| break | 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 | val sheetProjectCode = ExcelUtils.getCell(sheet, i, 1).stringCellValue | ||||
| checkInvoiceNo(sheetInvoice, invoices, invoicesResult, false) | checkInvoiceNo(sheetInvoice, invoices, invoicesResult, false) | ||||
| checkProjectCode(sheetProjectCode, projects, newProjectCodes) | checkProjectCode(sheetProjectCode, projects, newProjectCodes) | ||||