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 1e0f2a5..33fd49a 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 @@ -4,10 +4,7 @@ import com.ffii.core.support.JdbcDao import com.ffii.tsms.modules.data.entity.* import com.ffii.tsms.modules.data.service.SalaryEffectiveService import com.ffii.tsms.modules.data.service.SalaryEffectiveService.MonthlyStaffSalaryData -import com.ffii.tsms.modules.project.entity.Invoice -import com.ffii.tsms.modules.project.entity.Milestone -import com.ffii.tsms.modules.project.entity.Project -import com.ffii.tsms.modules.project.entity.ProjectRepository +import com.ffii.tsms.modules.project.entity.* import com.ffii.tsms.modules.report.web.model.costAndExpenseRequest import com.ffii.tsms.modules.timesheet.entity.Timesheet import com.ffii.tsms.modules.timesheet.entity.TimesheetRepository @@ -158,6 +155,7 @@ open class ReportService( project: Project, invoices: List, timesheets: List, + projectExpenses: List, monthlyStaffSalaryEffective: List, dateType: String ): ByteArray { @@ -167,6 +165,7 @@ open class ReportService( project, invoices, timesheets, + projectExpenses, monthlyStaffSalaryEffective, dateType, PROJECT_CASH_FLOW_REPORT @@ -374,6 +373,7 @@ open class ReportService( sheet.setColumnWidth(3, 20 * 256) sheet.setColumnWidth(4, 45 * 256) sheet.setColumnWidth(5, 15 * 256) + sheet.setColumnWidth(7, 30 * 256) val boldFont = sheet.workbook.createFont() boldFont.bold = true @@ -467,22 +467,35 @@ open class ReportService( } val cumExpenditureCell = row.createCell(9) + cumExpenditureCell.apply { + cellFormula = "K${rowNum} + L${rowNum}" + cellStyle.dataFormat = accountingStyle + } + + val cumManHourSpentCell = row.createCell(10) // val normalConsumed = item["normalConsumed"]?.let { it as BigDecimal } ?: BigDecimal(0) // val otConsumed = item["otConsumed"]?.let { it as BigDecimal } ?: BigDecimal(0) // val cumExpenditure = normalConsumed.add(otConsumed) - val totalCumulativeExpenditure = item["totalCumulativeExpenditure"]?.let { it as BigDecimal } ?: BigDecimal(0) - cumExpenditureCell.apply { - setCellValue(totalCumulativeExpenditure.toDouble()) + val totalCumulativeManhoursExpenditure = item["totalCumulativeExpenditure"]?.let { it as BigDecimal } ?: BigDecimal(0) + cumManHourSpentCell.apply { + setCellValue(totalCumulativeManhoursExpenditure.toDouble()) + cellStyle.dataFormat = accountingStyle + } + + val projectExpenseCell = row.createCell(11) + val projectExpense = item["projectExpense"]?.let { it as BigDecimal } ?: BigDecimal(0) + projectExpenseCell.apply { + setCellValue(projectExpense.toDouble()) cellStyle.dataFormat = accountingStyle } - val budgetVCell = row.createCell(10) + val budgetVCell = row.createCell(12) budgetVCell.apply { cellFormula = "I${rowNum} - J${rowNum}" cellStyle.dataFormat = accountingStyle } - val issuedCell = row.createCell(11) + val issuedCell = row.createCell(13) val issuedAmount = item["sumIssuedAmount"]?.let { it as BigDecimal } ?: BigDecimal(0) issuedCell.apply { setCellValue(issuedAmount.toDouble()) @@ -490,36 +503,36 @@ open class ReportService( cellStyle.dataFormat = accountingStyle } - val uninvoiceCell = row.createCell(12) + val uninvoiceCell = row.createCell(14) uninvoiceCell.apply { cellFormula = - " IF(H${rowNum}-L${rowNum}<0, 0, H${rowNum}-L${rowNum})" + " IF(H${rowNum}-M${rowNum}<0, 0, H${rowNum}-M${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 } - val cpiCell = row.createCell(13) + val cpiCell = row.createCell(15) cpiCell.apply { - cellFormula = "IF(J${rowNum} = 0, 0, L${rowNum}/J${rowNum})" + cellFormula = "IF(J${rowNum} = 0, 0, M${rowNum}/(J${rowNum}+K${rowNum}))" cellStyle = boldFontCellStyle } - val projectedCpiCell = row.createCell(14) + val projectedCpiCell = row.createCell(16) projectedCpiCell.apply { - cellFormula = "IF(J${rowNum} = 0, 0, H${rowNum}/J${rowNum})" + cellFormula = "IF(J${rowNum} = 0, 0, H${rowNum}/(J${rowNum}+K${rowNum}))" cellStyle = boldFontCellStyle } - val receivedAmountCell = row.createCell(15) + val receivedAmountCell = row.createCell(17) val paidAmount = item["sumPaidAmount"]?.let { it as BigDecimal } ?: BigDecimal(0) receivedAmountCell.apply { setCellValue(paidAmount.toDouble()) cellStyle.dataFormat = accountingStyle } - val unsettledAmountCell = row.createCell(16) + val unsettledAmountCell = row.createCell(18) unsettledAmountCell.apply { - cellFormula = "L${rowNum}-P${rowNum}" + cellFormula = "M${rowNum}-Q${rowNum}" cellStyle = boldFontCellStyle cellStyle.dataFormat = accountingStyle } @@ -566,42 +579,58 @@ open class ReportService( CellUtil.setCellStyleProperty(sumCumExpenditureCell, "borderTop", BorderStyle.THIN) CellUtil.setCellStyleProperty(sumCumExpenditureCell, "borderBottom", BorderStyle.DOUBLE) - val sumBudgetVCell = row.createCell(10) - sumBudgetVCell.apply { + val sumTotalManHourSpent = row.createCell(10) + sumTotalManHourSpent.apply { cellFormula = "SUM(K15:K${rowNum})" + cellStyle.dataFormat = accountingStyle + } + CellUtil.setCellStyleProperty(sumTotalManHourSpent, "borderTop", BorderStyle.THIN) + CellUtil.setCellStyleProperty(sumTotalManHourSpent, "borderBottom", BorderStyle.DOUBLE) + + val sumProjectExpenseCell = row.createCell(11) + sumProjectExpenseCell.apply { + cellFormula = "SUM(L15:L${rowNum})" + cellStyle.dataFormat = accountingStyle + } + CellUtil.setCellStyleProperty(sumProjectExpenseCell, "borderTop", BorderStyle.THIN) + CellUtil.setCellStyleProperty(sumProjectExpenseCell, "borderBottom", BorderStyle.DOUBLE) + + val sumBudgetVCell = row.createCell(12) + sumBudgetVCell.apply { + cellFormula = "SUM(M15:M${rowNum})" cellStyle = boldFontCellStyle cellStyle.dataFormat = accountingStyle } CellUtil.setCellStyleProperty(sumBudgetVCell, "borderTop", BorderStyle.THIN) CellUtil.setCellStyleProperty(sumBudgetVCell, "borderBottom", BorderStyle.DOUBLE) - val sumIInvoiceCell = row.createCell(11) + val sumIInvoiceCell = row.createCell(13) sumIInvoiceCell.apply { - cellFormula = "SUM(L15:L${rowNum})" + cellFormula = "SUM(N15:N${rowNum})" cellStyle.dataFormat = accountingStyle } CellUtil.setCellStyleProperty(sumIInvoiceCell, "borderTop", BorderStyle.THIN) CellUtil.setCellStyleProperty(sumIInvoiceCell, "borderBottom", BorderStyle.DOUBLE) - val sumUInvoiceCell = row.createCell(12) + val sumUInvoiceCell = row.createCell(14) sumUInvoiceCell.apply { - cellFormula = "SUM(M15:M${rowNum})" + cellFormula = "SUM(O15:O${rowNum})" cellStyle = boldFontCellStyle cellStyle.dataFormat = accountingStyle } CellUtil.setCellStyleProperty(sumUInvoiceCell, "borderTop", BorderStyle.THIN) CellUtil.setCellStyleProperty(sumUInvoiceCell, "borderBottom", BorderStyle.DOUBLE) - val lastCpiCell = row.createCell(13) + val lastCpiCell = row.createCell(15) lastCpiCell.apply { - cellFormula = "IF(J${rowNum+1}=0,0,L${rowNum+1}/J${rowNum+1})" + cellFormula = "IF(J${rowNum+1}=0,0,N${rowNum+1}/J${rowNum+1})" cellStyle = boldFontCellStyle cellStyle.dataFormat = accountingStyle } CellUtil.setCellStyleProperty(lastCpiCell, "borderTop", BorderStyle.THIN) CellUtil.setCellStyleProperty(lastCpiCell, "borderBottom", BorderStyle.DOUBLE) - val lastPCpiCell = row.createCell(14) + val lastPCpiCell = row.createCell(16) lastPCpiCell.apply { cellFormula = "IF(J${rowNum+1}=0,0,H${rowNum+1}/J${rowNum+1})" cellStyle = boldFontCellStyle @@ -611,17 +640,17 @@ open class ReportService( CellUtil.setCellStyleProperty(lastPCpiCell, "borderBottom", BorderStyle.DOUBLE) - val sumRAmountCell = row.createCell(15) + val sumRAmountCell = row.createCell(17) sumRAmountCell.apply { - cellFormula = "SUM(P15:P${rowNum})" + cellFormula = "SUM(R15:R${rowNum})" cellStyle.dataFormat = accountingStyle } CellUtil.setCellStyleProperty(sumRAmountCell, "borderTop", BorderStyle.THIN) CellUtil.setCellStyleProperty(sumRAmountCell, "borderBottom", BorderStyle.DOUBLE) - val sumUnSettleCell = row.createCell(16) + val sumUnSettleCell = row.createCell(18) sumUnSettleCell.apply { - cellFormula = "SUM(Q15:Q${rowNum})" + cellFormula = "SUM(S15:S${rowNum})" cellStyle = boldFontCellStyle cellStyle.dataFormat = accountingStyle } @@ -670,7 +699,7 @@ open class ReportService( val row7: Row = sheet.getRow(rowNum) val cell3 = row7.createCell(2) cell3.apply { - cellFormula = "K${lastRowNum}" + cellFormula = "L${lastRowNum}" cellStyle.dataFormat = accountingStyle } @@ -678,7 +707,7 @@ open class ReportService( val row8: Row = sheet.getRow(rowNum) val cell4 = row8.createCell(2) cell4.apply { - cellFormula = "L${lastRowNum}" + cellFormula = "M${lastRowNum}" cellStyle.dataFormat = accountingStyle } @@ -686,7 +715,7 @@ open class ReportService( val row9: Row = sheet.getRow(rowNum) val cell5 = row9.createCell(2) cell5.apply { - cellFormula = "M${lastRowNum}" + cellFormula = "N${lastRowNum}" cellStyle.dataFormat = accountingStyle } @@ -694,7 +723,7 @@ open class ReportService( val row10: Row = sheet.getRow(rowNum) val cell6 = row10.createCell(2) cell6.apply { - cellFormula = "P${lastRowNum}" + cellFormula = "Q${lastRowNum}" cellStyle.dataFormat = accountingStyle } @@ -702,7 +731,7 @@ open class ReportService( val row11: Row = sheet.getRow(rowNum) val cell7 = row11.createCell(2) cell7.apply { - cellFormula = "Q${lastRowNum}" + cellFormula = "R${lastRowNum}" cellStyle.dataFormat = accountingStyle } @@ -716,6 +745,7 @@ open class ReportService( project: Project, invoices: List, timesheets: List, + projectExpenses: List, monthlyStaffSalaryEffective: List, dateType: String, templatePath: String, @@ -859,6 +889,18 @@ open class ReportService( } } + val groupedProjectExpense = projectExpenses.sortedBy { it.issueDate } + .groupBy { projectExpenseEntries -> projectExpenseEntries.issueDate?.format(dateFormatter).toString() } + .mapValues { (_, projectExpenses) -> + projectExpenses.map {projectExpense-> + mapOf( + "projectExpense" to (projectExpense.amount ?: 0.0), + "expenseNo" to projectExpense.expenseNo + ) + } + } + println("grouped Project Expense") + println(groupedProjectExpense) // groupedTimesheets.entries.forEach { (key, value) -> // logger.info("key: $key") // logger.info("value: " + value.sumOf { it }) @@ -1943,10 +1985,16 @@ open class ReportService( + " left join project p on p.code = i.projectCode" + " where i.deleted = false " + " group by p.code" - + " )" + + " )," + + " cte_expense as ( " + + " select IFNULL(sum(pe.amount),0) as amount, pe.projectId " + + " from project_expense pe " + + " where pe.deleted = false " + + " group by projectId " + + " ) " + " select p.code, p.description, c.name as client, IFNULL(s2.name, \"N/A\") as subsidiary, concat(t.code, \' - \', t.name) as teamLead, p.planStart , p.planEnd , p.expectedTotalFee, ifnull(p.subContractFee, 0) as subContractFee, " + " IFNULL(cte_i.sumIssuedAmount, 0) as sumIssuedAmount, IFNULL(cte_i.sumPaidAmount, 0) as sumPaidAmount" - + " ,0 as totalCumulativeExpenditure " + + " ,0 as totalCumulativeExpenditure, IFNULL(cte_e.amount,0) as projectExpense " + " from project p" // + " left join cte_timesheet cte_ts on p.code = cte_ts.code" + " left join customer c on c.id = p.customerId" @@ -1954,6 +2002,7 @@ open class ReportService( + " left join subsidiary s2 on s2.id = cs.subsidiaryId " + " left join tsmsdb.team t on t.teamLead = p.teamLead" + " left join cte_invoice cte_i on cte_i.code = p.code" + + " left join cte_expense cte_e on cte_e.projectId = p.id " + " where p.status = \'On-going\'" ) if (teamLeadId!! > 0) { @@ -2269,13 +2318,19 @@ open class ReportService( + " left join project p on p.code = i.projectCode" + " where i.deleted = false " + " group by p.code" - + " )" + + " )," + + " cte_expense as ( " + + " select sum(pe.amount) as amount, pe.projectId " + + " from project_expense pe " + + " where pe.projectId = :projectId " + + " and (DATE_FORMAT(pe.issueDate, '%Y-%m') >= :startMonth and DATE_FORMAT(pe.issueDate, '%Y-%m') <= :endMonth) " + + " ) " + " select p.code, p.description, c.name as client, IFNULL(s2.name, \"N/A\") as subsidiary, concat(t.code, \" - \", t.name) as teamLead," + " IFNULL(cte_ts.normalConsumed, 0) as normalConsumed, IFNULL(cte_ts.otConsumed, 0) as otConsumed, DATE_FORMAT(cte_ts.recordDate, '%Y-%m') as recordDate, " + " IFNULL(cte_ts.salaryPoint, 0) as salaryPoint, " + " (p.expectedTotalFee - IFNULL(cte_i.sumIssuedAmount, 0)) as expectedTotalFee, " + " IFNULL(cte_ts.hourlyRate, 0) as hourlyRate, IFNULL(cte_i.sumIssuedAmount, 0) as sumIssuedAmount, IFNULL(cte_i.sumPaidAmount, 0) as sumPaidAmount, IFNULL(cte_tss.sumManhourExpenditure, 0) as sumManhourExpenditure," - + " s.name, s.staffId, g.code as gradeCode, g.name as gradeName, t2.code as teamCode, t2.name as teamName" + + " s.name, s.staffId, g.code as gradeCode, g.name as gradeName, t2.code as teamCode, t2.name as teamName, cte_e.amount " + " from project p" + " left join cte_timesheet cte_ts on p.code = cte_ts.code" + " left join cte_timesheet_sum cte_tss on p.code = cte_tss.code" @@ -2287,6 +2342,7 @@ open class ReportService( + " left join team t2 on t2.id = s.teamId" + " left join customer_subsidiary cs on cs.id = p.customerSubsidiaryId " + " left join subsidiary s2 on s2.id = cs.subsidiaryId " + + " left join cte_expense cte_e on cte_e.projectId = p.id " + " where p.deleted = false" + " and (DATE_FORMAT(cte_ts.recordDate, \'%Y-%m\') >= :startMonth and DATE_FORMAT(cte_ts.recordDate, \'%Y-%m\') <= :endMonth)" + " and p.id = :projectId" @@ -2322,8 +2378,18 @@ open class ReportService( "select p.code, p.description from project p where p.deleted = false and p.id = :projectId" ) + val projectExpenseSql = StringBuilder( + "select IFNULL(sum(pe.amount),0) as amount" + + " from project_expense pe" + + " where pe.projectId = :projectId" + + " and (DATE_FORMAT(pe.issueDate, '%Y-%m') >= :startMonth and DATE_FORMAT(pe.issueDate, '%Y-%m') <= :endMonth) " + + " and pe.deleted = false " + ) + val projectsCode = jdbcDao.queryForMap(projectCodeSql.toString(), args).get() + val projectExpense = jdbcDao.queryForMap(projectExpenseSql.toString(), args).get() + val otFactor = BigDecimal(1).toDouble() var tempList = mutableListOf>() @@ -2333,7 +2399,8 @@ open class ReportService( "startMonth" to startMonth, "endMonth" to endMonth, "code" to projectsCode["code"], - "description" to projectsCode["description"] + "description" to projectsCode["description"], + "projectExpense" to projectExpense["amount"] ) val financialYears = getHalfYearFinancialPeriods(queryStartMonth, queryEndMonth, 1) @@ -2984,8 +3051,21 @@ open class ReportService( // setCellValue(info.getValue("manhourExpenditure") as Double) cellStyle.dataFormat = accountingStyle } - CellUtil.setCellStyleProperty(totalManhourETitleCell, "borderBottom", BorderStyle.THIN) - CellUtil.setCellStyleProperty(totalManhourECell, "borderBottom", BorderStyle.THIN) + + rowNum += 1 + val projectExpenseRow: Row = sheet.getRow(rowNum) ?: sheet.createRow(rowNum) + val projectExpenseTitleCell = projectExpenseRow.getCell(0) ?: projectExpenseRow.createCell(0) + projectExpenseTitleCell.apply { + setCellValue("Less: Project Expense (HKD)") + } + val projectExpenseCell = projectExpenseRow.getCell(1) ?: projectExpenseRow.createCell(1) + projectExpenseCell.apply { + setCellValue(info.getValue("projectExpense").toString().toDouble()) + cellStyle.dataFormat = accountingStyle + } + + CellUtil.setCellStyleProperty(projectExpenseTitleCell, "borderBottom", BorderStyle.THIN) + CellUtil.setCellStyleProperty(projectExpenseCell, "borderBottom", BorderStyle.THIN) rowNum += 1 val pandlRow: Row = sheet.getRow(rowNum) ?: sheet.createRow(rowNum) @@ -2995,7 +3075,7 @@ open class ReportService( } val panlCell = pandlRow.getCell(1) ?: pandlRow.createCell(1) panlCell.apply { - cellFormula = "B${rowNum - 1}-B${rowNum}" + cellFormula = "B${rowNum - 2}-B${rowNum - 1}-B${rowNum}" cellStyle.dataFormat = accountingStyle } // CellUtil.setCellStyleProperty(panlCellTitle, "borderBottom", BorderStyle.DOUBLE) @@ -3036,15 +3116,22 @@ open class ReportService( fun getCostAndExpense(clientId: Long?, teamId: Long?, type: String): List> { val sql = StringBuilder( - " select p.code, p.description, c.name as client, IFNULL(s2.name, \"N/A\") as subsidiary, " + + " with cte_expense as ( " + + " select IFNULL(sum(pe.amount),0) as amount, pe.projectId " + + " from project_expense pe " + + " where pe.deleted = false " + + " group by projectId " + + " ) " + + " select p.code, p.description, c.name as client, IFNULL(s2.name, \"N/A\") as subsidiary, " + " concat(t.code, ' - ', t.name) as teamLead, ifnull(p.expectedTotalFee, 0) as expectedTotalFee, " + " ifnull(p.subContractFee, 0) as subContractFee, " + - " 0 as totalCumulativeExpenditure " + + " 0 as totalCumulativeExpenditure, IFNULL(sum(cte_e.amount),0) as projectExpense " + " from project p " + " left join customer c on c.id = p.customerId " + " left join customer_subsidiary cs on cs.id = p.customerSubsidiaryId " + " left join subsidiary s2 on s2.id = cs.subsidiaryId " + " left join tsmsdb.team t on t.teamLead = p.teamLead " + + " left join cte_expense cte_e on cte_e.projectId = p.id " + " where ISNULL(p.code) = False " ) @@ -3066,6 +3153,8 @@ open class ReportService( " and p.teamLead = :teamLeadId " ) } + + sql.append(" group by p.code, p.description, c.name, s2.name, t.code, t.name, p.expectedTotalFee, p.subContractFee ") sql.append(" order by p.code ") val args = mapOf( @@ -3083,9 +3172,10 @@ open class ReportService( val updatedList = costAndExpenseList.map { item -> val code = item["code"] as? String val expenditure = projectsExpenditure[code] ?: BigDecimal.ZERO + val projectExpense = item["projectExpense"] as? Double ?: 0.0 val budget = (item["expectedTotalFee"] as Double - item["subContractFee"] as Double).times(0.8) val totalCumulativeExpenditure = (expenditure as? BigDecimal ?: 0.0).toDouble() - val budgetRemain = budget.minus(totalCumulativeExpenditure) + val budgetRemain = budget.minus(totalCumulativeExpenditure).minus(projectExpense) val remainingPercent = (budgetRemain).div(budget) // println("-----------------------------------${item["code"]}-------------------------------") // println("budget: $budget") @@ -3099,20 +3189,20 @@ open class ReportService( } } - val result = updatedList.map { item -> - val budget = (item["budget"] as? Double)?.times(0.8) ?: 0.0 - val totalCumulativeExpenditure = (item["totalCumulativeExpenditure"] as? BigDecimal ?: 0.0).toDouble() - val budgetRemain = budget.minus(totalCumulativeExpenditure) - val remainingPercent = (budgetRemain).div(budget) -// println("-----------------------------------${item["code"]}-------------------------------") -// println("budget: $budget") -// println("totalCumulativeExpenditure: $totalCumulativeExpenditure") -// println("budgetRemain: $budgetRemain") -// println("remainingPercent: $remainingPercent") - item.toMutableMap().apply { - put("budgetPercentage", remainingPercent) - } - } +// val result = updatedList.map { item -> +// val budget = (item["budget"] as? Double)?.times(0.8) ?: 0.0 +// val totalCumulativeExpenditure = (item["totalCumulativeExpenditure"] as? BigDecimal ?: 0.0).toDouble() +// val budgetRemain = budget.minus(totalCumulativeExpenditure) +// val remainingPercent = (budgetRemain).div(budget) +//// println("-----------------------------------${item["code"]}-------------------------------") +//// println("budget: $budget") +//// println("totalCumulativeExpenditure: $totalCumulativeExpenditure") +//// println("budgetRemain: $budgetRemain") +//// println("remainingPercent: $remainingPercent") +// item.toMutableMap().apply { +// put("budgetPercentage", remainingPercent) +// } +// } return updatedList } @@ -3232,16 +3322,23 @@ open class ReportService( CellUtil.setCellStyleProperty(cell7, "dataFormat", accountingStyle) val cell8 = row.getCell(8) ?: row.createCell(8) + val projectExpense = (item["projectExpense"] as BigDecimal).toDouble() cell8.apply { - cellFormula = "G${rowNum + 1}-H${rowNum + 1}" + setCellValue(projectExpense) } CellUtil.setCellStyleProperty(cell8, "dataFormat", accountingStyle) val cell9 = row.getCell(9) ?: row.createCell(9) cell9.apply { - cellFormula = "I${rowNum + 1}/G${rowNum + 1}" + cellFormula = "G${rowNum + 1}-H${rowNum + 1}-I${rowNum + 1}" + } + CellUtil.setCellStyleProperty(cell9, "dataFormat", accountingStyle) + + val cell10 = row.getCell(10) ?: row.createCell(10) + cell10.apply { + cellFormula = "J${rowNum + 1}/G${rowNum + 1}" } - CellUtil.setCellStyleProperty(cell9, "dataFormat", percentStyle) + CellUtil.setCellStyleProperty(cell10, "dataFormat", percentStyle) sheet.setRowBreak(rowNum++); } diff --git a/src/main/java/com/ffii/tsms/modules/report/web/ReportController.kt b/src/main/java/com/ffii/tsms/modules/report/web/ReportController.kt index 096fb28..c12c060 100644 --- a/src/main/java/com/ffii/tsms/modules/report/web/ReportController.kt +++ b/src/main/java/com/ffii/tsms/modules/report/web/ReportController.kt @@ -64,6 +64,7 @@ class ReportController( private val subsidiaryRepository: SubsidiaryRepository, private val staffAllocationRepository: StaffAllocationRepository, private val gradeRepository: GradeRepository, private val salaryEffectiveService: SalaryEffectiveService, + private val projectExpenseRepository: ProjectExpenseRepository, ) { private val logger: Log = LogFactory.getLog(javaClass) @@ -88,9 +89,10 @@ class ReportController( // val invoices = invoiceService.findAllByProjectAndPaidAmountIsNotNull(project) val invoices = invoiceRepository.findAllByProjectCodeAndPaidAmountIsNotNullAndDeletedFalse(project.code!!) val timesheets = timesheetRepository.findAllByProjectTaskIn(projectTasks) + val projectExpenses = projectExpenseRepository.findAll().filter { it.project == project } val monthlyStaffSalaryEffective = salaryEffectiveService.getMonthlyStaffSalaryData(timesheets.minByOrNull { it.recordDate!! }?.recordDate ?: LocalDate.parse("2012-01-01"), timesheets.maxByOrNull { it.recordDate!! }?.recordDate ?: LocalDate.now()) - val reportResult: ByteArray = excelReportService.generateProjectCashFlowReport(project, invoices, timesheets, monthlyStaffSalaryEffective, request.dateType) + val reportResult: ByteArray = excelReportService.generateProjectCashFlowReport(project, invoices, timesheets, projectExpenses, monthlyStaffSalaryEffective, request.dateType) // val mediaType: MediaType = MediaType.parseMediaType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") return ResponseEntity.ok() // .contentType(mediaType) diff --git a/src/main/resources/templates/report/AR04_Cost and Expense Report v02.xlsx b/src/main/resources/templates/report/AR04_Cost and Expense Report v02.xlsx index 6dea4f8..934a821 100644 Binary files a/src/main/resources/templates/report/AR04_Cost and Expense Report v02.xlsx and b/src/main/resources/templates/report/AR04_Cost and Expense Report v02.xlsx differ diff --git a/src/main/resources/templates/report/EX01_Financial Status Report.xlsx b/src/main/resources/templates/report/EX01_Financial Status Report.xlsx index 1279a4c..e1dcf08 100644 Binary files a/src/main/resources/templates/report/EX01_Financial Status Report.xlsx and b/src/main/resources/templates/report/EX01_Financial Status Report.xlsx differ