| @@ -362,7 +362,7 @@ 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){ | ||||
| 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 | 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) | ||||
| @@ -398,7 +398,7 @@ 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 = BigDecimal(ExcelUtils.getCell(sheet, i, 0).toString()).toInt().toString() | |||||
| invoiceNo = ExcelUtils.getCell(sheet, i, 0).toString() | |||||
| 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 | ||||
| @@ -447,7 +447,7 @@ 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){ | ||||
| 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 | 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) | ||||
| @@ -489,7 +489,7 @@ open class InvoiceService( | |||||
| } | } | ||||
| for (i in 2..sheet.lastRowNum){ | 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.paidAmount = ExcelUtils.getCell(sheet, i, 5).numericCellValue.toBigDecimal() | ||||
| invoice.receiptDate = ExcelUtils.getCell(sheet, i, 4).dateCellValue.toInstant().atZone(ZoneId.systemDefault()).toLocalDate() | invoice.receiptDate = ExcelUtils.getCell(sheet, i, 4).dateCellValue.toInstant().atZone(ZoneId.systemDefault()).toLocalDate() | ||||
| saveAndFlush(invoice) | saveAndFlush(invoice) | ||||
| @@ -435,7 +435,7 @@ open class ReportService( | |||||
| val uninvoiceCell = row.createCell(12) | val uninvoiceCell = row.createCell(12) | ||||
| uninvoiceCell.apply { | uninvoiceCell.apply { | ||||
| cellFormula = | 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}<L${rowNum}), 0, IF(AND(I${rowNum}>J${rowNum}, J${rowNum}>=L${rowNum}), J${rowNum}-L${rowNum}, 0))) " | // " IF(I${rowNum}<=J${rowNum}, I${rowNum}-L${rowNum}, IF(AND(I${rowNum}>J${rowNum}, J${rowNum}<L${rowNum}), 0, IF(AND(I${rowNum}>J${rowNum}, J${rowNum}>=L${rowNum}), J${rowNum}-L${rowNum}, 0))) " | ||||
| cellStyle.dataFormat = accountingStyle | cellStyle.dataFormat = accountingStyle | ||||
| } | } | ||||
| @@ -529,6 +529,11 @@ open class ReportService( | |||||
| CellUtil.setCellStyleProperty(sumUInvoiceCell, "borderBottom", BorderStyle.DOUBLE) | CellUtil.setCellStyleProperty(sumUInvoiceCell, "borderBottom", BorderStyle.DOUBLE) | ||||
| val lastCpiCell = row.createCell(13) | 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, "borderTop", BorderStyle.THIN) | ||||
| CellUtil.setCellStyleProperty(lastCpiCell, "borderBottom", BorderStyle.DOUBLE) | CellUtil.setCellStyleProperty(lastCpiCell, "borderBottom", BorderStyle.DOUBLE) | ||||
| @@ -607,7 +612,7 @@ open class ReportService( | |||||
| val row9: Row = sheet.getRow(rowNum) | val row9: Row = sheet.getRow(rowNum) | ||||
| val cell5 = row9.createCell(2) | val cell5 = row9.createCell(2) | ||||
| cell5.apply { | cell5.apply { | ||||
| cellFormula = "N${lastRowNum}" | |||||
| cellFormula = "M${lastRowNum}" | |||||
| cellStyle.dataFormat = accountingStyle | cellStyle.dataFormat = accountingStyle | ||||
| } | } | ||||
| @@ -1801,26 +1806,22 @@ open class ReportService( | |||||
| open fun getProjectResourceOverconsumptionReport(args: Map<String, Any>): List<Map<String, Any>> { | open fun getProjectResourceOverconsumptionReport(args: Map<String, Any>): List<Map<String, Any>> { | ||||
| val sql = StringBuilder("WITH teamNormalConsumed AS (" | 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 " | + " SELECT " | ||||
| + " p.code, " | + " p.code, " | ||||