mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-14 06:57:35 +08:00
add active transaction days and transactions per active day to value metric in insights explorer
This commit is contained in:
@@ -301,6 +301,8 @@ export class TransactionExplorerDataDimension implements NameValue {
|
||||
|
||||
export enum TransactionExplorerValueMetricType {
|
||||
TransactionCount = 'transactionCount',
|
||||
ActiveTransactionDays = 'activeTransactionDays',
|
||||
TransactionsPerActiveDay = 'transactionsPerActiveDay',
|
||||
SourceIncomeAmountSum = 'sourceIncomeAmountSum',
|
||||
SourceExpenseAmountSum = 'sourceExpenseAmountSum',
|
||||
SourceNetIncomeAmountSum = 'sourceNetIncomeAmountSum',
|
||||
@@ -334,6 +336,8 @@ export class TransactionExplorerValueMetric implements NameValue {
|
||||
private static readonly allInstancesByValue: Record<string, TransactionExplorerValueMetric> = {};
|
||||
|
||||
public static readonly TransactionCount = new TransactionExplorerValueMetric('Transaction Count', TransactionExplorerValueMetricType.TransactionCount, false, false, true);
|
||||
public static readonly ActiveTransactionDays = new TransactionExplorerValueMetric('Active Transaction Days', TransactionExplorerValueMetricType.ActiveTransactionDays, false, false, true);
|
||||
public static readonly TransactionsPerDay = new TransactionExplorerValueMetric('Transactions per Active Day', TransactionExplorerValueMetricType.TransactionsPerActiveDay, false, false, true);
|
||||
public static readonly SourceIncomeAmountSum = new TransactionExplorerValueMetric('Total Income', TransactionExplorerValueMetricType.SourceIncomeAmountSum, true, false, true);
|
||||
public static readonly SourceExpenseAmountSum = new TransactionExplorerValueMetric('Total Expense', TransactionExplorerValueMetricType.SourceExpenseAmountSum, true, false, true);
|
||||
public static readonly SourceNetIncomeAmountSum = new TransactionExplorerValueMetric('Net Income', TransactionExplorerValueMetricType.SourceNetIncomeAmountSum, true, false, true);
|
||||
|
||||
@@ -1806,6 +1806,8 @@
|
||||
"Destination Account Currency": "Zielkonto-Währung",
|
||||
"Value Metric": "Wertmetrik",
|
||||
"Transaction Count": "Transaktionsanzahl",
|
||||
"Active Transaction Days": "Active Transaction Days",
|
||||
"Transactions per Active Day": "Transactions per Active Day",
|
||||
"Expense / Income Ratio": "Expense / Income Ratio",
|
||||
"Savings Rate": "Savings Rate",
|
||||
"Average Amount": "Durchschnittsbetrag",
|
||||
|
||||
@@ -1806,6 +1806,8 @@
|
||||
"Destination Account Currency": "Destination Account Currency",
|
||||
"Value Metric": "Value Metric",
|
||||
"Transaction Count": "Transaction Count",
|
||||
"Active Transaction Days": "Active Transaction Days",
|
||||
"Transactions per Active Day": "Transactions per Active Day",
|
||||
"Expense / Income Ratio": "Expense / Income Ratio",
|
||||
"Savings Rate": "Savings Rate",
|
||||
"Average Amount": "Average Amount",
|
||||
|
||||
@@ -1806,6 +1806,8 @@
|
||||
"Destination Account Currency": "Moneda de la cuenta de destino",
|
||||
"Value Metric": "Métrica de valor",
|
||||
"Transaction Count": "Recuento de transacciones",
|
||||
"Active Transaction Days": "Active Transaction Days",
|
||||
"Transactions per Active Day": "Transactions per Active Day",
|
||||
"Expense / Income Ratio": "Expense / Income Ratio",
|
||||
"Savings Rate": "Savings Rate",
|
||||
"Average Amount": "Importe Medio",
|
||||
|
||||
@@ -1806,6 +1806,8 @@
|
||||
"Destination Account Currency": "Destination Account Currency",
|
||||
"Value Metric": "Value Metric",
|
||||
"Transaction Count": "Transaction Count",
|
||||
"Active Transaction Days": "Active Transaction Days",
|
||||
"Transactions per Active Day": "Transactions per Active Day",
|
||||
"Expense / Income Ratio": "Expense / Income Ratio",
|
||||
"Savings Rate": "Savings Rate",
|
||||
"Average Amount": "Average Amount",
|
||||
|
||||
@@ -1806,6 +1806,8 @@
|
||||
"Destination Account Currency": "Destination Account Currency",
|
||||
"Value Metric": "Value Metric",
|
||||
"Transaction Count": "Transaction Count",
|
||||
"Active Transaction Days": "Active Transaction Days",
|
||||
"Transactions per Active Day": "Transactions per Active Day",
|
||||
"Expense / Income Ratio": "Expense / Income Ratio",
|
||||
"Savings Rate": "Savings Rate",
|
||||
"Average Amount": "Average Amount",
|
||||
|
||||
@@ -1806,6 +1806,8 @@
|
||||
"Destination Account Currency": "Destination Account Currency",
|
||||
"Value Metric": "Value Metric",
|
||||
"Transaction Count": "Transaction Count",
|
||||
"Active Transaction Days": "Active Transaction Days",
|
||||
"Transactions per Active Day": "Transactions per Active Day",
|
||||
"Expense / Income Ratio": "Expense / Income Ratio",
|
||||
"Savings Rate": "Savings Rate",
|
||||
"Average Amount": "Average Amount",
|
||||
|
||||
@@ -1806,6 +1806,8 @@
|
||||
"Destination Account Currency": "Destination Account Currency",
|
||||
"Value Metric": "Value Metric",
|
||||
"Transaction Count": "Transaction Count",
|
||||
"Active Transaction Days": "Active Transaction Days",
|
||||
"Transactions per Active Day": "Transactions per Active Day",
|
||||
"Expense / Income Ratio": "Expense / Income Ratio",
|
||||
"Savings Rate": "Savings Rate",
|
||||
"Average Amount": "Average Amount",
|
||||
|
||||
@@ -1806,6 +1806,8 @@
|
||||
"Destination Account Currency": "목적지 계좌 통화",
|
||||
"Value Metric": "값 메트릭",
|
||||
"Transaction Count": "거래 수",
|
||||
"Active Transaction Days": "Active Transaction Days",
|
||||
"Transactions per Active Day": "Transactions per Active Day",
|
||||
"Expense / Income Ratio": "Expense / Income Ratio",
|
||||
"Savings Rate": "Savings Rate",
|
||||
"Average Amount": "평균 금액",
|
||||
|
||||
@@ -1806,6 +1806,8 @@
|
||||
"Destination Account Currency": "Destination Account Currency",
|
||||
"Value Metric": "Value Metric",
|
||||
"Transaction Count": "Transaction Count",
|
||||
"Active Transaction Days": "Active Transaction Days",
|
||||
"Transactions per Active Day": "Transactions per Active Day",
|
||||
"Expense / Income Ratio": "Expense / Income Ratio",
|
||||
"Savings Rate": "Savings Rate",
|
||||
"Average Amount": "Average Amount",
|
||||
|
||||
@@ -1806,6 +1806,8 @@
|
||||
"Destination Account Currency": "Moeda da Conta de Destino",
|
||||
"Value Metric": "Métrica de Valor",
|
||||
"Transaction Count": "Quantidade de Transações",
|
||||
"Active Transaction Days": "Active Transaction Days",
|
||||
"Transactions per Active Day": "Transactions per Active Day",
|
||||
"Expense / Income Ratio": "Expense / Income Ratio",
|
||||
"Savings Rate": "Savings Rate",
|
||||
"Average Amount": "Valor Médio",
|
||||
|
||||
@@ -1806,6 +1806,8 @@
|
||||
"Destination Account Currency": "Валюта целевого счёта",
|
||||
"Value Metric": "Метрика значения",
|
||||
"Transaction Count": "Количество транзакций",
|
||||
"Active Transaction Days": "Active Transaction Days",
|
||||
"Transactions per Active Day": "Transactions per Active Day",
|
||||
"Expense / Income Ratio": "Expense / Income Ratio",
|
||||
"Savings Rate": "Savings Rate",
|
||||
"Average Amount": "Средняя сумма",
|
||||
|
||||
@@ -1806,6 +1806,8 @@
|
||||
"Destination Account Currency": "Valuta ciljnega računa",
|
||||
"Value Metric": "Metrika vrednosti",
|
||||
"Transaction Count": "Število transakcij",
|
||||
"Active Transaction Days": "Active Transaction Days",
|
||||
"Transactions per Active Day": "Transactions per Active Day",
|
||||
"Expense / Income Ratio": "Expense / Income Ratio",
|
||||
"Savings Rate": "Savings Rate",
|
||||
"Average Amount": "Povprečni znesek",
|
||||
|
||||
@@ -1806,6 +1806,8 @@
|
||||
"Destination Account Currency": "இலக்கு கணக்கு நாணயம்",
|
||||
"Value Metric": "மதிப்பு அளவீடு",
|
||||
"Transaction Count": "பரிவர்த்தனை எண்ணிக்கை",
|
||||
"Active Transaction Days": "Active Transaction Days",
|
||||
"Transactions per Active Day": "Transactions per Active Day",
|
||||
"Expense / Income Ratio": "Expense / Income Ratio",
|
||||
"Savings Rate": "Savings Rate",
|
||||
"Average Amount": "சராசரி தொகை",
|
||||
|
||||
@@ -1806,6 +1806,8 @@
|
||||
"Destination Account Currency": "Destination Account Currency",
|
||||
"Value Metric": "Value Metric",
|
||||
"Transaction Count": "Transaction Count",
|
||||
"Active Transaction Days": "Active Transaction Days",
|
||||
"Transactions per Active Day": "Transactions per Active Day",
|
||||
"Expense / Income Ratio": "Expense / Income Ratio",
|
||||
"Savings Rate": "Savings Rate",
|
||||
"Average Amount": "Average Amount",
|
||||
|
||||
@@ -1806,6 +1806,8 @@
|
||||
"Destination Account Currency": "Destination Account Currency",
|
||||
"Value Metric": "Value Metric",
|
||||
"Transaction Count": "Transaction Count",
|
||||
"Active Transaction Days": "Active Transaction Days",
|
||||
"Transactions per Active Day": "Transactions per Active Day",
|
||||
"Expense / Income Ratio": "Expense / Income Ratio",
|
||||
"Savings Rate": "Savings Rate",
|
||||
"Average Amount": "Average Amount",
|
||||
|
||||
@@ -1806,6 +1806,8 @@
|
||||
"Destination Account Currency": "Destination Account Currency",
|
||||
"Value Metric": "Value Metric",
|
||||
"Transaction Count": "Transaction Count",
|
||||
"Active Transaction Days": "Active Transaction Days",
|
||||
"Transactions per Active Day": "Transactions per Active Day",
|
||||
"Expense / Income Ratio": "Expense / Income Ratio",
|
||||
"Savings Rate": "Savings Rate",
|
||||
"Average Amount": "Average Amount",
|
||||
|
||||
@@ -1806,6 +1806,8 @@
|
||||
"Destination Account Currency": "Destination Account Currency",
|
||||
"Value Metric": "Value Metric",
|
||||
"Transaction Count": "Transaction Count",
|
||||
"Active Transaction Days": "Active Transaction Days",
|
||||
"Transactions per Active Day": "Transactions per Active Day",
|
||||
"Expense / Income Ratio": "Expense / Income Ratio",
|
||||
"Savings Rate": "Savings Rate",
|
||||
"Average Amount": "Average Amount",
|
||||
|
||||
@@ -1806,6 +1806,8 @@
|
||||
"Destination Account Currency": "目标账户货币",
|
||||
"Value Metric": "值类型",
|
||||
"Transaction Count": "交易数量",
|
||||
"Active Transaction Days": "活跃交易日",
|
||||
"Transactions per Active Day": "每活跃日交易数量",
|
||||
"Expense / Income Ratio": "支出/收入比",
|
||||
"Savings Rate": "储蓄率",
|
||||
"Average Amount": "平均金额",
|
||||
|
||||
@@ -1806,6 +1806,8 @@
|
||||
"Destination Account Currency": "目標帳戶貨幣",
|
||||
"Value Metric": "值類型",
|
||||
"Transaction Count": "交易數量",
|
||||
"Active Transaction Days": "活躍交易日數",
|
||||
"Transactions per Active Day": "每活躍日交易數",
|
||||
"Expense / Income Ratio": "支出/收入比率",
|
||||
"Savings Rate": "儲蓄率",
|
||||
"Average Amount": "平均金額",
|
||||
|
||||
@@ -43,6 +43,7 @@ import {
|
||||
isNumber,
|
||||
isInteger,
|
||||
isEquals,
|
||||
getObjectOwnFieldCount
|
||||
} from '@/lib/common.ts';
|
||||
import {
|
||||
median,
|
||||
@@ -800,6 +801,11 @@ export const useExplorersStore = defineStore('explorers', () => {
|
||||
const defaultCurrency = userStore.currentUserDefaultCurrency;
|
||||
const result: CategoriedTransactionExplorerData[] = [];
|
||||
const categoriedDataMap = categoriedTransactions.value;
|
||||
let needCalculateDailyTransactionCount: boolean = false;
|
||||
|
||||
if (valueMetric === TransactionExplorerValueMetric.ActiveTransactionDays || valueMetric === TransactionExplorerValueMetric.TransactionsPerDay) {
|
||||
needCalculateDailyTransactionCount = true;
|
||||
}
|
||||
|
||||
for (const categoriedTransactions of values(categoriedDataMap)) {
|
||||
const dataItems: CategoriedTransactionExplorerDataItem[] = [];
|
||||
@@ -824,6 +830,7 @@ export const useExplorersStore = defineStore('explorers', () => {
|
||||
}
|
||||
|
||||
for (const seriesTransactions of values(allSeriesTransactions)) {
|
||||
const transactionDateMapCount: Record<string, number> = {};
|
||||
const allSourceAmountsInDefaultCurrency: number[] = [];
|
||||
let totalSourceAmountSumInDefaultCurrency: number = 0;
|
||||
let totalSourceIncomeAmountSumInDefaultCurrency: number = 0;
|
||||
@@ -844,6 +851,23 @@ export const useExplorersStore = defineStore('explorers', () => {
|
||||
}
|
||||
}
|
||||
|
||||
if (needCalculateDailyTransactionCount) {
|
||||
let transactionTimeUtfOffset: number | undefined = undefined;
|
||||
|
||||
if (currentInsightsExplorer.value.timezoneUsedForDateRange === TimezoneTypeForStatistics.TransactionTimezone.type) {
|
||||
transactionTimeUtfOffset = transaction.utcOffset;
|
||||
}
|
||||
|
||||
const transactionDateTime: DateTime = isDefined(transactionTimeUtfOffset) ? parseDateTimeFromUnixTimeWithTimezoneOffset(transaction.time, transactionTimeUtfOffset) : parseDateTimeFromUnixTime(transaction.time);
|
||||
const transactionYearMonthDay: string = transactionDateTime.getGregorianCalendarYearDashMonthDashDay();
|
||||
|
||||
if (transactionDateMapCount[transactionYearMonthDay]) {
|
||||
transactionDateMapCount[transactionYearMonthDay]++;
|
||||
} else {
|
||||
transactionDateMapCount[transactionYearMonthDay] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
allSourceAmountsInDefaultCurrency.push(amountInDefaultCurrency);
|
||||
totalSourceAmountSumInDefaultCurrency += amountInDefaultCurrency;
|
||||
|
||||
@@ -866,6 +890,11 @@ export const useExplorersStore = defineStore('explorers', () => {
|
||||
|
||||
if (valueMetric === TransactionExplorerValueMetric.TransactionCount) {
|
||||
value = allSourceAmountsInDefaultCurrency.length;
|
||||
} else if (valueMetric === TransactionExplorerValueMetric.ActiveTransactionDays) {
|
||||
value = getObjectOwnFieldCount(transactionDateMapCount);
|
||||
} else if (valueMetric === TransactionExplorerValueMetric.TransactionsPerDay) {
|
||||
const activeDays = getObjectOwnFieldCount(transactionDateMapCount);
|
||||
value = activeDays > 0 ? allSourceAmountsInDefaultCurrency.length / activeDays : 0;
|
||||
} else if (valueMetric === TransactionExplorerValueMetric.SourceIncomeAmountSum) {
|
||||
value = totalSourceIncomeAmountSumInDefaultCurrency;
|
||||
} else if (valueMetric === TransactionExplorerValueMetric.SourceExpenseAmountSum) {
|
||||
|
||||
Reference in New Issue
Block a user