|
|
@@ -629,13 +629,14 @@ open class DashboardService( |
|
|
|
} |
|
|
|
fun CashFlowReceivableAndExpenditure(args: Map<String, Any>): List<Map<String, Any>> { |
|
|
|
val sql = StringBuilder("select" |
|
|
|
+ "coalesce (round(sum(i.paidAmount)/sum(i.issueAmount)*100,0)) as receivedPercentage," |
|
|
|
+ "coalesce (round(expenditure.expenditure/(sum(p.expectedTotalFee)*0.8)*100,0)) as expenditurePercentage," |
|
|
|
+ " coalesce (round(sum(i.paidAmount)/sum(i.issueAmount)*100,0),0) as receivedPercentage," |
|
|
|
+ " coalesce (round(expenditure.expenditure/(sum(p.expectedTotalFee)*0.8)*100,0),0) as expenditurePercentage," |
|
|
|
+ " coalesce (sum(i.issueAmount),0) as totalInvoiced," |
|
|
|
+ " coalesce (sum(i.paidAmount),0) as totalReceived," |
|
|
|
+ " coalesce (sum(i.issueAmount) - sum(i.paidAmount),0) as receivable," |
|
|
|
+ " coalesce (round(sum(p.expectedTotalFee)*0.8,2),0) as totalBudget," |
|
|
|
+ " coalesce (expenditure.expenditure) as totalExpenditure" |
|
|
|
+ " coalesce (expenditure.expenditure) as totalExpenditure," |
|
|
|
+ " coalesce (sum(p.expectedTotalFee)*0.8 - expenditure.expenditure,0) as expenditureReceivable" |
|
|
|
+ " from project p" |
|
|
|
+ " left join invoice i on p.code = i.projectCode" |
|
|
|
+ " left join(" |
|
|
@@ -697,7 +698,8 @@ open class DashboardService( |
|
|
|
+ " from project p" |
|
|
|
+ " left join milestone m on p.id = m.projectId" |
|
|
|
+ " left join milestone_payment mp on m.id = mp.milestoneId" |
|
|
|
+ " where p.id in (:projecIds)" |
|
|
|
+ " where p.id in (:projectIds)" |
|
|
|
+ " and year(mp.date) = :year" |
|
|
|
+ " group by month(mp.date)" |
|
|
|
+ " ) as anticipateIncome on months.month = anticipateIncome.anticipateIncomeDate" |
|
|
|
) |
|
|
@@ -706,17 +708,26 @@ open class DashboardService( |
|
|
|
} |
|
|
|
fun CashFlowAnticipateExpenditure(args: Map<String, Any>): List<Map<String, Any>> { |
|
|
|
val sql = StringBuilder("select" |
|
|
|
+ " p.id, p.name," |
|
|
|
+ " date_format(p.planStart, '%Y-%m') as planStart," |
|
|
|
+ " date_format(p.planEnd, '%Y-%m') as planEnd," |
|
|
|
+ " month(p.planStart) as startMonth," |
|
|
|
+ " PERIOD_DIFF(DATE_FORMAT(p.planEnd, '%Y%m'), DATE_FORMAT(p.planStart, '%Y%m'))+1 AS 'Duration'," |
|
|
|
+ " ROUND(p.totalManhour / (PERIOD_DIFF(DATE_FORMAT(p.planEnd, '%Y%m'), DATE_FORMAT(p.planStart, '%Y%m'))+1), 2) AS 'Average Manhours'," |
|
|
|
+ " p.teamLead, p.totalManhour" |
|
|
|
+ " FROM project p" |
|
|
|
+ " WHERE p.status = 'On-going'" |
|
|
|
+ " and p.id in (:productIds)" |
|
|
|
+ " order by teamLead, planStart" |
|
|
|
+ " p.id, p.name," |
|
|
|
+ " date_format(p.planStart, '%Y-%m') as planStart," |
|
|
|
+ " date_format(p.planEnd, '%Y-%m') as planEnd," |
|
|
|
+ " case" |
|
|
|
+ " when year(p.planStart) < :year then 1" |
|
|
|
+ " when year(p.planStart) = :year then month(p.planStart)" |
|
|
|
+ " end as startMonth," |
|
|
|
+ " case" |
|
|
|
+ " when year(p.planStart) < :year and year(p.planEnd) > :year then 12" |
|
|
|
+ " when year(p.planStart) < :year and year(p.planEnd) = :year then month(p.planEnd)" |
|
|
|
+ " 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'," |
|
|
|
+ " 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 (year(p.planStart) <= :year and year(p.planEnd) >= :year)" |
|
|
|
+ " order by teamLead, planStart" |
|
|
|
) |
|
|
|
|
|
|
|
return jdbcDao.queryForList(sql.toString(), args) |
|
|
|