add total income / total expense / net income to value metric in insights explorer

This commit is contained in:
MaysWind
2026-04-15 00:28:47 +08:00
parent 36d82254d6
commit 53702e68d8
2 changed files with 20 additions and 0 deletions
+14
View File
@@ -831,6 +831,8 @@ export const useExplorersStore = defineStore('explorers', () => {
for (const seriesTransactions of values(allSeriesTransactions)) {
const allSourceAmountsInDefaultCurrency: number[] = [];
let totalSourceAmountSumInDefaultCurrency: number = 0;
let totalSourceIncomeAmountSumInDefaultCurrency: number = 0;
let totalSourceExpenseAmountSumInDefaultCurrency: number = 0;
let minimumSourceAmountInDefaultCurrency: number = Number.MAX_SAFE_INTEGER;
let maximumSourceAmountInDefaultCurrency: number = Number.MIN_SAFE_INTEGER;
@@ -850,6 +852,12 @@ export const useExplorersStore = defineStore('explorers', () => {
allSourceAmountsInDefaultCurrency.push(amountInDefaultCurrency);
totalSourceAmountSumInDefaultCurrency += amountInDefaultCurrency;
if (transaction.type === TransactionType.Income) {
totalSourceIncomeAmountSumInDefaultCurrency += amountInDefaultCurrency;
} else if (transaction.type === TransactionType.Expense) {
totalSourceExpenseAmountSumInDefaultCurrency += amountInDefaultCurrency;
}
if (amountInDefaultCurrency >= 0 && amountInDefaultCurrency < minimumSourceAmountInDefaultCurrency) {
minimumSourceAmountInDefaultCurrency = amountInDefaultCurrency;
}
@@ -865,6 +873,12 @@ export const useExplorersStore = defineStore('explorers', () => {
value = allSourceAmountsInDefaultCurrency.length;
} else if (valueMetric === TransactionExplorerValueMetric.SourceAmountSum) {
value = totalSourceAmountSumInDefaultCurrency;
} else if (valueMetric === TransactionExplorerValueMetric.SourceIncomeAmountSum) {
value = totalSourceIncomeAmountSumInDefaultCurrency;
} else if (valueMetric === TransactionExplorerValueMetric.SourceExpenseAmountSum) {
value = totalSourceExpenseAmountSumInDefaultCurrency;
} else if (valueMetric === TransactionExplorerValueMetric.SourceNetIncomeAmountSum) {
value = totalSourceIncomeAmountSumInDefaultCurrency - totalSourceExpenseAmountSumInDefaultCurrency;
} else if (valueMetric === TransactionExplorerValueMetric.SourceAmountAverage) {
value = allSourceAmountsInDefaultCurrency.length > 0 ? Math.trunc(totalSourceAmountSumInDefaultCurrency / allSourceAmountsInDefaultCurrency.length) : 0;
} else if (valueMetric === TransactionExplorerValueMetric.SourceAmountMedian) {