| @@ -17,6 +17,7 @@ import com.ffii.tsms.modules.project.web.models.EditInvoiceResponse | |||||
| import com.ffii.tsms.modules.project.web.models.InvoiceResponse | import com.ffii.tsms.modules.project.web.models.InvoiceResponse | ||||
| import net.sf.jasperreports.engine.JasperCompileManager | import net.sf.jasperreports.engine.JasperCompileManager | ||||
| import net.sf.jasperreports.engine.JasperReport | import net.sf.jasperreports.engine.JasperReport | ||||
| import org.apache.poi.ss.usermodel.Cell | |||||
| import org.apache.poi.ss.usermodel.CellType | import org.apache.poi.ss.usermodel.CellType | ||||
| import org.apache.poi.ss.usermodel.Sheet | import org.apache.poi.ss.usermodel.Sheet | ||||
| import org.apache.poi.ss.usermodel.Workbook | import org.apache.poi.ss.usermodel.Workbook | ||||
| @@ -250,6 +251,9 @@ open class InvoiceService( | |||||
| val duplicateValues = HashSet<String>() | val duplicateValues = HashSet<String>() | ||||
| for (i in startingRow..sheet.lastRowNum) { | for (i in startingRow..sheet.lastRowNum) { | ||||
| if(ExcelUtils.getCell(sheet, i, 0).cellType == CellType.BLANK){ | |||||
| break | |||||
| } | |||||
| val row = sheet.getRow(i) | val row = sheet.getRow(i) | ||||
| val cell = row?.getCell(columnIndex) | val cell = row?.getCell(columnIndex) | ||||
| if (cell != null && cell.cellType == CellType.STRING) { | if (cell != null && cell.cellType == CellType.STRING) { | ||||
| @@ -405,6 +409,12 @@ open class InvoiceService( | |||||
| // Check the import invoice with the data in DB | // Check the import invoice with the data in DB | ||||
| for (i in 2..sheet.lastRowNum){ | for (i in 2..sheet.lastRowNum){ | ||||
| if(ExcelUtils.getCell(sheet, i, 0).cellType == CellType.BLANK){ | |||||
| break | |||||
| } | |||||
| // 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 sheetInvoice = ExcelUtils.getCell(sheet, i, 0).toString() | ||||
| 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) | ||||
| @@ -437,6 +447,9 @@ open class InvoiceService( | |||||
| } | } | ||||
| for (i in 2..sheet.lastRowNum){ | for (i in 2..sheet.lastRowNum){ | ||||
| if(ExcelUtils.getCell(sheet, i, 0).cellType == CellType.BLANK){ | |||||
| break | |||||
| } | |||||
| // Beria cannot provide Payment Milestone when importing the invoice, so it cannot be checked and import to DB | // Beria cannot provide Payment Milestone when importing the invoice, so it cannot be checked and import to DB | ||||
| // 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() | ||||
| @@ -496,6 +509,9 @@ open class InvoiceService( | |||||
| val duplicateItemsInInvoice = checkDuplicateItemInImportedInvoice(sheet,2,0) | val duplicateItemsInInvoice = checkDuplicateItemInImportedInvoice(sheet,2,0) | ||||
| for (i in 2..sheet.lastRowNum){ | for (i in 2..sheet.lastRowNum){ | ||||
| if(ExcelUtils.getCell(sheet, i, 0).cellType == CellType.BLANK){ | |||||
| break | |||||
| } | |||||
| val sheetInvoice = ExcelUtils.getCell(sheet, i, 0).toString() | val sheetInvoice = ExcelUtils.getCell(sheet, i, 0).toString() | ||||
| 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) | ||||
| @@ -538,6 +554,9 @@ open class InvoiceService( | |||||
| } | } | ||||
| for (i in 2..sheet.lastRowNum){ | for (i in 2..sheet.lastRowNum){ | ||||
| if(ExcelUtils.getCell(sheet, i, 0).cellType == CellType.BLANK){ | |||||
| break | |||||
| } | |||||
| val invoice = getInvoiceByInvoiceNo(ExcelUtils.getCell(sheet, i, 0).toString()) | val invoice = getInvoiceByInvoiceNo(ExcelUtils.getCell(sheet, i, 0).toString()) | ||||
| invoice.paidAmount = ExcelUtils.getCell(sheet, i, 3).numericCellValue.toBigDecimal() | invoice.paidAmount = ExcelUtils.getCell(sheet, i, 3).numericCellValue.toBigDecimal() | ||||
| invoice.receiptDate = ExcelUtils.getCell(sheet, i, 2).dateCellValue.toInstant().atZone(ZoneId.systemDefault()).toLocalDate() | invoice.receiptDate = ExcelUtils.getCell(sheet, i, 2).dateCellValue.toInstant().atZone(ZoneId.systemDefault()).toLocalDate() | ||||