| @@ -1433,7 +1433,13 @@ open class ReportService( | |||
| // result = timesheet record mapped | |||
| var result: Map<String, Any> = mapOf() | |||
| 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( | |||
| { it["id"].toString() }, | |||
| { | |||
| @@ -1583,7 +1589,7 @@ open class ReportService( | |||
| // } | |||
| if (totalConsumed.isNotEmpty()) { | |||
| 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) { | |||
| normalConsumed += 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 p on p.id = pt.project_id" | |||
| + " 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" | |||
| + " order by p.id, t.recordDate" | |||
| ) | |||
| @@ -2226,11 +2232,11 @@ open class ReportService( | |||
| val sql = StringBuilder( | |||
| "SELECT" | |||
| + " 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 " | |||
| + " left join project p on p.id = t.projectId " | |||
| + " where t.staffId = :staffId " | |||
| + " and t.recordDate BETWEEN :startDate and :endDate " | |||
| + " and t.recordDate >= :startDate and t.recordDate < :endDate " | |||
| + " group by t.recordDate " | |||
| + " order by t.recordDate; " | |||
| ) | |||
| @@ -2244,7 +2250,7 @@ open class ReportService( | |||
| + " CAST(DATE_FORMAT(recordDate, '%d') AS SIGNED) AS recordDate " | |||
| + " from `leave` " | |||
| + " where staffId = :staffId " | |||
| + " and recordDate BETWEEN :startDate and :endDate " | |||
| + " and recordDate >= :startDate and recordDate < :endDate " | |||
| + " group by recordDate " | |||
| + " order by recordDate " | |||
| ) | |||
| @@ -2604,10 +2610,15 @@ open class ReportService( | |||
| val staffInfoList = mutableListOf<Map<String, Any>>() | |||
| val staffSalaryLists = salaryEffectiveService.getStaffSalaryDataByProjectId(projectId) | |||
| // val testing = staffSalaryLists.filter{ it.staffId == "B730"} | |||
| // println("-------------testing-------------") | |||
| // println(testing) | |||
| for (item in manHoursSpent) { | |||
| 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() | |||
| if (!staffInfoList.any { it["staffId"] == item["staffId"] && it["name"] == item["name"] }) { | |||