Browse Source

update report budget calculation

tags/Baseline_30082024_BACKEND_UAT
cyril.tsui 1 year ago
parent
commit
366eb6048c
1 changed files with 9 additions and 8 deletions
  1. +9
    -8
      src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt

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

@@ -136,6 +136,7 @@ open class ReportService(
"planStart" to item.getValue("planStart"), "planStart" to item.getValue("planStart"),
"planEnd" to item.getValue("planEnd"), "planEnd" to item.getValue("planEnd"),
"expectedTotalFee" to item.getValue("expectedTotalFee"), "expectedTotalFee" to item.getValue("expectedTotalFee"),
"subContractFee" to item.getValue("subContractFee"),
"normalConsumed" to manHourRate, "normalConsumed" to manHourRate,
"otConsumed" to manOtHourRate, "otConsumed" to manOtHourRate,
"issuedAmount" to item.getValue("sumIssuedAmount"), "issuedAmount" to item.getValue("sumIssuedAmount"),
@@ -445,7 +446,7 @@ open class ReportService(
endDateCell.setCellValue(if (item["planEnd"] != null) item.getValue("planEnd").toString() else "N/A") endDateCell.setCellValue(if (item["planEnd"] != null) item.getValue("planEnd").toString() else "N/A")


val totalFeeCell = row.createCell(7) val totalFeeCell = row.createCell(7)
val totalFee = item["expectedTotalFee"]?.let { it as Double } ?: 0.0
val totalFee = (item["expectedTotalFee"]?.let { it as Double } ?: 0.0) - (item["subContractFee"]?.let { it as Double } ?: 0.0)
totalFeeCell.apply { totalFeeCell.apply {
setCellValue(totalFee) setCellValue(totalFee)
cellStyle.dataFormat = accountingStyle cellStyle.dataFormat = accountingStyle
@@ -1924,7 +1925,7 @@ open class ReportService(
+ " left join project p on p.code = i.projectCode" + " left join project p on p.code = i.projectCode"
+ " group by p.code" + " group by p.code"
+ " )" + " )"
+ " 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,"
+ " 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_ts.normalConsumed, 0) as normalConsumed, IFNULL(cte_ts.otConsumed, 0) as otConsumed," + " IFNULL(cte_ts.normalConsumed, 0) as normalConsumed, IFNULL(cte_ts.otConsumed, 0) as otConsumed,"
+ " IFNULL(cte_ts.hourlyRate, 0) as hourlyRate, IFNULL(cte_i.sumIssuedAmount, 0) as sumIssuedAmount, IFNULL(cte_i.sumPaidAmount, 0) as sumPaidAmount" + " IFNULL(cte_ts.hourlyRate, 0) as hourlyRate, IFNULL(cte_i.sumIssuedAmount, 0) as sumIssuedAmount, IFNULL(cte_i.sumPaidAmount, 0) as sumPaidAmount"
+ " from project p" + " from project p"
@@ -2063,11 +2064,11 @@ open class ReportService(
+ " tm.code as team, " + " tm.code as team, "
+ " concat(c.code, ' - ',c.name) as client, " + " concat(c.code, ' - ',c.name) as client, "
+ " COALESCE(concat(ss.code, ' - ', ss.name), 'N/A') as subsidiary, " + " COALESCE(concat(ss.code, ' - ', ss.name), 'N/A') as subsidiary, "
+ " p.expectedTotalFee * 0.8 as plannedBudget, "
+ " (p.expectedTotalFee - ifnull(p.subContractFee, 0)) * 0.8 as plannedBudget, "
+ " sum(t.consumedBudget) as actualConsumedBudget, " + " sum(t.consumedBudget) as actualConsumedBudget, "
+ " COALESCE(p.totalManhour, 0) as plannedManhour, " + " COALESCE(p.totalManhour, 0) as plannedManhour, "
+ " sum(t.normalConsumed + COALESCE(t.otConsumed, 0)) as actualConsumedManhour, " + " sum(t.normalConsumed + COALESCE(t.otConsumed, 0)) as actualConsumedManhour, "
+ " sum(t.consumedBudget) / p.expectedTotalFee * 0.8 as budgetConsumptionRate, "
+ " sum(t.consumedBudget) / (p.expectedTotalFee - ifnull(p.subContractFee, 0)) * 0.8 as budgetConsumptionRate, "
+ " sum(t.normalConsumed + COALESCE(t.otConsumed, 0)) / COALESCE(p.totalManhour, 0) as manhourConsumptionRate, " + " sum(t.normalConsumed + COALESCE(t.otConsumed, 0)) / COALESCE(p.totalManhour, 0) as manhourConsumptionRate, "
+ " case " + " case "
+ " when (sum(t.consumedBudget) / p.expectedTotalFee) >= :lowerLimit and (sum(t.consumedBudget) / p.expectedTotalFee) <= 1 " + " when (sum(t.consumedBudget) / p.expectedTotalFee) >= :lowerLimit and (sum(t.consumedBudget) / p.expectedTotalFee) <= 1 "
@@ -2115,7 +2116,7 @@ open class ReportService(
else -> "" else -> ""
} }
} }
sql.append(" group by p.code, p.name, tm.code, c.code, c.name, ss.code, ss.name,p.expectedTotalFee, p.totalManhour, p.expectedTotalFee ")
sql.append(" group by p.code, p.name, tm.code, c.code, c.name, ss.code, ss.name, p.expectedTotalFee, p.subContractFee, p.totalManhour, p.expectedTotalFee ")
sql.append(statusFilter) sql.append(statusFilter)
return jdbcDao.queryForList(sql.toString(), args) return jdbcDao.queryForList(sql.toString(), args)
} }
@@ -2754,7 +2755,7 @@ open class ReportService(
+ " left join salary s2 on s.salaryId = s2.salaryPoint" + " left join salary s2 on s.salaryId = s2.salaryPoint"
+ " left join team t2 on t2.id = s.teamId" + " left join team t2 on t2.id = s.teamId"
+ " )" + " )"
+ " select p.code, p.description, c.name as client, IFNULL(s2.name, \'NA\') as subsidiary, concat(t.code, \' - \', t.name) as teamLead, p.expectedTotalFee,"
+ " select p.code, p.description, c.name as client, IFNULL(s2.name, \'NA\') as subsidiary, concat(t.code, \' - \', t.name) as teamLead, p.expectedTotalFee, ifnull(p.subContractFee, 0) as subContractFee"
+ " SUM(IFNULL(cte_ts.normalConsumed, 0)) as normalConsumed," + " SUM(IFNULL(cte_ts.normalConsumed, 0)) as normalConsumed,"
+ " SUM(IFNULL(cte_ts.otConsumed, 0)) as otConsumed," + " SUM(IFNULL(cte_ts.otConsumed, 0)) as otConsumed,"
+ " IFNULL(cte_ts.hourlyRate, 0) as hourlyRate" + " IFNULL(cte_ts.hourlyRate, 0) as hourlyRate"
@@ -2789,7 +2790,7 @@ open class ReportService(
} }


sql.append( sql.append(
" group by p.code, p.description , c.name, teamLead, p.expectedTotalFee , hourlyRate, s2.name order by p.code"
" group by p.code, p.description , c.name, teamLead, p.expectedTotalFee, p.subContractFee , hourlyRate, s2.name order by p.code"
) )


val args = mapOf( val args = mapOf(
@@ -2811,7 +2812,7 @@ open class ReportService(
"client" to item["client"], "client" to item["client"],
"subsidiary" to item["subsidiary"], "subsidiary" to item["subsidiary"],
"teamLead" to item["teamLead"], "teamLead" to item["teamLead"],
"budget" to item["expectedTotalFee"],
"budget" to item["expectedTotalFee"] as Double - item["subContractFee"] as Double,
"totalManhours" to item["normalConsumed"] as Double + item["otConsumed"] as Double, "totalManhours" to item["normalConsumed"] as Double + item["otConsumed"] as Double,
"manhourExpenditure" to (hourlyRate * item["normalConsumed"] as Double) "manhourExpenditure" to (hourlyRate * item["normalConsumed"] as Double)
+ (hourlyRate * item["otConsumed"] as Double * otFactor) + (hourlyRate * item["otConsumed"] as Double * otFactor)


Loading…
Cancel
Save