fix the problem that the monthly total income/expense amount sometimes is wrong

This commit is contained in:
MaysWind
2023-07-31 01:36:32 +08:00
parent 6da910d8fb
commit 4cff481d61
+4 -4
View File
@@ -198,14 +198,14 @@ function calculateMonthTotalAmount(state, exchangeRatesStore, transactionMonthLi
continue; continue;
} }
amount = Math.floor(balance); amount = balance;
} }
if (transaction.type === transactionConstants.allTransactionTypes.Expense) { if (transaction.type === transactionConstants.allTransactionTypes.Expense) {
totalExpense += amount; totalExpense += amount;
} else if (transaction.type === transactionConstants.allTransactionTypes.Income) { } else if (transaction.type === transactionConstants.allTransactionTypes.Income) {
totalIncome += amount; totalIncome += amount;
} else if (transaction.type === transactionConstants.allTransactionTypes.Transfer && accountId) { } else if (transaction.type === transactionConstants.allTransactionTypes.Transfer && accountId && accountId !== '0') {
if (accountId === transaction.sourceAccountId) { if (accountId === transaction.sourceAccountId) {
totalExpense += amount; totalExpense += amount;
} else if (accountId === transaction.destinationAccountId) { } else if (accountId === transaction.destinationAccountId) {
@@ -222,9 +222,9 @@ function calculateMonthTotalAmount(state, exchangeRatesStore, transactionMonthLi
} }
transactionMonthList.totalAmount = { transactionMonthList.totalAmount = {
expense: totalExpense, expense: Math.floor(totalExpense),
incompleteExpense: incomplete || hasUnCalculatedTotalExpense, incompleteExpense: incomplete || hasUnCalculatedTotalExpense,
income: totalIncome, income: Math.floor(totalIncome),
incompleteIncome: incomplete || hasUnCalculatedTotalIncome incompleteIncome: incomplete || hasUnCalculatedTotalIncome
}; };
} }