| @@ -65,6 +65,7 @@ open class ReportService( | |||
| private val COMPLETION_PROJECT = "templates/report/AR05_Project Completion Report.xlsx" | |||
| private val CROSS_TEAM_CHARGE_REPORT = "templates/report/Cross Team Charge Report.xlsx" | |||
| private val chargeFee = 1.15 | |||
| private fun conditionalFormattingNegative(sheet: Sheet) { | |||
| // Create a conditional formatting rule | |||
| val sheetCF = sheet.sheetConditionalFormatting | |||
| @@ -3688,21 +3689,38 @@ open class ReportService( | |||
| rowIndex = 3 | |||
| sortedTeams.forEach { team: Team -> | |||
| // not his/her team staffs | |||
| val staffs = timesheets | |||
| var staffs = timesheets | |||
| .filter { it.project?.teamLead?.team?.id == team.id && it.staff?.team?.id != team.id } | |||
| .mapNotNull { it.staff } | |||
| .sortedBy { it.staffId } | |||
| .distinct() | |||
| // his/her team projects | |||
| val projects = timesheets | |||
| .filter { it.project?.teamLead?.team?.id == team.id && it.project?.teamLead?.team?.id != it.staff?.team?.id } | |||
| var tempTimesheets = timesheets | |||
| .filter { | |||
| it.project?.teamLead?.team?.id == team.id | |||
| && it.project?.teamLead?.team?.id != it.staff?.team?.id | |||
| } | |||
| if (teamId.lowercase() != "all" && teamId.toLong() != team.id) { | |||
| staffs = staffs.filter { | |||
| it.team.id == teamId.toLong() | |||
| } | |||
| tempTimesheets = tempTimesheets.filter { | |||
| it.staff?.team?.id == teamId.toLong() | |||
| } | |||
| } | |||
| val projects = tempTimesheets | |||
| .mapNotNull { it.project } | |||
| .sortedByDescending { it.code } | |||
| .distinct() | |||
| // Team | |||
| if (projects.isNotEmpty()) { | |||
| if (projects.isNotEmpty() && staffs.isNotEmpty()) { | |||
| sheet.createRow(rowIndex++).apply { | |||
| createCell(0).apply { | |||
| setCellValue("Team to be charged:") | |||
| @@ -3776,7 +3794,7 @@ open class ReportService( | |||
| val startRow = rowIndex + 1 | |||
| var endRow = rowIndex | |||
| projects.forEach { project: Project -> | |||
| if (teamId.lowercase() == "all" || teamId.toLong() == project.teamLead?.team?.id || teamId.toLong() == team.id) { | |||
| if (teamId.lowercase() == "all" || teamId.toLong() == project.teamLead?.team?.id || teamId.toLong() == team.id || team.id == project.teamLead?.team?.id) { | |||
| // if (team.id == project.teamLead?.team?.id) { | |||
| endRow++ | |||
| sheet.createRow(rowIndex++).apply { | |||
| @@ -3825,7 +3843,7 @@ open class ReportService( | |||
| } | |||
| createCell(columnIndex).apply { | |||
| setCellValue(totalSalary) | |||
| setCellValue(totalSalary * chargeFee) | |||
| val cloneStyle = workbook.createCellStyle() | |||
| cloneStyle.cloneStyleFrom(boldFontWithBorderStyle) | |||
| cellStyle = cloneStyle.apply { | |||