From b0874a4669ae966d8ad4ec39b2ad7b30605335fb Mon Sep 17 00:00:00 2001 From: "cyril.tsui" Date: Thu, 27 Jun 2024 18:38:54 +0800 Subject: [PATCH] update --- .../modules/project/service/InvoiceService.kt | 8 ++-- .../modules/report/service/ReportService.kt | 45 ++++++++++--------- 2 files changed, 27 insertions(+), 26 deletions(-) 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 21d3759..950ab7e 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 = BigDecimal(ExcelUtils.getCell(sheet, i, 0).toString()).toInt().toString() + val sheetInvoice = ExcelUtils.getCell(sheet, i, 0).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 = BigDecimal(ExcelUtils.getCell(sheet, i, 0).toString()).toInt().toString() + invoiceNo = ExcelUtils.getCell(sheet, i, 0).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 = BigDecimal(ExcelUtils.getCell(sheet, i, 0).toString()).toInt().toString() + val sheetInvoice = ExcelUtils.getCell(sheet, i, 0).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(BigDecimal(ExcelUtils.getCell(sheet, i, 0).toString()).toInt().toString()) + val invoice = getInvoiceByInvoiceNo(ExcelUtils.getCell(sheet, i, 0).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 406c52e..d5c38a1 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 @@ -435,7 +435,7 @@ open class ReportService( val uninvoiceCell = row.createCell(12) uninvoiceCell.apply { cellFormula = - " IF(I${rowNum}-L${rowNum}<0, 0, I${rowNum}-L${rowNum})" + " IF(H${rowNum}-L${rowNum}<0, 0, H${rowNum}-L${rowNum})" // " IF(I${rowNum}<=J${rowNum}, I${rowNum}-L${rowNum}, IF(AND(I${rowNum}>J${rowNum}, J${rowNum}J${rowNum}, J${rowNum}>=L${rowNum}), J${rowNum}-L${rowNum}, 0))) " cellStyle.dataFormat = accountingStyle } @@ -529,6 +529,11 @@ open class ReportService( CellUtil.setCellStyleProperty(sumUInvoiceCell, "borderBottom", BorderStyle.DOUBLE) val lastCpiCell = row.createCell(13) + lastCpiCell.apply { + cellFormula = "SUM(N15:N${rowNum})" + cellStyle = boldFontCellStyle + cellStyle.dataFormat = accountingStyle + } CellUtil.setCellStyleProperty(lastCpiCell, "borderTop", BorderStyle.THIN) CellUtil.setCellStyleProperty(lastCpiCell, "borderBottom", BorderStyle.DOUBLE) @@ -607,7 +612,7 @@ open class ReportService( val row9: Row = sheet.getRow(rowNum) val cell5 = row9.createCell(2) cell5.apply { - cellFormula = "N${lastRowNum}" + cellFormula = "M${lastRowNum}" cellStyle.dataFormat = accountingStyle } @@ -1801,26 +1806,22 @@ open class ReportService( open fun getProjectResourceOverconsumptionReport(args: Map): List> { val sql = StringBuilder("WITH teamNormalConsumed AS (" - + " SELECT " - + " s.teamId, " - + " pt.project_id, " - + " SUM(tns.totalConsumed) AS totalConsumed, " - + " sum(tns.totalBudget) as totalBudget " - + " FROM ( " - + " SELECT " - + " t.staffId, " - + " sum(t.normalConsumed + COALESCE(t.otConsumed, 0)) as totalConsumed, " - + " t.projectTaskId AS taskId, " - + " sum(t.normalConsumed + COALESCE(t.otConsumed, 0)) * min(sal.hourlyRate) as totalBudget " - + " FROM timesheet t " - + " LEFT JOIN staff s ON t.staffId = s.id " - + " left join salary sal on sal.salaryPoint = s.salaryId " - + " GROUP BY t.staffId, t.projectTaskId " - + " ) AS tns " - + " INNER JOIN project_task pt ON tns.taskId = pt.id " - + " JOIN staff s ON tns.staffId = s.id " - + " JOIN team t ON s.teamId = t.id " - + " GROUP BY teamId, project_id " + + " SELECT" + + " tns.projectId," + + " SUM(tns.totalConsumed) AS totalConsumed, " + + " sum(tns.totalBudget) as totalBudget " + + " FROM ( " + + " SELECT" + + " t.staffId," + + " t.projectId AS projectId," + + " sum(t.normalConsumed + COALESCE(t.otConsumed, 0)) as totalConsumed, " + + " sum(t.normalConsumed + COALESCE(t.otConsumed, 0)) * min(sal.hourlyRate) as totalBudget " + + " FROM timesheet t" + + " LEFT JOIN staff s ON t.staffId = s.id " + + " left join salary sal on sal.salaryPoint = s.salaryId " + + " GROUP BY t.staffId, t.projectId" + + " ) AS tns" + + " GROUP BY projectId" + " ) " + " SELECT " + " p.code, "