|
|
@@ -721,11 +721,14 @@ open class DashboardService( |
|
|
|
+ " when year(p.planStart) = :year and year(p.planEnd) > :year then 12 - month(p.planStart)" |
|
|
|
+ " else PERIOD_DIFF(DATE_FORMAT(p.planEnd, '%Y%m'), DATE_FORMAT(p.planStart, '%Y%m'))+1" |
|
|
|
+ " end AS 'Duration'," |
|
|
|
+ " PERIOD_DIFF(DATE_FORMAT(p.planEnd, '%Y%m'), DATE_FORMAT(p.planStart, '%Y%m'))+1 as projectDuration," |
|
|
|
+ " p.expectedTotalFee*0.8 as totalBudget," |
|
|
|
+ " (p.expectedTotalFee*0.8) / (PERIOD_DIFF(DATE_FORMAT(p.planEnd, '%Y%m'), DATE_FORMAT(p.planStart, '%Y%m'))+1) as aniticipateExpenditure," |
|
|
|
+ " ROUND(p.totalManhour / (PERIOD_DIFF(DATE_FORMAT(p.planEnd, '%Y%m'), DATE_FORMAT(p.planStart, '%Y%m'))+1), 2) AS 'AverageManhours'," |
|
|
|
+ " p.teamLead, p.totalManhour" |
|
|
|
+ " FROM project p" |
|
|
|
+ " WHERE p.status = 'On-going'" |
|
|
|
+ " and p.id in (1,2,3,4,5,6)" |
|
|
|
+ " and p.id in (:projectIds)" |
|
|
|
+ " and (year(p.planStart) <= :year and year(p.planEnd) >= :year)" |
|
|
|
+ " order by teamLead, planStart" |
|
|
|
) |
|
|
@@ -734,6 +737,7 @@ open class DashboardService( |
|
|
|
} |
|
|
|
fun CashFlowLedger(args: Map<String, Any>): List<Map<String, Any>> { |
|
|
|
val sql = StringBuilder("select" |
|
|
|
+ " ROW_NUMBER() OVER (ORDER BY date, income, expenditure) AS id," |
|
|
|
+ " date," |
|
|
|
+ " COALESCE(ROUND(income, 2), 0) AS income," |
|
|
|
+ " COALESCE(ROUND(expenditure, 2), 0) AS expenditure," |
|
|
@@ -830,13 +834,18 @@ open class DashboardService( |
|
|
|
+ " left join team t on p.teamLead = t.teamLead" |
|
|
|
+ " left join invoice i on p.code = i.projectCode" |
|
|
|
+ " where p.status = 'On-going'" |
|
|
|
+ " and t.id = :teamId" |
|
|
|
+ " and year(i.receiptDate) = :year" |
|
|
|
+ " and i.id is not null" |
|
|
|
+ " group by month(i.receiptDate)" |
|
|
|
+ " ) as invoice on months.month = invoice.invoiceMonth" |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
if (args != null) { |
|
|
|
if (args.containsKey("teamId")) |
|
|
|
sql.append(" AND t.id = :teamId") |
|
|
|
} |
|
|
|
sql.append(" and year(i.receiptDate) = :year" |
|
|
|
+ " and i.id is not null" |
|
|
|
+ " group by month(i.receiptDate)" |
|
|
|
+ " ) as invoice on months.month = invoice.invoiceMonth") |
|
|
|
|
|
|
|
return jdbcDao.queryForList(sql.toString(), args) |
|
|
|
} |
|
|
|
fun TeamCashFlowExpenditure(args: Map<String, Any>): List<Map<String, Any>> { |
|
|
@@ -885,13 +894,16 @@ open class DashboardService( |
|
|
|
+ " left join staff s on t.staffId = s.id" |
|
|
|
+ " left join salary s2 on s.salaryId = s2.salaryPoint" |
|
|
|
+ " where t.id is not null" |
|
|
|
+ " and t2.id = :teamId" |
|
|
|
+ " and year(t.recordDate) = :year" |
|
|
|
+ " group by month(t.recordDate),s2.hourlyRate" |
|
|
|
+ " ) as r" |
|
|
|
+ " group by r.recordMonth" |
|
|
|
+ " ) as expenditure on months.month = expenditure.recordMonth" |
|
|
|
) |
|
|
|
if (args != null) { |
|
|
|
if (args.containsKey("teamId")) |
|
|
|
sql.append(" AND t2.id = :teamId") |
|
|
|
} |
|
|
|
sql.append(" and year(t.recordDate) = :year" |
|
|
|
+ " group by month(t.recordDate),s2.hourlyRate" |
|
|
|
+ " ) as r" |
|
|
|
+ " group by r.recordMonth" |
|
|
|
+ " ) as expenditure on months.month = expenditure.recordMonth") |
|
|
|
|
|
|
|
return jdbcDao.queryForList(sql.toString(), args) |
|
|
|
} |
|
|
|