| @@ -1433,7 +1433,13 @@ open class ReportService( | |||||
| // result = timesheet record mapped | // result = timesheet record mapped | ||||
| var result: Map<String, Any> = mapOf() | var result: Map<String, Any> = mapOf() | ||||
| if (timesheets.isNotEmpty()) { | if (timesheets.isNotEmpty()) { | ||||
| projectList = timesheets.map { "${it["code"]}\n ${it["name"]}" }.toList().distinct() | |||||
| projectList = timesheets.map { | |||||
| if (it["code"] != null) { | |||||
| "${it["code"]}\n ${it["name"]}" | |||||
| } else { | |||||
| "Non-Billable Tasks" | |||||
| } | |||||
| }.toList().distinct() | |||||
| result = timesheets.groupBy( | result = timesheets.groupBy( | ||||
| { it["id"].toString() }, | { it["id"].toString() }, | ||||
| { | { | ||||
| @@ -1583,7 +1589,7 @@ open class ReportService( | |||||
| // } | // } | ||||
| if (totalConsumed.isNotEmpty()) { | if (totalConsumed.isNotEmpty()) { | ||||
| totalConsumed.forEach { t -> | totalConsumed.forEach { t -> | ||||
| val total = t["totalConsumed"] as Double | |||||
| val total = if (t["totalConsumed"] != null) t["totalConsumed"] as Double else 0.0 | |||||
| if (total > 8.0) { | if (total > 8.0) { | ||||
| normalConsumed += 8.0 | normalConsumed += 8.0 | ||||
| otConsumed += total - 8.0 | otConsumed += total - 8.0 | ||||
| @@ -2215,7 +2221,7 @@ open class ReportService( | |||||
| + " left join project_task pt on t.projectTaskId = pt.id" | + " left join project_task pt on t.projectTaskId = pt.id" | ||||
| + " left join project p on p.id = pt.project_id" | + " left join project p on p.id = pt.project_id" | ||||
| + " where t.staffId = :staffId" | + " where t.staffId = :staffId" | ||||
| + " and t.recordDate BETWEEN :startDate and :endDate" | |||||
| + " and t.recordDate >= :startDate and t.recordDate < :endDate" | |||||
| + " group by p.id, t.recordDate" | + " group by p.id, t.recordDate" | ||||
| + " order by p.id, t.recordDate" | + " order by p.id, t.recordDate" | ||||
| ) | ) | ||||
| @@ -2226,11 +2232,11 @@ open class ReportService( | |||||
| val sql = StringBuilder( | val sql = StringBuilder( | ||||
| "SELECT" | "SELECT" | ||||
| + " CAST(DATE_FORMAT(t.recordDate, '%d') AS SIGNED) AS recordDate, " | + " CAST(DATE_FORMAT(t.recordDate, '%d') AS SIGNED) AS recordDate, " | ||||
| + " coalesce(sum(t.normalConsumed), 0) + coalesce(sum(t.otConsumed), 0) " | |||||
| + " sum(coalesce(t.normalConsumed, 0) + coalesce(t.otConsumed, 0)) as totalConsumed" | |||||
| + " from timesheet t " | + " from timesheet t " | ||||
| + " left join project p on p.id = t.projectId " | + " left join project p on p.id = t.projectId " | ||||
| + " where t.staffId = :staffId " | + " where t.staffId = :staffId " | ||||
| + " and t.recordDate BETWEEN :startDate and :endDate " | |||||
| + " and t.recordDate >= :startDate and t.recordDate < :endDate " | |||||
| + " group by t.recordDate " | + " group by t.recordDate " | ||||
| + " order by t.recordDate; " | + " order by t.recordDate; " | ||||
| ) | ) | ||||
| @@ -2244,7 +2250,7 @@ open class ReportService( | |||||
| + " CAST(DATE_FORMAT(recordDate, '%d') AS SIGNED) AS recordDate " | + " CAST(DATE_FORMAT(recordDate, '%d') AS SIGNED) AS recordDate " | ||||
| + " from `leave` " | + " from `leave` " | ||||
| + " where staffId = :staffId " | + " where staffId = :staffId " | ||||
| + " and recordDate BETWEEN :startDate and :endDate " | |||||
| + " and recordDate >= :startDate and recordDate < :endDate " | |||||
| + " group by recordDate " | + " group by recordDate " | ||||
| + " order by recordDate " | + " order by recordDate " | ||||
| ) | ) | ||||
| @@ -2604,10 +2610,15 @@ open class ReportService( | |||||
| val staffInfoList = mutableListOf<Map<String, Any>>() | val staffInfoList = mutableListOf<Map<String, Any>>() | ||||
| val staffSalaryLists = salaryEffectiveService.getStaffSalaryDataByProjectId(projectId) | val staffSalaryLists = salaryEffectiveService.getStaffSalaryDataByProjectId(projectId) | ||||
| // val testing = staffSalaryLists.filter{ it.staffId == "B730"} | |||||
| // println("-------------testing-------------") | |||||
| // println(testing) | |||||
| for (item in manHoursSpent) { | for (item in manHoursSpent) { | ||||
| updateInfo(info, item) | updateInfo(info, item) | ||||
| if (item.getValue("staffId") == "B730") { | |||||
| println("---------item---------") | |||||
| println(item) | |||||
| } | |||||
| val hourlyRate = getSalaryForMonth(item.getValue("recordDate") as String, item.getValue("staffId") as String, staffSalaryLists) ?: (item.getValue("hourlyRate") as BigDecimal).toDouble() | val hourlyRate = getSalaryForMonth(item.getValue("recordDate") as String, item.getValue("staffId") as String, staffSalaryLists) ?: (item.getValue("hourlyRate") as BigDecimal).toDouble() | ||||
| if (!staffInfoList.any { it["staffId"] == item["staffId"] && it["name"] == item["name"] }) { | if (!staffInfoList.any { it["staffId"] == item["staffId"] && it["name"] == item["name"] }) { | ||||