From d38164adf70b78cbecc8f0ae319c86fa231dd9ce Mon Sep 17 00:00:00 2001 From: "MSI\\User" Date: Thu, 29 Aug 2024 15:48:24 +0800 Subject: [PATCH] fix cumulative income graph --- src/app/api/cashflow/index.ts | 1 + src/components/ProjectCashFlow/ProjectCashFlow.tsx | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app/api/cashflow/index.ts b/src/app/api/cashflow/index.ts index 3549868..5d2f9fb 100644 --- a/src/app/api/cashflow/index.ts +++ b/src/app/api/cashflow/index.ts @@ -29,6 +29,7 @@ export interface CashFlowByMonthChartResult { incomeList: any[]; expenditureList: any[]; beforeCurrentYearExpenditure: any[]; + beforeCurrentYearIncome: any[]; } export interface CashFlowReceivableAndExpenditure { diff --git a/src/components/ProjectCashFlow/ProjectCashFlow.tsx b/src/components/ProjectCashFlow/ProjectCashFlow.tsx index 8e9e442..66827ff 100644 --- a/src/components/ProjectCashFlow/ProjectCashFlow.tsx +++ b/src/components/ProjectCashFlow/ProjectCashFlow.tsx @@ -102,11 +102,11 @@ const ProjectCashFlow: React.FC = () => { leftMax = Math.max(cashFlowMonthlyChartData[0].incomeList[i].income,cashFlowMonthlyChartData[0].expenditureList[i].expenditure) } monthlyIncome.push(cashFlowMonthlyChartData[0].incomeList[i].income) - cumulativeIncome.push(cashFlowMonthlyChartData[0].incomeList[i].cumulativeIncome) + cumulativeIncome.push(cashFlowMonthlyChartData[0].beforeCurrentYearIncome[0].beforeCurrentYearCumulativeIncome + 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].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) + if (rightMax < cashFlowMonthlyChartData[0].beforeCurrentYearIncome[0].beforeCurrentYearCumulativeIncome + cashFlowMonthlyChartData[0].incomeList[i].cumulativeIncome || rightMax < cashFlowMonthlyChartData[0].beforeCurrentYearExpenditure[0].beforeCurrentYearCumulativeExpenditure +cashFlowMonthlyChartData[0].expenditureList[i].cumulativeExpenditure){ + rightMax = Math.max(cashFlowMonthlyChartData[0].beforeCurrentYearIncome[0].beforeCurrentYearCumulativeIncome + 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].beforeCurrentYearExpenditure[0].beforeCurrentYearCumulativeExpenditure + cashFlowMonthlyChartData[0].expenditureList[i].cumulativeExpenditure)