| @@ -1580,7 +1580,7 @@ open class DashboardService( | |||||
| + " from(" | + " from(" | ||||
| + " select" | + " select" | ||||
| + " se.recordMonth as recordMonth," | + " se.recordMonth as recordMonth," | ||||
| + " (coalesce(sum(t3.normalConsumed),0) * se.hourlyRate) + (coalesce(sum(t3.otConsumed),0) * se.hourlyRate * 1.0) as cumulativeExpenditure" | |||||
| + " (coalesce(sum(ifNull(t3.normalConsumed, 0)),0) * ifNull(se.hourlyRate, 0)) + (coalesce(sum(ifNull(t3.otConsumed, 0)),0) * ifNull(se.hourlyRate, 0) * 1.0) as cumulativeExpenditure" | |||||
| + " from(" | + " from(" | ||||
| + " select" | + " select" | ||||
| + " month(t.recordDate) as recordMonth," | + " month(t.recordDate) as recordMonth," | ||||
| @@ -1588,20 +1588,21 @@ open class DashboardService( | |||||
| + " t.recordDate as timesheet_record_date," | + " t.recordDate as timesheet_record_date," | ||||
| + " s.id as staff_id," | + " s.id as staff_id," | ||||
| + " se.id as salary_effective_id," | + " se.id as salary_effective_id," | ||||
| + " se.salaryId," | |||||
| + " se.startdate as salary_effective_start_date," | |||||
| + " coalesce(se.salaryId, s.salaryId) as salaryId," | |||||
| + " coalesce(se.startdate, s.joinDate) as salary_effective_start_date," | |||||
| + " coalesce(se.enddate,now()) as salary_effective_end_date," | + " coalesce(se.enddate,now()) as salary_effective_end_date," | ||||
| + " s2.hourlyRate as hourlyRate" | |||||
| + " coalesce(s2.hourlyRate, staffS.hourlyRate, 0) as hourlyRate" | |||||
| + " from project p" | + " from project p" | ||||
| + " left join project_task pt on p.id = pt.project_id" | + " left join project_task pt on p.id = pt.project_id" | ||||
| + " left join timesheet t on pt.id = t.projectTaskId" | + " left join timesheet t on pt.id = t.projectTaskId" | ||||
| + " left join staff s on t.staffId = s.id" | + " left join staff s on t.staffId = s.id" | ||||
| + " left join salary_effective se on t.recordDate >= se.`date` and s.id = se.staffId" | + " left join salary_effective se on t.recordDate >= se.`date` and s.id = se.staffId" | ||||
| + " left join salary s2 on se.salaryId = s2.salaryPoint" | + " left join salary s2 on se.salaryId = s2.salaryPoint" | ||||
| + " left join salary staffS on staffS.salaryPoint = s.salaryId" | |||||
| + " where t.id is not null" | + " where t.id is not null" | ||||
| + " and p.id in (:projectIds)" | + " and p.id in (:projectIds)" | ||||
| + " and year(t.recordDate) = :year" | + " and year(t.recordDate) = :year" | ||||
| + " group by t.id, s.id, se.id, se.salaryId,se.date, s2.hourlyRate" | |||||
| + " group by t.id, s.id, se.id, se.salaryId,se.date, s2.hourlyRate, staffS.hourlyRate" | |||||
| + " ) as se" | + " ) as se" | ||||
| + " left join timesheet t3 on se.tid = t3.id" | + " left join timesheet t3 on se.tid = t3.id" | ||||
| + " where t3.recordDate >= se.salary_effective_start_date and t3.recordDate <= se.salary_effective_end_date" | + " where t3.recordDate >= se.salary_effective_start_date and t3.recordDate <= se.salary_effective_end_date" | ||||
| @@ -1617,7 +1618,7 @@ open class DashboardService( | |||||
| fun BeforeCurrentYearCashFlowMonthlyCumulativeExpenditure(args: Map<String, Any>): List<Map<String, Any>> { | fun BeforeCurrentYearCashFlowMonthlyCumulativeExpenditure(args: Map<String, Any>): List<Map<String, Any>> { | ||||
| val sql = StringBuilder( | val sql = StringBuilder( | ||||
| " select" | " select" | ||||
| + " coalesce (sum(result.expenditure),0) as beforeCurrentYearCumulativeExpenditure" | |||||
| + " coalesce (sum(ifNull(result.expenditure, 0)),0) as beforeCurrentYearCumulativeExpenditure" | |||||
| + " from(" | + " from(" | ||||
| + " select" | + " select" | ||||
| + " r.recordYearMonth as recordYearMonth," | + " r.recordYearMonth as recordYearMonth," | ||||
| @@ -1639,20 +1640,21 @@ open class DashboardService( | |||||
| + " t.recordDate as timesheet_record_date," | + " t.recordDate as timesheet_record_date," | ||||
| + " s.id as staff_id," | + " s.id as staff_id," | ||||
| + " se.id as salary_effective_id," | + " se.id as salary_effective_id," | ||||
| + " se.salaryId," | |||||
| + " se.startdate as salary_effective_start_date," | |||||
| + " coalesce(se.salaryId, s.salaryId) as salaryId," | |||||
| + " coalesce(se.startdate, s.joinDate) as salary_effective_start_date," | |||||
| + " coalesce(se.enddate,now()) as salary_effective_end_date," | + " coalesce(se.enddate,now()) as salary_effective_end_date," | ||||
| + " s2.hourlyRate as hourlyRate" | |||||
| + " coalesce(s2.hourlyRate, staffS.hourlyRate, 0) as hourlyRate" | |||||
| + " from project p" | + " from project p" | ||||
| + " left join project_task pt on p.id = pt.project_id" | + " left join project_task pt on p.id = pt.project_id" | ||||
| + " left join timesheet t on pt.id = t.projectTaskId" | + " left join timesheet t on pt.id = t.projectTaskId" | ||||
| + " left join staff s on t.staffId = s.id" | + " left join staff s on t.staffId = s.id" | ||||
| + " left join salary_effective se on t.recordDate >= se.`date` and s.id = se.staffId" | + " left join salary_effective se on t.recordDate >= se.`date` and s.id = se.staffId" | ||||
| + " left join salary s2 on se.salaryId = s2.salaryPoint" | + " left join salary s2 on se.salaryId = s2.salaryPoint" | ||||
| + " left join salary staffS on s.salaryId = staffS.salaryPoint" | |||||
| + " where t.id is not null" | + " where t.id is not null" | ||||
| + " and p.id in (:projectIds)" | + " and p.id in (:projectIds)" | ||||
| + " and year(t.recordDate) < :year" | + " and year(t.recordDate) < :year" | ||||
| + " group by t.id, s.id, se.id, se.salaryId,se.date, s2.hourlyRate" | |||||
| + " group by t.id, s.id, se.id, se.salaryId,se.date, s2.hourlyRate, staffS.hourlyRate" | |||||
| + " ) as se" | + " ) as se" | ||||
| + " left join timesheet t3 on se.tid = t3.id" | + " left join timesheet t3 on se.tid = t3.id" | ||||
| + " where t3.recordDate >= se.salary_effective_start_date and t3.recordDate <= se.salary_effective_end_date" | + " where t3.recordDate >= se.salary_effective_start_date and t3.recordDate <= se.salary_effective_end_date" | ||||
| @@ -1765,30 +1767,31 @@ open class DashboardService( | |||||
| + " ) as i on i.pid = p.id" | + " ) as i on i.pid = p.id" | ||||
| + " left join(" | + " left join(" | ||||
| + " select" | + " select" | ||||
| + " sum(r.expenditure) as expenditure" | |||||
| + " sum(coalesce(r.expenditure, 0)) as expenditure" | |||||
| + " from(" | + " from(" | ||||
| + " select" | + " select" | ||||
| + " t3.id," | + " t3.id," | ||||
| + " (coalesce(sum(t3.normalConsumed),0) * se.hourlyRate) + (coalesce(sum(t3.otConsumed),0) * se.hourlyRate * 1.0) as expenditure" | |||||
| + " (coalesce(sum(coalesce(t3.normalConsumed, 0)),0) * se.hourlyRate) + (coalesce(sum(coalesce(t3.otConsumed, 0)),0) * se.hourlyRate * 1.0) as expenditure" | |||||
| + " from (" | + " from (" | ||||
| + " select" | + " select" | ||||
| + " t2.id as tid," | + " t2.id as tid," | ||||
| + " t2.recordDate as timesheet_record_date," | + " t2.recordDate as timesheet_record_date," | ||||
| + " s.id as staff_id," | + " s.id as staff_id," | ||||
| + " se.id as salary_effective_id," | + " se.id as salary_effective_id," | ||||
| + " se.salaryId," | |||||
| + " se.startdate as salary_effective_start_date," | |||||
| + " coalesce(se.salaryId, s.salaryId) as salaryId," | |||||
| + " coalesce(se.startdate, s.joinDate) as salary_effective_start_date," | |||||
| + " coalesce(se.enddate,now()) as salary_effective_end_date," | + " coalesce(se.enddate,now()) as salary_effective_end_date," | ||||
| + " s2.hourlyRate as hourlyRate" | |||||
| + " coalesce(s2.hourlyRate, staffS.hourlyRate, 0) as hourlyRate" | |||||
| + " from project p" | + " from project p" | ||||
| + " left join project_task pt on p.id = pt.project_id" | + " left join project_task pt on p.id = pt.project_id" | ||||
| + " left join timesheet t2 on pt.id = t2.projectTaskId" | + " left join timesheet t2 on pt.id = t2.projectTaskId" | ||||
| + " left join staff s on t2.staffId = s.id" | + " left join staff s on t2.staffId = s.id" | ||||
| + " left join salary_effective se on t2.recordDate >= se.`date` and s.id = se.staffId" | + " left join salary_effective se on t2.recordDate >= se.`date` and s.id = se.staffId" | ||||
| + " left join salary s2 on se.salaryId = s2.salaryPoint" | + " left join salary s2 on se.salaryId = s2.salaryPoint" | ||||
| + " left join salary staffS on s.salaryId = staffS.salaryPoint" | |||||
| + " where t2.id is not null" | + " where t2.id is not null" | ||||
| + " and p.id in (:projectIds)" | + " and p.id in (:projectIds)" | ||||
| + " group by t2.id, s.id, se.id, se.salaryId,se.date, s2.hourlyRate" | |||||
| + " group by t2.id, s.id, se.id, se.salaryId,se.date, s2.hourlyRate, staffS.hourlyRate" | |||||
| + " ) as se" | + " ) as se" | ||||
| + " left join timesheet t3 on se.tid = t3.id" | + " left join timesheet t3 on se.tid = t3.id" | ||||
| + " where t3.recordDate >= se.salary_effective_start_date and t3.recordDate <= se.salary_effective_end_date" | + " where t3.recordDate >= se.salary_effective_start_date and t3.recordDate <= se.salary_effective_end_date" | ||||
| @@ -1991,20 +1994,21 @@ open class DashboardService( | |||||
| + " t2.recordDate as timesheet_record_date, " | + " t2.recordDate as timesheet_record_date, " | ||||
| + " s.id as staff_id, " | + " s.id as staff_id, " | ||||
| + " se.id as salary_effective_id, " | + " se.id as salary_effective_id, " | ||||
| + " se.salaryId, " | |||||
| + " se.startdate as salary_effective_start_date, " | |||||
| + " coalesce(se.salaryId, s.salaryId) as salaryId, " | |||||
| + " coalesce(se.startdate, s.joinDate) as salary_effective_start_date, " | |||||
| + " coalesce(se.enddate,NOW()) as salary_effective_end_date, " | + " coalesce(se.enddate,NOW()) as salary_effective_end_date, " | ||||
| + " s2.hourlyRate as hourlyRate " | |||||
| + " coalesce(s2.hourlyRate, staffS.hourlyRate, 0) as hourlyRate " | |||||
| + " from project p2 " | + " from project p2 " | ||||
| + " left join project_task pt ON p2.id = pt.project_id " | + " left join project_task pt ON p2.id = pt.project_id " | ||||
| + " left join timesheet t2 on pt.id = t2.projectTaskId " | + " left join timesheet t2 on pt.id = t2.projectTaskId " | ||||
| + " left join staff s on t2.staffId = s.id " | + " left join staff s on t2.staffId = s.id " | ||||
| + " left join salary_effective se on t2.recordDate >= se.`date` and s.id = se.staffId " | + " left join salary_effective se on t2.recordDate >= se.`date` and s.id = se.staffId " | ||||
| + " left join salary s2 on se.salaryId = s2.salaryPoint " | + " left join salary s2 on se.salaryId = s2.salaryPoint " | ||||
| + " left join salary staffS on s.salaryId = staffS.salaryPoint " | |||||
| + " where p2.status = 'On-going' " | + " where p2.status = 'On-going' " | ||||
| + " and t2.id is not null " | + " and t2.id is not null " | ||||
| + " AND p2.id IN (:projectIds) " | + " AND p2.id IN (:projectIds) " | ||||
| + " group by t2.id, s.id, se.id, se.salaryId,se.date, s2.hourlyRate " | |||||
| + " group by t2.id, s.id, se.id, se.salaryId,se.date, s2.hourlyRate, staffS.hourlyRate " | |||||
| + " ) as se " | + " ) as se " | ||||
| + " left join timesheet t3 on se.tid = t3.id " | + " left join timesheet t3 on se.tid = t3.id " | ||||
| + " where t3.recordDate >= se.salary_effective_start_date and t3.recordDate <= se.salary_effective_end_date " | + " where t3.recordDate >= se.salary_effective_start_date and t3.recordDate <= se.salary_effective_end_date " | ||||
| @@ -2769,7 +2773,7 @@ open class DashboardService( | |||||
| continue | continue | ||||
| } | } | ||||
| System.out.println("-----------------------------------") | System.out.println("-----------------------------------") | ||||
| System.out.println("Staff Name: ${curr.name}") | |||||
| System.out.println("Staff Name: ${curr.name} | Team: ${thisTeam.team.code}") | |||||
| var dateListSize = dateList.size | var dateListSize = dateList.size | ||||
| var publicHolidayListSize = publicHolidayList.size | var publicHolidayListSize = publicHolidayList.size | ||||
| var companyHolidaySize = companyHoliday.size | var companyHolidaySize = companyHoliday.size | ||||
| @@ -2786,12 +2790,16 @@ open class DashboardService( | |||||
| result.add( | result.add( | ||||
| mapOf( | mapOf( | ||||
| "id" to curr.id!!, | "id" to curr.id!!, | ||||
| "staffId" to curr.staffId, | |||||
| "name" to curr.name, | "name" to curr.name, | ||||
| "teamCode" to thisTeam.team.code, | |||||
| "teamId" to thisTeam.team.id, | "teamId" to thisTeam.team.id, | ||||
| "UnsubmittedCount" to unsubmittedCount, | "UnsubmittedCount" to unsubmittedCount, | ||||
| )) | )) | ||||
| } | } | ||||
| return result | |||||
| val filteredResult = result.filter { it["staffId"] != "A003" && it["staffId"] != "A004" && it["staffId"] != "B011" }.filter{ it["teamCode"] != "HO"} | |||||
| return filteredResult | |||||
| } | } | ||||
| fun getMonthlyUnsubmittedTimesheet(args: Map<String, Any>): List<Map<String, Any>> { | fun getMonthlyUnsubmittedTimesheet(args: Map<String, Any>): List<Map<String, Any>> { | ||||
| val today = LocalDate.now() | val today = LocalDate.now() | ||||
| @@ -2826,7 +2834,7 @@ open class DashboardService( | |||||
| continue | continue | ||||
| } | } | ||||
| System.out.println("-----------------------------------") | System.out.println("-----------------------------------") | ||||
| System.out.println("Staff Name: ${curr.name}") | |||||
| System.out.println("Staff Name: ${curr.name} | Team: ${thisTeam.team.code}") | |||||
| var dateListSize = dateList.size | var dateListSize = dateList.size | ||||
| var publicHolidayListSize = publicHolidayList.size | var publicHolidayListSize = publicHolidayList.size | ||||
| var companyHolidaySize = companyHoliday.size | var companyHolidaySize = companyHoliday.size | ||||
| @@ -2843,12 +2851,15 @@ open class DashboardService( | |||||
| result.add( | result.add( | ||||
| mapOf( | mapOf( | ||||
| "id" to curr.id!!, | "id" to curr.id!!, | ||||
| "staffId" to curr.staffId, | |||||
| "name" to curr.name, | "name" to curr.name, | ||||
| "teamCode" to thisTeam.team.code, | |||||
| "teamId" to thisTeam.team.id, | "teamId" to thisTeam.team.id, | ||||
| "UnsubmittedCount" to unsubmittedCount, | "UnsubmittedCount" to unsubmittedCount, | ||||
| )) | )) | ||||
| } | } | ||||
| return result | |||||
| val filteredResult = result.filter { it["staffId"] != "A003" && it["staffId"] != "A004" && it["staffId"] != "B011" }.filter{ it["teamCode"] != "HO"} | |||||
| return filteredResult | |||||
| } | } | ||||
| fun weeklyUnsubmittedTimeSheet(args: Map<String, Any>): List<Map<String, Any>> { | fun weeklyUnsubmittedTimeSheet(args: Map<String, Any>): List<Map<String, Any>> { | ||||
| val sql = StringBuilder( | val sql = StringBuilder( | ||||