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 7e18936..88cfbd1 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 @@ -575,14 +575,14 @@ open class DashboardService( + " coalesce(sum(i.paidAmount),0) as totalReceived," + " round(expenditure.cumulativeExpenditure,2) as cumulativeExpenditure," + " case" - + " when coalesce(round(sum(i.issueAmount) / (expenditure.cumulativeExpenditure),2),0) >= 1 then 'Positive'" - + " when coalesce(round(sum(i.issueAmount) / (expenditure.cumulativeExpenditure),2),0) < 1 then 'Negative'" + + " 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'" + " end as cashFlowStatus," - + " coalesce(round(sum(i.issueAmount) / (expenditure.cumulativeExpenditure),2),0) as cpi," - + " coalesce(round(coalesce(pj.totalFee,0) / (expenditure.cumulativeExpenditure),2),0) as projectedCpi," + + " coalesce(round(sum(i.issueAmount) / (expenditure.cumulativeExpenditure),3),0) as cpi," + + " coalesce(round(coalesce(pj.totalFee,0) / (expenditure.cumulativeExpenditure),3),0) as projectedCpi," + " case" - + " when coalesce(round(coalesce(pj.totalFee,0) / (expenditure.cumulativeExpenditure),2),0) >= 1 then 'Positive'" - + " when coalesce(round(coalesce(pj.totalFee,0) / (expenditure.cumulativeExpenditure),2),0) < 1 then 'Negative'" + + " when coalesce(round(coalesce(pj.totalFee,0) / (expenditure.cumulativeExpenditure),3),0) >= 1 then 'Positive'" + + " when coalesce(round(coalesce(pj.totalFee,0) / (expenditure.cumulativeExpenditure),3),0) < 1 then 'Negative'" + " end as projectedCashFlowStatus" + " from team t" + " left join (" @@ -657,14 +657,14 @@ open class DashboardService( + " sum(p.expectedTotalFee) - sum(i.issueAmount) as unInvoiced," + " sum(i.paidAmount) as totalReceived," + " case" - + " when round(sum(i.issueAmount) / (expenditure.cumulativeExpenditure),2) >= 1 then 'Positive'" - + " when round(sum(i.issueAmount) / (expenditure.cumulativeExpenditure),2) < 1 then 'Negative'" + + " when round(sum(i.issueAmount) / (expenditure.cumulativeExpenditure),3) >= 1 then 'Positive'" + + " when round(sum(i.issueAmount) / (expenditure.cumulativeExpenditure),3) < 1 then 'Negative'" + " end as cashFlowStatus," - + " round(sum(i.issueAmount) / (expenditure.cumulativeExpenditure),2) as cpi," - + " round(sum(p.expectedTotalFee) / (expenditure.cumulativeExpenditure),2) as projectedCpi," + + " round(sum(i.issueAmount) / (expenditure.cumulativeExpenditure),3) as cpi," + + " round(sum(p.expectedTotalFee) / (expenditure.cumulativeExpenditure),3) as projectedCpi," + " case" - + " when round(sum(p.expectedTotalFee) / (expenditure.cumulativeExpenditure),2) >= 1 then 'Positive'" - + " when round(sum(p.expectedTotalFee) / (expenditure.cumulativeExpenditure),2) < 1 then 'Negative'" + + " when round(sum(p.expectedTotalFee) / (expenditure.cumulativeExpenditure),3) >= 1 then 'Positive'" + + " when round(sum(p.expectedTotalFee) / (expenditure.cumulativeExpenditure),3) < 1 then 'Negative'" + " end as projectedCashFlowStatus" + " from project p" + " left join (" @@ -802,14 +802,14 @@ open class DashboardService( + " coalesce(sum(i.issueAmount),0) as totalInvoiced," + " coalesce(sum(i.paidAmount),0) as totalReceived," + " case" - + " when coalesce(round(sum(i.issueAmount) / (COALESCE(expenditure.cumulativeExpenditure,0)),2),0) >= 1 then 'Positive'" - + " when coalesce(round(sum(i.issueAmount) / (COALESCE(expenditure.cumulativeExpenditure,0)),2),0) < 1 then 'Negative'" + + " when coalesce(round(sum(i.issueAmount) / (COALESCE(expenditure.cumulativeExpenditure,0)),3),0) >= 1 then 'Positive'" + + " when coalesce(round(sum(i.issueAmount) / (COALESCE(expenditure.cumulativeExpenditure,0)),3),0) < 1 then 'Negative'" + " end as cashFlowStatus," - + " coalesce(round(sum(i.issueAmount) / (COALESCE(expenditure.cumulativeExpenditure,0)),2),0) as cpi," - + " coalesce(round(p.totalFee / (COALESCE(expenditure.cumulativeExpenditure,0)),2),0) as projectedCpi," + + " coalesce(round(sum(i.issueAmount) / (COALESCE(expenditure.cumulativeExpenditure,0)),3),0) as cpi," + + " coalesce(round(p.totalFee / (COALESCE(expenditure.cumulativeExpenditure,0)),3),0) as projectedCpi," + " case" - + " when coalesce(round(p.totalFee / (COALESCE(expenditure.cumulativeExpenditure,0)),2),0) >= 1 then 'Positive'" - + " when coalesce(round(p.totalFee / (COALESCE(expenditure.cumulativeExpenditure,0)),2),0) < 1 then 'Negative'" + + " when coalesce(round(p.totalFee / (COALESCE(expenditure.cumulativeExpenditure,0)),3),0) >= 1 then 'Positive'" + + " when coalesce(round(p.totalFee / (COALESCE(expenditure.cumulativeExpenditure,0)),3),0) < 1 then 'Negative'" + " end as projectedCashFlowStatus," + " case" + " when p.totalFee - sum(i.issueAmount) >= 0 then coalesce(round(p.totalFee - sum(i.issueAmount),2),0)" @@ -910,14 +910,14 @@ open class DashboardService( + " coalesce(sum(i.issueAmount),0) as totalInvoiced," + " coalesce(sum(i.paidAmount),0) as totalReceived," + " case" - + " when coalesce(round(sum(i.issueAmount) / (COALESCE(expenditure.cumulativeExpenditure,0)),2),0) >= 1 then 'Positive'" - + " when coalesce(round(sum(i.issueAmount) / (COALESCE(expenditure.cumulativeExpenditure,0)),2),0) < 1 then 'Negative'" + + " when coalesce(round(sum(i.issueAmount) / (COALESCE(expenditure.cumulativeExpenditure,0)),3),0) >= 1 then 'Positive'" + + " when coalesce(round(sum(i.issueAmount) / (COALESCE(expenditure.cumulativeExpenditure,0)),3),0) < 1 then 'Negative'" + " end as cashFlowStatus," - + " coalesce(round(sum(i.issueAmount) / (COALESCE(expenditure.cumulativeExpenditure,0)),2),0) as cpi," - + " coalesce(round(p.expectedTotalFee / (COALESCE(expenditure.cumulativeExpenditure,0)),2),0) as projectedCpi," + + " coalesce(round(sum(i.issueAmount) / (COALESCE(expenditure.cumulativeExpenditure,0)),3),0) as cpi," + + " coalesce(round(p.expectedTotalFee / (COALESCE(expenditure.cumulativeExpenditure,0)),3),0) as projectedCpi," + " case" - + " when coalesce(round(p.expectedTotalFee / (COALESCE(expenditure.cumulativeExpenditure,0)),2),0) >= 1 then 'Positive'" - + " when coalesce(round(p.expectedTotalFee / (COALESCE(expenditure.cumulativeExpenditure,0)),2),0) < 1 then 'Negative'" + + " when coalesce(round(p.expectedTotalFee / (COALESCE(expenditure.cumulativeExpenditure,0)),3),0) >= 1 then 'Positive'" + + " when coalesce(round(p.expectedTotalFee / (COALESCE(expenditure.cumulativeExpenditure,0)),3),0) < 1 then 'Negative'" + " end as projectedCashFlowStatus," // + " case" // + " when coalesce(round(sum(p.expectedTotalFee) * 0.8,2),0) <= COALESCE(expenditure.cumulativeExpenditure,0) then coalesce(round(sum(p.expectedTotalFee) * 0.8,2),0) - coalesce(sum(i.issueAmount),0)"