Quellcode durchsuchen

totalExpenditure / manhoursExpenditure / projectExpense

add_swagger
MSI\User vor 11 Monaten
Ursprung
Commit
fecbfc3592
1 geänderte Dateien mit 57 neuen und 5 gelöschten Zeilen
  1. +57
    -5
      src/main/java/com/ffii/tsms/modules/data/service/DashboardService.kt

+ 57
- 5
src/main/java/com/ffii/tsms/modules/data/service/DashboardService.kt Datei anzeigen

@@ -704,7 +704,9 @@ open class DashboardService(
+ " coalesce(sum(i.issueAmount),0) as totalInvoiced,"
+ " coalesce(pj.totalFee,0) - coalesce(sum(i.issueAmount),0) as unInvoiced,"
+ " coalesce(sum(i.paidAmount),0) as totalReceived,"
+ " round(expenditure.cumulativeExpenditure,2) as cumulativeExpenditure,"
+ " round(expenditure.cumulativeExpenditure + projectExpense.amount,2) as totalExpenditure,"
+ " round(expenditure.cumulativeExpenditure,2) as manhoursExpenditure,"
+ " round(projectExpense.amount,2) as projectExpense,"
+ " case"
+ " when coalesce(round(sum(i.issueAmount) / (expenditure.cumulativeExpenditure),3),0) >= 1 then 'Positive'"
+ " when coalesce(round(sum(i.issueAmount) / (expenditure.cumulativeExpenditure),3),0) < 1 then 'Negative'"
@@ -780,6 +782,16 @@ open class DashboardService(
+ " ) as r"
+ " group by r.teamId"
+ " ) as expenditure on expenditure.teamId = t.id"
+ " 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'"
+ " group by t4.id"
+ " ) as projectExpense on projectExpense.teamId = t.id"
+ " where t.deleted = 0"
+ " and pj.projectNo is not null"
)
@@ -851,7 +863,9 @@ 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,2) as cumulativeExpenditure,"
+ " 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,"
+ " sum(p.expectedTotalFee) - sum(i.issueAmount) as unInvoiced,"
+ " sum(i.paidAmount) as totalReceived,"
@@ -913,8 +927,17 @@ open class DashboardService(
+ " group by t3.id, se.hourlyRate"
+ " ) as r"
+ " ) 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"
+ " ) as projectExpense on 1 = 1"
+ " where p.status = 'On-going'"
+ " group by expenditure.cumulativeExpenditure"
+ " group by expenditure.cumulativeExpenditure,projectExpense.amount"
)

return jdbcDao.queryForList(sql.toString(), args)
@@ -979,7 +1002,9 @@ open class DashboardService(
+ " p.projectNo as projectNo,"
+ " p.totalFee as totalFee,"
+ " p.totalBudget as totalBudget,"
+ " COALESCE(round(expenditure.cumulativeExpenditure,2),0) as cumulativeExpenditure,"
+ " COALESCE(round(expenditure.cumulativeExpenditure + projectExpense.amount,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,"
+ " coalesce(sum(i.paidAmount),0) as totalReceived,"
+ " case"
@@ -1128,6 +1153,21 @@ open class DashboardService(
+ " ) as r"
+ " 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"
+ " ) as projectExpense on projectExpense.teamId = t.id"
+ " where t.deleted = 0"
+ " and i.cid is not null"
)
@@ -1212,7 +1252,9 @@ 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,2),0) as cumulativeExpenditure,"
+ " COALESCE(round(expenditure.cumulativeExpenditure + projectExpense.amount,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,"
+ " coalesce(sum(i.paidAmount),0) as totalReceived,"
+ " case"
@@ -1282,6 +1324,16 @@ open class DashboardService(
+ " ) as r"
+ " group by r.teamId, r.customerId, r.projectId"
+ " ) as expenditure on expenditure.teamId = t.id and expenditure.customerId = c.id and expenditure.projectId = p.id"
+ " 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'"
+ " group by t4.id"
+ " ) as projectExpense on projectExpense.teamId = t.id"
+ " where t.deleted = 0"
+ " and p.status = 'On-going'"
)


Laden…
Abbrechen
Speichern