diff --git a/src/main/java/com/ffii/tsms/modules/project/service/InvoiceService.kt b/src/main/java/com/ffii/tsms/modules/project/service/InvoiceService.kt index 950ab7e..21d3759 100644 --- a/src/main/java/com/ffii/tsms/modules/project/service/InvoiceService.kt +++ b/src/main/java/com/ffii/tsms/modules/project/service/InvoiceService.kt @@ -362,7 +362,7 @@ open class InvoiceService( // Check the import invoice with the data in DB for (i in 2..sheet.lastRowNum){ - val sheetInvoice = ExcelUtils.getCell(sheet, i, 0).toString() + val sheetInvoice = BigDecimal(ExcelUtils.getCell(sheet, i, 0).toString()).toInt().toString() val sheetProjectCode = ExcelUtils.getCell(sheet, i, 1).stringCellValue checkInvoiceNo(sheetInvoice, invoices, invoicesResult, true) checkProjectCode(sheetProjectCode, projects, newProjectCodes) @@ -398,7 +398,7 @@ 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 = BigDecimal(ExcelUtils.getCell(sheet, i, 0).toString()).toInt().toString() projectCode = ExcelUtils.getCell(sheet, i, 1).stringCellValue projectName = ExcelUtils.getCell(sheet, i, 2).stringCellValue team = ExcelUtils.getCell(sheet, i, 3).stringCellValue @@ -447,7 +447,7 @@ open class InvoiceService( val duplicateItemsInInvoice = checkDuplicateItemInImportedInvoice(sheet,2,0) for (i in 2..sheet.lastRowNum){ - val sheetInvoice = ExcelUtils.getCell(sheet, i, 0).toString() + val sheetInvoice = BigDecimal(ExcelUtils.getCell(sheet, i, 0).toString()).toInt().toString() val sheetProjectCode = ExcelUtils.getCell(sheet, i, 1).stringCellValue checkInvoiceNo(sheetInvoice, invoices, invoicesResult, false) checkProjectCode(sheetProjectCode, projects, newProjectCodes) @@ -489,7 +489,7 @@ open class InvoiceService( } for (i in 2..sheet.lastRowNum){ - val invoice = getInvoiceByInvoiceNo(ExcelUtils.getCell(sheet, i, 0).toString()) + val invoice = getInvoiceByInvoiceNo(BigDecimal(ExcelUtils.getCell(sheet, i, 0).toString()).toInt().toString()) invoice.paidAmount = ExcelUtils.getCell(sheet, i, 5).numericCellValue.toBigDecimal() invoice.receiptDate = ExcelUtils.getCell(sheet, i, 4).dateCellValue.toInstant().atZone(ZoneId.systemDefault()).toLocalDate() saveAndFlush(invoice) diff --git a/src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt b/src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt index f7796cb..82cf016 100644 --- a/src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt +++ b/src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt @@ -65,7 +65,7 @@ open class ReportService( var rowIndex = startRow var columnIndex = startColumn result.forEachIndexed { index, obj -> - var tempCell = sheet.getRow(rowIndex).createCell(columnIndex) + var tempCell = (sheet.getRow(rowIndex) ?: sheet.createRow(rowIndex)).createCell(columnIndex) tempCell.setCellValue((index + 1).toDouble()) val keys = obj.keys.toList() keys.forEachIndexed { keyIndex, key -> @@ -1846,22 +1846,22 @@ open class ReportService( if (args != null) { var statusFilter: String = "" if (args.containsKey("teamId")) - sql.append("and t.id = :teamId") + sql.append(" and t.id = :teamId") if (args.containsKey("custId")) - sql.append("and c.id = :custId") + sql.append(" and c.id = :custId") if (args.containsKey("subsidiaryId")) - sql.append("and ss.id = :subsidiaryId") + sql.append(" and ss.id = :subsidiaryId") if (args.containsKey("status")) statusFilter = when (args.get("status")) { - "Potential Overconsumption" -> "and " + + "Potential Overconsumption" -> " and " + " (COALESCE((tns.totalConsumed * sa.hourlyRate), 0) / p.expectedTotalFee) >= :lowerLimit " + " and (COALESCE((tns.totalConsumed * sa.hourlyRate), 0) / p.expectedTotalFee) <= 1 " + " or (COALESCE(tns.totalConsumed, 0) / COALESCE(p.totalManhour, 0)) >= :lowerLimit " + " and (COALESCE(tns.totalConsumed, 0) / COALESCE(p.totalManhour, 0)) <= 1 " - "All" -> "and " + + "All" -> " and " + " (COALESCE((tns.totalConsumed * sa.hourlyRate), 0) / p.expectedTotalFee) >= :lowerLimit " + " or (COALESCE(tns.totalConsumed, 0) / COALESCE(p.totalManhour, 0)) >= :lowerLimit " -// "Overconsumption" -> "and " + +// "Overconsumption" -> " and " + // " ((COALESCE((tns.totalConsumed * sa.hourlyRate), 0) / p.expectedTotalFee) >= 1 " + // " or (COALESCE(tns.totalConsumed, 0) / COALESCE(p.totalManhour, 0)) >= 1) " @@ -2403,7 +2403,7 @@ open class ReportService( for(item in queryList){ val hourlyRate = (item.getValue("hourlyRate") as BigDecimal).toDouble() - if(item["code"] !in costAndExpenseList){ + if(item["code"] !in costAndExpenseList.map { it["code"] }){ costAndExpenseList.add( mapOf( "code" to item["code"], @@ -2414,13 +2414,13 @@ open class ReportService( "budget" to item["expectedTotalFee"], "totalManhours" to item["normalConsumed"] as Double + item["otConsumed"] as Double, "manhourExpenditure" to (hourlyRate * item["normalConsumed"] as Double ) - + (hourlyRate * item["otConsumed"]as Double * otFactor) + + (hourlyRate * item["otConsumed"] as Double * otFactor) ) ) }else{ val existingMap = costAndExpenseList.find { it.containsValue(item["code"]) }!! costAndExpenseList[costAndExpenseList.indexOf(existingMap)] = existingMap.toMutableMap().apply { - put("totalManhours", get("manhours") as Double + (item["normalConsumed"] as Double + item["otConsumed"] as Double)) + put("totalManhours", get("totalManhours") as Double + (item["normalConsumed"] as Double + item["otConsumed"] as Double)) put("manhourExpenditure", get("manhourExpenditure") as Double + ((hourlyRate * item["normalConsumed"] as Double ) + (hourlyRate * item["otConsumed"]as Double * otFactor))) } diff --git a/src/main/java/com/ffii/tsms/modules/timesheet/service/TimesheetsService.kt b/src/main/java/com/ffii/tsms/modules/timesheet/service/TimesheetsService.kt index 0b4bf12..1b4e2c2 100644 --- a/src/main/java/com/ffii/tsms/modules/timesheet/service/TimesheetsService.kt +++ b/src/main/java/com/ffii/tsms/modules/timesheet/service/TimesheetsService.kt @@ -256,7 +256,7 @@ open class TimesheetsService( timesheetRepository.saveAll(timesheetList) logger.info("---------end-------") - logger.info("Not Exist Project List: "+ notExistProjectList.joinToString(", ")) + logger.info("Not Exist Project List: "+ notExistProjectList.distinct().joinToString(", ")) return if (sheet.lastRowNum > 0) "Import Excel success btw " + notExistProjectList.joinToString(", ") else "Import Excel failure" } diff --git a/src/main/resources/templates/report/AR03_Resource Overconsumption.xlsx b/src/main/resources/templates/report/AR03_Resource Overconsumption.xlsx index fb94181..2050300 100644 Binary files a/src/main/resources/templates/report/AR03_Resource Overconsumption.xlsx and b/src/main/resources/templates/report/AR03_Resource Overconsumption.xlsx differ diff --git a/src/main/resources/templates/report/AR05_Project Completion Report.xlsx b/src/main/resources/templates/report/AR05_Project Completion Report.xlsx index 2c07680..2b41594 100644 Binary files a/src/main/resources/templates/report/AR05_Project Completion Report.xlsx and b/src/main/resources/templates/report/AR05_Project Completion Report.xlsx differ diff --git a/src/main/resources/templates/report/AR06_Project Completion Report with Outstanding Accounts Receivable v02.xlsx b/src/main/resources/templates/report/AR06_Project Completion Report with Outstanding Accounts Receivable v02.xlsx index ee9bcda..28af616 100644 Binary files a/src/main/resources/templates/report/AR06_Project Completion Report with Outstanding Accounts Receivable v02.xlsx and b/src/main/resources/templates/report/AR06_Project Completion Report with Outstanding Accounts Receivable v02.xlsx differ