|
|
@@ -863,7 +863,7 @@ open class DashboardService( |
|
|
|
+ " count(p.code) as projectNo," |
|
|
|
+ " sum(p.expectedTotalFee) as totalFee," |
|
|
|
+ " round((sum(p.expectedTotalFee) - sum(ifnull(p.subContractFee, 0))) * 0.8,2) as totalBudget," |
|
|
|
+ " round(expenditure.cumulativeExpenditure + projectExpense.amount,2) as totalExpenditure," |
|
|
|
+ " round((expenditure.cumulativeExpenditure + projectExpense.amount),2) as totalExpenditure," |
|
|
|
+ " round(expenditure.cumulativeExpenditure,2) as manhoursExpenditure," |
|
|
|
+ " round(projectExpense.amount,2) as projectExpense," |
|
|
|
+ " sum(i.issueAmount) as totalInvoiced," |
|
|
@@ -929,15 +929,14 @@ open class DashboardService( |
|
|
|
+ " ) as expenditure on 1=1." |
|
|
|
+ " left join (" |
|
|
|
+ " select" |
|
|
|
+ " p4.id as pid," |
|
|
|
+ " sum(pe.amount) as amount" |
|
|
|
+ " from project p4" |
|
|
|
+ " left join project_expense pe on pe.projectId = p4.id" |
|
|
|
+ " where p4.status = 'On-going'" |
|
|
|
+ " group by p4.id" |
|
|
|
+ " and pe.deleted = false " |
|
|
|
+ " ) as projectExpense on 1 = 1" |
|
|
|
+ " where p.status = 'On-going'" |
|
|
|
+ " group by expenditure.cumulativeExpenditure,projectExpense.amount" |
|
|
|
+ " group by expenditure.cumulativeExpenditure, projectExpense.amount" |
|
|
|
) |
|
|
|
|
|
|
|
return jdbcDao.queryForList(sql.toString(), args) |
|
|
@@ -1002,7 +1001,7 @@ open class DashboardService( |
|
|
|
+ " p.projectNo as projectNo," |
|
|
|
+ " p.totalFee as totalFee," |
|
|
|
+ " p.totalBudget as totalBudget," |
|
|
|
+ " COALESCE(round(expenditure.cumulativeExpenditure + projectExpense.amount,2),0) as totalExpenditure," |
|
|
|
+ " COALESCE(round((expenditure.cumulativeExpenditure + coalesce(projectExpense.amount, 0)),2),0) as totalExpenditure," |
|
|
|
+ " COALESCE(round(expenditure.cumulativeExpenditure,2),0) as manhoursExpenditure," |
|
|
|
+ " COALESCE(round(projectExpense.amount,2),0) as projectExpense," |
|
|
|
+ " coalesce(sum(i.issueAmount),0) as totalInvoiced," |
|
|
@@ -1154,20 +1153,29 @@ open class DashboardService( |
|
|
|
+ " group by r.teamId, r.customerId" |
|
|
|
+ " ) as expenditure on expenditure.teamId = t.id and expenditure.customerId = i.cid" |
|
|
|
+ " left join (" |
|
|
|
// + " select" |
|
|
|
// + " t4.id as teamId," |
|
|
|
// + " sum(pe.amount) as amount" |
|
|
|
// + " from team t4" |
|
|
|
// + " left join project p4 on t4.teamLead = p4.teamLead" |
|
|
|
// + " left join project_expense pe on pe.projectId = p4.id" |
|
|
|
// + " where p4.status = 'On-going'") |
|
|
|
// if (args != null) { |
|
|
|
// if (args.containsKey("teamId")) |
|
|
|
// sql.append(" AND t4.id = :teamId"); |
|
|
|
// } |
|
|
|
// sql.append( |
|
|
|
// " group by t4.id" |
|
|
|
+ " select" |
|
|
|
+ " t4.id as teamId," |
|
|
|
+ " c.id as customerId, c.name," |
|
|
|
+ " sum(pe.amount) as amount" |
|
|
|
+ " from team t4" |
|
|
|
+ " left join project p4 on t4.teamLead = p4.teamLead" |
|
|
|
+ " from project p4" |
|
|
|
+ " left join project_expense pe on pe.projectId = p4.id" |
|
|
|
+ " where p4.status = 'On-going'") |
|
|
|
if (args != null) { |
|
|
|
if (args.containsKey("teamId")) |
|
|
|
sql.append(" AND t4.id = :teamId"); |
|
|
|
} |
|
|
|
sql.append( |
|
|
|
" group by t4.id" |
|
|
|
+ " ) as projectExpense on projectExpense.teamId = t.id" |
|
|
|
+ " left join customer c on c.id = p4.customerId" |
|
|
|
+ " where p4.status = 'On-going'" |
|
|
|
+ " and pe.deleted = false" |
|
|
|
+ " group by c.id, c.name" |
|
|
|
+ " ) as projectExpense on projectExpense.customerId = i.cid" |
|
|
|
+ " where t.deleted = 0" |
|
|
|
+ " and i.cid is not null" |
|
|
|
) |
|
|
@@ -1175,7 +1183,7 @@ open class DashboardService( |
|
|
|
if (args.containsKey("teamId")) |
|
|
|
sql.append(" AND t.id = :teamId"); |
|
|
|
} |
|
|
|
sql.append( " group by t.id, i.cid, i.customerCode, i.customerName, p.projectNo, p.totalFee, p.totalBudget") |
|
|
|
sql.append( " group by t.id, i.cid, i.customerCode, i.customerName, p.projectNo, p.totalFee, p.totalBudget, projectExpense.amount") |
|
|
|
|
|
|
|
return jdbcDao.queryForList(sql.toString(), args) |
|
|
|
} |
|
|
@@ -1252,7 +1260,7 @@ open class DashboardService( |
|
|
|
+ " s3.name as subsidiaryName," |
|
|
|
+ " p.expectedTotalFee as totalFee," |
|
|
|
+ " round((p.expectedTotalFee - ifnull(p.subContractFee, 0)) * 0.8,2) as totalBudget," |
|
|
|
+ " COALESCE(round(expenditure.cumulativeExpenditure + projectExpense.amount,2),0) as totalExpenditure," |
|
|
|
+ " COALESCE(round((expenditure.cumulativeExpenditure + COALESCE(projectExpense.amount, 0)),2),0) as totalExpenditure," |
|
|
|
+ " COALESCE(round(expenditure.cumulativeExpenditure,2),0) as manhoursExpenditure," |
|
|
|
+ " COALESCE(round(projectExpense.amount,2),0) as projectExpense," |
|
|
|
+ " coalesce(sum(i.issueAmount),0) as totalInvoiced," |
|
|
@@ -1326,14 +1334,14 @@ open class DashboardService( |
|
|
|
+ " ) as expenditure on expenditure.teamId = t.id and expenditure.customerId = c.id and expenditure.projectId = p.id" |
|
|
|
+ " left join (" |
|
|
|
+ " select" |
|
|
|
+ " t4.id as teamId," |
|
|
|
+ " p4.id as projectId," |
|
|
|
+ " sum(pe.amount) as amount" |
|
|
|
+ " from team t4" |
|
|
|
+ " left join project p4 on t4.teamLead = p4.teamLead" |
|
|
|
+ " from project p4" |
|
|
|
+ " left join project_expense pe on pe.projectId = p4.id" |
|
|
|
+ " where p4.status = 'On-going'" |
|
|
|
+ " group by t4.id" |
|
|
|
+ " ) as projectExpense on projectExpense.teamId = t.id" |
|
|
|
+ " and pe.deleted = false" |
|
|
|
+ " group by p4.id" |
|
|
|
+ " ) as projectExpense on projectExpense.projectId = p.id" |
|
|
|
+ " where t.deleted = 0" |
|
|
|
+ " and p.status = 'On-going'" |
|
|
|
) |
|
|
@@ -1344,6 +1352,7 @@ open class DashboardService( |
|
|
|
sql.append(" AND c.id = :customerId"); |
|
|
|
} |
|
|
|
sql.append(" group by t.id, p.id, p.code, p.name, c.name, p.expectedTotalFee") |
|
|
|
sql.append(" order by t.id, p.code ") |
|
|
|
|
|
|
|
return jdbcDao.queryForList(sql.toString(), args) |
|
|
|
} |
|
|
|