diff --git a/src/app/api/cashflow/index.ts b/src/app/api/cashflow/index.ts index d946c8a..3549868 100644 --- a/src/app/api/cashflow/index.ts +++ b/src/app/api/cashflow/index.ts @@ -28,6 +28,7 @@ export interface CashFlowByMonthChartResult { cumulativeExpenditure:number; incomeList: any[]; expenditureList: any[]; + beforeCurrentYearExpenditure: any[]; } export interface CashFlowReceivableAndExpenditure { diff --git a/src/components/ProjectCashFlow/ProjectCashFlow.tsx b/src/components/ProjectCashFlow/ProjectCashFlow.tsx index d8ac2fe..8e9e442 100644 --- a/src/components/ProjectCashFlow/ProjectCashFlow.tsx +++ b/src/components/ProjectCashFlow/ProjectCashFlow.tsx @@ -89,6 +89,7 @@ const ProjectCashFlow: React.FC = () => { } const fetchChartData = async () => { const cashFlowMonthlyChartData = await fetchProjectsCashFlowMonthlyChart(selectedProjectIdList,cashFlowYear); + console.log(cashFlowMonthlyChartData) const monthlyIncome = [] const cumulativeIncome = [] const monthlyExpenditure = [] @@ -104,11 +105,11 @@ const ProjectCashFlow: React.FC = () => { cumulativeIncome.push(cashFlowMonthlyChartData[0].incomeList[i].cumulativeIncome) } for (var i = 0; i < cashFlowMonthlyChartData[0].expenditureList.length; i++) { - if (rightMax < cashFlowMonthlyChartData[0].incomeList[i].cumulativeIncome || rightMax < cashFlowMonthlyChartData[0].expenditureList[i].cumulativeExpenditure){ - rightMax = Math.max(cashFlowMonthlyChartData[0].incomeList[i].cumulativeIncome,cashFlowMonthlyChartData[0].expenditureList[i].cumulativeExpenditure) + if (rightMax < cashFlowMonthlyChartData[0].incomeList[i].cumulativeIncome || rightMax < cashFlowMonthlyChartData[0].beforeCurrentYearExpenditure[0].beforeCurrentYearCumulativeExpenditure +cashFlowMonthlyChartData[0].expenditureList[i].cumulativeExpenditure){ + rightMax = Math.max(cashFlowMonthlyChartData[0].incomeList[i].cumulativeIncome,cashFlowMonthlyChartData[0].beforeCurrentYearExpenditure[0].beforeCurrentYearCumulativeExpenditure + cashFlowMonthlyChartData[0].expenditureList[i].cumulativeExpenditure) } monthlyExpenditure.push(cashFlowMonthlyChartData[0].expenditureList[i].expenditure) - cumulativeExpenditure.push(cashFlowMonthlyChartData[0].expenditureList[i].cumulativeExpenditure) + cumulativeExpenditure.push(cashFlowMonthlyChartData[0].beforeCurrentYearExpenditure[0].beforeCurrentYearCumulativeExpenditure + cashFlowMonthlyChartData[0].expenditureList[i].cumulativeExpenditure) } setMonthlyIncomeList(monthlyIncome) setMonthlyCumulativeIncomeList(cumulativeIncome)