From 1aa124164f3f083a93a7f9f4540ac4a7d4ab36c6 Mon Sep 17 00:00:00 2001 From: "Mac\\David" Date: Mon, 22 Jul 2024 15:01:21 +0800 Subject: [PATCH] dashboard update budget calculation --- .../modules/data/service/DashboardService.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 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 74f214a..9be62f5 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 @@ -540,7 +540,7 @@ open class DashboardService( + " t2.id as tid," + " count(p.id) as projectNo," + " sum(p.expectedTotalFee) as totalFee," - + " sum(round(p.expectedTotalFee * 0.8,2)) as totalBudget" + + " sum(round((p.expectedTotalFee - p.subContractFee) * 0.8,2)) as totalBudget" + " from team t2" + " left join project p on t2.teamLead = p.teamLead" + " where p.status = 'On-going'" @@ -601,7 +601,7 @@ open class DashboardService( + " 'All Team' as teamName," + " count(p.code) as projectNo," + " sum(p.expectedTotalFee) as totalFee," - + " round(sum(p.expectedTotalFee) * 0.8,2) as totalBudget," + + " round((sum(p.expectedTotalFee) - sum(p.subContractFee)) * 0.8,2) as totalBudget," + " round(expenditure.cumulativeExpenditure,2) as cumulativeExpenditure," + " sum(i.issueAmount) as totalInvoiced," + " sum(p.expectedTotalFee) - sum(i.issueAmount) as unInvoiced," @@ -795,7 +795,7 @@ open class DashboardService( + " c.id as cid," + " count(p.id) as projectNo," + " sum(p.expectedTotalFee) as totalFee," - + " round(sum(p.expectedTotalFee) * 0.8,2) as totalBudget" + + " round((sum(p.expectedTotalFee) - sum(p.subContractFee)) * 0.8,2) as totalBudget" + " from team t" + " left join project p on t.teamLead = p.teamLead" + " left join customer c on p.customerId = c.id" @@ -855,7 +855,7 @@ open class DashboardService( + " c.name as customerName," + " s3.name as subsidiaryName," + " p.expectedTotalFee as totalFee," - + " round(p.expectedTotalFee * 0.8,2) as totalBudget," + + " round((p.expectedTotalFee - p.subContractFee) * 0.8,2) as totalBudget," + " COALESCE(round(expenditure.cumulativeExpenditure,2),0) as cumulativeExpenditure," + " coalesce(sum(i.issueAmount),0) as totalInvoiced," + " coalesce(sum(i.paidAmount),0) as totalReceived," @@ -1060,13 +1060,13 @@ open class DashboardService( fun CashFlowReceivableAndExpenditure(args: Map): List> { val sql = StringBuilder("select" + " 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 (round(expenditure.expenditure/((sum(p.expectedTotalFee) - sum(p.subContractFee))*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 (round((sum(p.expectedTotalFee) - sum(p.subContractFee))*0.8,2),0) as totalBudget," + " coalesce (expenditure.expenditure,0) as totalExpenditure," - + " coalesce (sum(p.expectedTotalFee)*0.8 - expenditure.expenditure,0) as expenditureReceivable," + + " coalesce ((sum(p.expectedTotalFee) - sum(p.subContractFee))*0.8 - expenditure.expenditure,0) as expenditureReceivable," + " sum(p.expectedTotalFee) as totalProjectFee," + " coalesce (round(sum(i.issueAmount)/sum(p.expectedTotalFee)*100,0),0) as invoicedPercentage" + " from project p" @@ -1164,8 +1164,8 @@ open class DashboardService( + " 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," + + " (p.expectedTotalFee - p.subContractFee)*0.8 as totalBudget," + + " ((p.expectedTotalFee - p.subContractFee)*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" @@ -1412,9 +1412,9 @@ open class DashboardService( "select" + " concat(p.code,'-',p.name) as projectCodeAndName," + " p.expectedTotalFee as totalFee," - + " p.expectedTotalFee * 0.8 as totalBudget," + + " (p.expectedTotalFee - p.subContractFee) * 0.8 as totalBudget," + " coalesce (expenditure.expenditure,0) as expenditure," - + " (p.expectedTotalFee * 0.8) - coalesce (expenditure.expenditure,0) as remainingBudget," + + " ((p.expectedTotalFee - p.subContractFee) * 0.8) - coalesce (expenditure.expenditure,0) as remainingBudget," + " case" + " when p.expectedTotalFee - expenditure.expenditure >= 0 then 'Within Budget'" + " when p.expectedTotalFee - expenditure.expenditure < 0 then 'Overconsumption'"