| @@ -449,8 +449,7 @@ open class ReportService( | |||
| val totalFeeCell = row.createCell(7) | |||
| val totalFee = | |||
| (item["expectedTotalFee"]?.let { it as Double } ?: 0.0) - (item["subContractFee"]?.let { it as Double } | |||
| ?: 0.0) | |||
| (item["expectedTotalFee"]?.let { it as Double } ?: 0.0) | |||
| totalFeeCell.apply { | |||
| setCellValue(totalFee) | |||
| cellStyle.dataFormat = accountingStyle | |||
| @@ -479,7 +478,7 @@ open class ReportService( | |||
| } | |||
| val issuedCell = row.createCell(11) | |||
| val issuedAmount = item["issuedAmount"]?.let { it as BigDecimal } ?: BigDecimal(0) | |||
| val issuedAmount = item["sumIssuedAmount"]?.let { it as BigDecimal } ?: BigDecimal(0) | |||
| issuedCell.apply { | |||
| setCellValue(issuedAmount.toDouble()) | |||
| cellStyle = boldFontCellStyle | |||
| @@ -496,7 +495,7 @@ open class ReportService( | |||
| val cpiCell = row.createCell(13) | |||
| cpiCell.apply { | |||
| cellFormula = "IF(L${rowNum} = 0, 0, L${rowNum}/J${rowNum})" | |||
| cellFormula = "IF(J${rowNum} = 0, 0, L${rowNum}/J${rowNum})" | |||
| cellStyle = boldFontCellStyle | |||
| } | |||
| @@ -507,7 +506,7 @@ open class ReportService( | |||
| } | |||
| val receivedAmountCell = row.createCell(15) | |||
| val paidAmount = item["paidAmount"]?.let { it as BigDecimal } ?: BigDecimal(0) | |||
| val paidAmount = item["sumPaidAmount"]?.let { it as BigDecimal } ?: BigDecimal(0) | |||
| receivedAmountCell.apply { | |||
| setCellValue(paidAmount.toDouble()) | |||
| cellStyle.dataFormat = accountingStyle | |||
| @@ -590,7 +589,7 @@ open class ReportService( | |||
| val lastCpiCell = row.createCell(13) | |||
| lastCpiCell.apply { | |||
| cellFormula = "SUM(N15:N${rowNum})" | |||
| cellFormula = "IF(J${rowNum}=0,0,L${rowNum}/J${rowNum})" | |||
| cellStyle = boldFontCellStyle | |||
| cellStyle.dataFormat = accountingStyle | |||
| } | |||
| @@ -599,7 +598,7 @@ open class ReportService( | |||
| val lastPCpiCell = row.createCell(14) | |||
| lastPCpiCell.apply { | |||
| cellFormula = "SUM(O15:O${rowNum})" | |||
| cellFormula = "=IF(J${rowNum}=0,0,H${rowNum}/J${rowNum})" | |||
| cellStyle = boldFontCellStyle | |||
| cellStyle.dataFormat = accountingStyle | |||
| } | |||
| @@ -1940,7 +1939,6 @@ open class ReportService( | |||
| + " 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, ifnull(p.subContractFee, 0) as subContractFee, " | |||
| // + " 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" | |||
| + " ,0 as totalCumulativeExpenditure " | |||
| + " from project p" | |||
| @@ -3096,8 +3094,14 @@ open class ReportService( | |||
| val result = updatedList.map { item -> | |||
| val budget = (item["budget"] as? Double)?.times(0.8) ?: 0.0 | |||
| val budgetRemain = budget - (item["totalCumulativeExpenditure"] as? Double ?: 0.0) | |||
| val remainingPercent = (budgetRemain / budget) | |||
| 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) | |||
| } | |||
| @@ -3930,7 +3934,7 @@ open class ReportService( | |||
| + " select p.id from project p" | |||
| + " where p.status = 'On-going'" | |||
| ) | |||
| if (teamLeadId != null){ | |||
| if (teamLeadId != null && teamLeadId > 0){ | |||
| sql.append( "and p.teamLead = :teamLeadId " ) | |||
| } | |||
| sql.append(" ) and t.recordDate >= p.actualStart ") | |||
| @@ -3971,7 +3975,7 @@ open class ReportService( | |||
| + " select p.id from project p" | |||
| + " where p.status = 'On-going'" | |||
| ) | |||
| if(teamLeadId != null){ | |||
| if(teamLeadId != null && teamLeadId > 0){ | |||
| sql.append(" and p.teamLead = :teamLeadId ") | |||
| } | |||
| sql.append(" )) order by staffId, salaryId, date ") | |||