Browse Source

update cross team report

tags/Baseline_30082024_BACKEND_UAT
cyril.tsui 1 year ago
parent
commit
8336c1f157
1 changed files with 24 additions and 6 deletions
  1. +24
    -6
      src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt

+ 24
- 6
src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt View File

@@ -65,6 +65,7 @@ open class ReportService(
private val COMPLETION_PROJECT = "templates/report/AR05_Project Completion Report.xlsx" 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 CROSS_TEAM_CHARGE_REPORT = "templates/report/Cross Team Charge Report.xlsx"


private val chargeFee = 1.15
private fun conditionalFormattingNegative(sheet: Sheet) { private fun conditionalFormattingNegative(sheet: Sheet) {
// Create a conditional formatting rule // Create a conditional formatting rule
val sheetCF = sheet.sheetConditionalFormatting val sheetCF = sheet.sheetConditionalFormatting
@@ -3688,21 +3689,38 @@ open class ReportService(
rowIndex = 3 rowIndex = 3
sortedTeams.forEach { team: Team -> sortedTeams.forEach { team: Team ->
// not his/her team staffs // 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 } .filter { it.project?.teamLead?.team?.id == team.id && it.staff?.team?.id != team.id }
.mapNotNull { it.staff } .mapNotNull { it.staff }
.sortedBy { it.staffId } .sortedBy { it.staffId }
.distinct() .distinct()




// his/her team projects // 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 } .mapNotNull { it.project }
.sortedByDescending { it.code } .sortedByDescending { it.code }
.distinct() .distinct()


// Team // Team
if (projects.isNotEmpty()) {
if (projects.isNotEmpty() && staffs.isNotEmpty()) {
sheet.createRow(rowIndex++).apply { sheet.createRow(rowIndex++).apply {
createCell(0).apply { createCell(0).apply {
setCellValue("Team to be charged:") setCellValue("Team to be charged:")
@@ -3776,7 +3794,7 @@ open class ReportService(
val startRow = rowIndex + 1 val startRow = rowIndex + 1
var endRow = rowIndex var endRow = rowIndex
projects.forEach { project: Project -> 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) { // if (team.id == project.teamLead?.team?.id) {
endRow++ endRow++
sheet.createRow(rowIndex++).apply { sheet.createRow(rowIndex++).apply {
@@ -3825,7 +3843,7 @@ open class ReportService(
} }


createCell(columnIndex).apply { createCell(columnIndex).apply {
setCellValue(totalSalary)
setCellValue(totalSalary * chargeFee)
val cloneStyle = workbook.createCellStyle() val cloneStyle = workbook.createCellStyle()
cloneStyle.cloneStyleFrom(boldFontWithBorderStyle) cloneStyle.cloneStyleFrom(boldFontWithBorderStyle)
cellStyle = cloneStyle.apply { cellStyle = cloneStyle.apply {


Loading…
Cancel
Save