From 81713333dc16831def5b5f1ef2569e0450bf25a4 Mon Sep 17 00:00:00 2001 From: "MSI\\derek" Date: Fri, 25 Oct 2024 20:43:31 +0800 Subject: [PATCH] update sql --- .../ffii/tsms/modules/data/service/DashboardService.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/ffii/tsms/modules/data/service/DashboardService.kt b/src/main/java/com/ffii/tsms/modules/data/service/DashboardService.kt index 5a983b1..7a89093 100644 --- a/src/main/java/com/ffii/tsms/modules/data/service/DashboardService.kt +++ b/src/main/java/com/ffii/tsms/modules/data/service/DashboardService.kt @@ -3448,9 +3448,9 @@ open class DashboardService( + " select " + " projectId, " + " CASE WHEN tl.teamId = p.teamId " - + " THEN SUM((COALESCE(t.normalConsumed, 0) + COALESCE(t.otConsumed, 0)) * COALESCE(sal.hourlyRate, 0)) " - + " ELSE SUM((COALESCE(t.normalConsumed, 0) + COALESCE(t.otConsumed, 0)) * COALESCE(sal.hourlyRate, 0) * 1) " // cross team multiplier - + " END AS manhourExpense " + + " then sum((coalesce(t.normalConsumed, 0) + coalesce(t.otConsumed, 0)) * coalesce(sal.hourlyRate, sal2.hourlyRate)) " + + " else sum((coalesce(t.normalConsumed, 0) + coalesce(t.otConsumed, 0)) * coalesce(sal.hourlyRate, sal2.hourlyRate)) " + + " end as manhourExpense " + " from ( " + " SELECT * " + " FROM timesheet t " @@ -3464,6 +3464,8 @@ open class DashboardService( + " left join team_log tl on tl.staffId = t.staffId and t.recordDate between tl.`from` AND tl.`to` " + " left JOIN salary_effective se ON se.staffId = t.staffId and t.recordDate between se.startDate AND se.endDate " + " left join salary sal on sal.salaryPoint = se.salaryId " + + " left join staff s on s.id = t.staffId and se.id is null " + + " left join salary sal2 on sal2.salaryPoint = s.salaryId " + " GROUP BY t.projectId, tl.teamId, p.teamId " + " ) " // invoice data