mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-17 16:24:25 +08:00
migrate consts/statistics.js to ts
This commit is contained in:
@@ -129,7 +129,7 @@ import { mapStores } from 'pinia';
|
||||
import { useSettingsStore } from '@/stores/setting.js';
|
||||
|
||||
import { DateRangeScene } from '@/core/datetime.ts';
|
||||
import statisticsConstants from '@/consts/statistics.js';
|
||||
import { StatisticsAnalysisType } from '@/core/statistics.ts';
|
||||
|
||||
import AccountFilterSettingsCard from '@/views/desktop/common/cards/AccountFilterSettingsCard.vue';
|
||||
import CategoryFilterSettingsCard from '@/views/desktop/common/cards/CategoryFilterSettingsCard.vue';
|
||||
@@ -142,7 +142,7 @@ export default {
|
||||
computed: {
|
||||
...mapStores(useSettingsStore),
|
||||
allChartDataTypes() {
|
||||
return this.$locale.getAllStatisticsChartDataTypes(statisticsConstants.allAnalysisTypes.CategoricalAnalysis);
|
||||
return this.$locale.getAllStatisticsChartDataTypes(StatisticsAnalysisType.CategoricalAnalysis);
|
||||
},
|
||||
allTimezoneTypesUsedForStatistics() {
|
||||
return this.$locale.getAllTimezoneTypesUsedForStatistics();
|
||||
|
||||
@@ -31,14 +31,14 @@
|
||||
class="mt-2"
|
||||
density="compact"
|
||||
:disabled="loading"
|
||||
:items="allSortingTypesArray"
|
||||
:items="allSortingTypes"
|
||||
v-model="querySortingType"
|
||||
/>
|
||||
</div>
|
||||
<v-tabs show-arrows class="my-4" direction="vertical"
|
||||
:disabled="loading" v-model="queryChartDataType">
|
||||
<v-tab class="tab-text-truncate" :key="dataType.type" :value="dataType.type"
|
||||
v-for="dataType in allChartDataTypes" v-show="dataType.availableAnalysisTypes[queryAnalysisType]">
|
||||
v-for="dataType in allChartDataTypes" v-show="dataType.isAvailableAnalysisType(queryAnalysisType)">
|
||||
<span class="text-truncate">{{ $t(dataType.name) }}</span>
|
||||
<v-tooltip activator="parent" location="right">{{ $t(dataType.name) }}</v-tooltip>
|
||||
</v-tab>
|
||||
@@ -97,7 +97,7 @@
|
||||
<v-list-item class="cursor-pointer" :key="aggregationType.type" :value="aggregationType.type"
|
||||
:append-icon="(trendDateAggregationType === aggregationType.type ? icons.check : null)"
|
||||
:title="aggregationType.displayName"
|
||||
v-for="aggregationType in allDateAggregationTypesArray"
|
||||
v-for="aggregationType in allDateAggregationTypes"
|
||||
@click="setTrendDateAggregationType(aggregationType.type)">
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
@@ -155,7 +155,7 @@
|
||||
<span class="statistics-subtitle statistics-overview-empty-tip">{{ $t('No transaction data') }}</span>
|
||||
</v-card-text>
|
||||
|
||||
<v-card-text :class="{ 'readonly': loading }" v-if="queryAnalysisType === allAnalysisTypes.CategoricalAnalysis && query.categoricalChartType === allCategoricalChartTypes.Pie">
|
||||
<v-card-text :class="{ 'readonly': loading }" v-if="queryAnalysisType === allAnalysisTypes.CategoricalAnalysis && query.categoricalChartType === allCategoricalChartTypes.Pie.type">
|
||||
<pie-chart
|
||||
:items="[
|
||||
{id: '1', name: '---', value: 60, color: '7c7c7f'},
|
||||
@@ -185,7 +185,7 @@
|
||||
/>
|
||||
</v-card-text>
|
||||
|
||||
<v-card-text :class="{ 'readonly': loading }" v-if="queryAnalysisType === allAnalysisTypes.CategoricalAnalysis && query.categoricalChartType === allCategoricalChartTypes.Bar">
|
||||
<v-card-text :class="{ 'readonly': loading }" v-if="queryAnalysisType === allAnalysisTypes.CategoricalAnalysis && query.categoricalChartType === allCategoricalChartTypes.Bar.type">
|
||||
<v-list rounded lines="two" v-if="initing">
|
||||
<template :key="itemIdx" v-for="itemIdx in [ 1, 2, 3 ]">
|
||||
<v-list-item class="pl-0">
|
||||
@@ -325,7 +325,13 @@ import { useStatisticsStore } from '@/stores/statistics.js';
|
||||
|
||||
import { DateRangeScene, DateRange } from '@/core/datetime.ts';
|
||||
import { ThemeType } from '@/core/theme.ts';
|
||||
import statisticsConstants from '@/consts/statistics.js';
|
||||
import {
|
||||
StatisticsAnalysisType,
|
||||
CategoricalChartType,
|
||||
ChartDataType,
|
||||
ChartSortingType,
|
||||
ChartDateAggregationType
|
||||
} from '@/core/statistics.ts';
|
||||
import {
|
||||
isDefined,
|
||||
limitText,
|
||||
@@ -341,7 +347,6 @@ import {
|
||||
getDateTypeByDateRange,
|
||||
getDateRangeByDateType
|
||||
} from '@/lib/datetime.ts';
|
||||
import { isChartDataTypeAvailableForAnalysisType } from '@/lib/statistics.js';
|
||||
|
||||
import {
|
||||
mdiCheck,
|
||||
@@ -390,8 +395,8 @@ export default {
|
||||
loading: true,
|
||||
alwaysShowNav: mdAndUp.value,
|
||||
showNav: mdAndUp.value,
|
||||
analysisType: statisticsConstants.allAnalysisTypes.CategoricalAnalysis,
|
||||
trendDateAggregationType: statisticsConstants.defaultDateAggregationType,
|
||||
analysisType: StatisticsAnalysisType.CategoricalAnalysis,
|
||||
trendDateAggregationType: ChartDateAggregationType.Default.type,
|
||||
showCustomDateRangeDialog: false,
|
||||
showCustomMonthRangeDialog: false,
|
||||
showFilterAccountDialog: false,
|
||||
@@ -439,9 +444,9 @@ export default {
|
||||
},
|
||||
queryChartType: {
|
||||
get: function () {
|
||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
return this.query.categoricalChartType;
|
||||
} else if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.queryAnalysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
return this.query.trendChartType;
|
||||
} else {
|
||||
return null;
|
||||
@@ -468,69 +473,66 @@ export default {
|
||||
}
|
||||
},
|
||||
queryDateType() {
|
||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
return this.query.categoricalChartDateType;
|
||||
} else if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.queryAnalysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
return this.query.trendChartDateType;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
queryTrendDateAggregationTypeName() {
|
||||
return getNameByKeyValue(this.allDateAggregationTypesArray, this.trendDateAggregationType, 'type', 'displayName', '');
|
||||
return getNameByKeyValue(this.allDateAggregationTypes, this.trendDateAggregationType, 'type', 'displayName', '');
|
||||
},
|
||||
queryStartTime() {
|
||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
return this.$locale.formatUnixTimeToLongDateTime(this.userStore, this.query.categoricalChartStartTime);
|
||||
} else if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.queryAnalysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
return this.$locale.formatUnixTimeToLongYearMonth(this.userStore, getYearMonthFirstUnixTime(this.query.trendChartStartYearMonth));
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
queryEndTime() {
|
||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
return this.$locale.formatUnixTimeToLongDateTime(this.userStore, this.query.categoricalChartEndTime);
|
||||
} else if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.queryAnalysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
return this.$locale.formatUnixTimeToLongYearMonth(this.userStore, getYearMonthLastUnixTime(this.query.trendChartEndYearMonth));
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
allAnalysisTypes() {
|
||||
return statisticsConstants.allAnalysisTypes;
|
||||
return StatisticsAnalysisType;
|
||||
},
|
||||
allChartTypes() {
|
||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
return this.$locale.getAllCategoricalChartTypes();
|
||||
} else if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.queryAnalysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
return this.$locale.getAllTrendChartTypes();
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
allCategoricalChartTypes() {
|
||||
return statisticsConstants.allCategoricalChartTypes;
|
||||
return CategoricalChartType.all();
|
||||
},
|
||||
allChartDataTypes() {
|
||||
return statisticsConstants.allChartDataTypes;
|
||||
return ChartDataType.all();
|
||||
},
|
||||
allSortingTypes() {
|
||||
return statisticsConstants.allSortingTypes;
|
||||
},
|
||||
allSortingTypesArray() {
|
||||
return this.$locale.getAllStatisticsSortingTypes();
|
||||
},
|
||||
allDateAggregationTypesArray() {
|
||||
allDateAggregationTypes() {
|
||||
return this.$locale.getAllStatisticsDateAggregationTypes();
|
||||
},
|
||||
allDateRanges() {
|
||||
return DateRange.all();
|
||||
},
|
||||
allDateRangesArray() {
|
||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
return this.$locale.getAllDateRanges(DateRangeScene.Normal, true);
|
||||
} else if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.queryAnalysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
return this.$locale.getAllDateRanges(DateRangeScene.TrendAnalysis, true);
|
||||
} else {
|
||||
return [];
|
||||
@@ -540,17 +542,17 @@ export default {
|
||||
return this.settingsStore.appSettings.showAccountBalance;
|
||||
},
|
||||
totalAmountName() {
|
||||
if (this.queryChartDataType === this.allChartDataTypes.IncomeByAccount.type
|
||||
|| this.queryChartDataType === this.allChartDataTypes.IncomeByPrimaryCategory.type
|
||||
|| this.queryChartDataType === this.allChartDataTypes.IncomeBySecondaryCategory.type) {
|
||||
if (this.queryChartDataType === ChartDataType.IncomeByAccount.type
|
||||
|| this.queryChartDataType === ChartDataType.IncomeByPrimaryCategory.type
|
||||
|| this.queryChartDataType === ChartDataType.IncomeBySecondaryCategory.type) {
|
||||
return this.$t('Total Income');
|
||||
} else if (this.queryChartDataType === this.allChartDataTypes.ExpenseByAccount.type
|
||||
|| this.queryChartDataType === this.allChartDataTypes.ExpenseByPrimaryCategory.type
|
||||
|| this.queryChartDataType === this.allChartDataTypes.ExpenseBySecondaryCategory.type) {
|
||||
} else if (this.queryChartDataType === ChartDataType.ExpenseByAccount.type
|
||||
|| this.queryChartDataType === ChartDataType.ExpenseByPrimaryCategory.type
|
||||
|| this.queryChartDataType === ChartDataType.ExpenseBySecondaryCategory.type) {
|
||||
return this.$t('Total Expense');
|
||||
} else if (this.queryChartDataType === this.allChartDataTypes.AccountTotalAssets.type) {
|
||||
} else if (this.queryChartDataType === ChartDataType.AccountTotalAssets.type) {
|
||||
return this.$t('Total Assets');
|
||||
} else if (this.queryChartDataType === this.allChartDataTypes.AccountTotalLiabilities.type) {
|
||||
} else if (this.queryChartDataType === ChartDataType.AccountTotalLiabilities.type) {
|
||||
return this.$t('Total Liabilities');
|
||||
}
|
||||
|
||||
@@ -563,23 +565,23 @@ export default {
|
||||
return this.statisticsStore.trendsAnalysisData;
|
||||
},
|
||||
translateNameInTrendsChart() {
|
||||
return this.queryChartDataType === this.allChartDataTypes.TotalExpense.type ||
|
||||
this.queryChartDataType === this.allChartDataTypes.TotalIncome.type ||
|
||||
this.queryChartDataType === this.allChartDataTypes.TotalBalance.type;
|
||||
return this.queryChartDataType === ChartDataType.TotalExpense.type ||
|
||||
this.queryChartDataType === ChartDataType.TotalIncome.type ||
|
||||
this.queryChartDataType === ChartDataType.TotalBalance.type;
|
||||
},
|
||||
showTotalAmountInTrendsChart() {
|
||||
return this.queryChartDataType !== this.allChartDataTypes.TotalExpense.type &&
|
||||
this.queryChartDataType !== this.allChartDataTypes.TotalIncome.type &&
|
||||
this.queryChartDataType !== this.allChartDataTypes.TotalBalance.type;
|
||||
return this.queryChartDataType !== ChartDataType.TotalExpense.type &&
|
||||
this.queryChartDataType !== ChartDataType.TotalIncome.type &&
|
||||
this.queryChartDataType !== ChartDataType.TotalBalance.type;
|
||||
},
|
||||
statisticsTextColor() {
|
||||
if (this.queryChartDataType === this.allChartDataTypes.ExpenseByAccount.type ||
|
||||
this.queryChartDataType === this.allChartDataTypes.ExpenseByPrimaryCategory.type ||
|
||||
this.queryChartDataType === this.allChartDataTypes.ExpenseBySecondaryCategory.type) {
|
||||
if (this.queryChartDataType === ChartDataType.ExpenseByAccount.type ||
|
||||
this.queryChartDataType === ChartDataType.ExpenseByPrimaryCategory.type ||
|
||||
this.queryChartDataType === ChartDataType.ExpenseBySecondaryCategory.type) {
|
||||
return 'text-expense';
|
||||
} else if (this.queryChartDataType === this.allChartDataTypes.IncomeByAccount.type ||
|
||||
this.queryChartDataType === this.allChartDataTypes.IncomeByPrimaryCategory.type ||
|
||||
this.queryChartDataType === this.allChartDataTypes.IncomeBySecondaryCategory.type) {
|
||||
} else if (this.queryChartDataType === ChartDataType.IncomeByAccount.type ||
|
||||
this.queryChartDataType === ChartDataType.IncomeByPrimaryCategory.type ||
|
||||
this.queryChartDataType === ChartDataType.IncomeBySecondaryCategory.type) {
|
||||
return 'text-income';
|
||||
} else {
|
||||
return 'text-default';
|
||||
@@ -587,7 +589,7 @@ export default {
|
||||
},
|
||||
showAmountInChart() {
|
||||
if (!this.showAccountBalance
|
||||
&& (this.queryChartDataType === this.allChartDataTypes.AccountTotalAssets.type || this.queryChartDataType === this.allChartDataTypes.AccountTotalLiabilities.type)) {
|
||||
&& (this.queryChartDataType === ChartDataType.AccountTotalAssets.type || this.queryChartDataType === ChartDataType.AccountTotalLiabilities.type)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -662,7 +664,7 @@ export default {
|
||||
sortingType: query.sortingType ? parseInt(query.sortingType) : undefined
|
||||
};
|
||||
|
||||
if (query.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis.toString()) {
|
||||
if (query.analysisType === StatisticsAnalysisType.CategoricalAnalysis.toString()) {
|
||||
filter.categoricalChartType = query.chartType ? parseInt(query.chartType) : undefined;
|
||||
filter.categoricalChartDateType = query.chartDateType ? parseInt(query.chartDateType) : undefined;
|
||||
filter.categoricalChartStartTime = query.startTime ? parseInt(query.startTime) : undefined;
|
||||
@@ -678,10 +680,10 @@ export default {
|
||||
}
|
||||
|
||||
if (query.analysisType !== self.queryAnalysisType.toString()) {
|
||||
self.analysisType = statisticsConstants.allAnalysisTypes.CategoricalAnalysis;
|
||||
self.analysisType = StatisticsAnalysisType.CategoricalAnalysis;
|
||||
needReload = true;
|
||||
}
|
||||
} else if (query.analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis.toString()) {
|
||||
} else if (query.analysisType === StatisticsAnalysisType.TrendAnalysis.toString()) {
|
||||
filter.trendChartType = query.chartType ? parseInt(query.chartType) : undefined;
|
||||
filter.trendChartDateType = query.chartDateType ? parseInt(query.chartDateType) : undefined;
|
||||
filter.trendChartStartYearMonth = query.startTime;
|
||||
@@ -697,7 +699,7 @@ export default {
|
||||
}
|
||||
|
||||
if (query.analysisType !== self.queryAnalysisType.toString()) {
|
||||
self.analysisType = statisticsConstants.allAnalysisTypes.TrendAnalysis;
|
||||
self.analysisType = StatisticsAnalysisType.TrendAnalysis;
|
||||
needReload = true;
|
||||
}
|
||||
|
||||
@@ -707,7 +709,7 @@ export default {
|
||||
}
|
||||
|
||||
if (!isDefined(query.analysisType)) {
|
||||
self.analysisType = statisticsConstants.allAnalysisTypes.CategoricalAnalysis;
|
||||
self.analysisType = StatisticsAnalysisType.CategoricalAnalysis;
|
||||
filter = null;
|
||||
}
|
||||
|
||||
@@ -723,11 +725,11 @@ export default {
|
||||
self.accountsStore.loadAllAccounts({force: false}),
|
||||
self.transactionCategoriesStore.loadAllCategories({force: false})
|
||||
]).then(() => {
|
||||
if (self.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (self.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
return self.statisticsStore.loadCategoricalAnalysis({
|
||||
force: false
|
||||
});
|
||||
} else if (self.queryAnalysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (self.queryAnalysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
return self.statisticsStore.loadTrendAnalysis({
|
||||
force: false
|
||||
});
|
||||
@@ -750,26 +752,26 @@ export default {
|
||||
|
||||
self.loading = true;
|
||||
|
||||
if (self.queryChartDataType === self.allChartDataTypes.ExpenseByAccount.type ||
|
||||
self.queryChartDataType === self.allChartDataTypes.ExpenseByPrimaryCategory.type ||
|
||||
self.queryChartDataType === self.allChartDataTypes.ExpenseBySecondaryCategory.type ||
|
||||
self.queryChartDataType === self.allChartDataTypes.IncomeByAccount.type ||
|
||||
self.queryChartDataType === self.allChartDataTypes.IncomeByPrimaryCategory.type ||
|
||||
self.queryChartDataType === self.allChartDataTypes.IncomeBySecondaryCategory.type ||
|
||||
self.queryChartDataType === self.allChartDataTypes.TotalExpense.type ||
|
||||
self.queryChartDataType === self.allChartDataTypes.TotalIncome.type ||
|
||||
self.queryChartDataType === self.allChartDataTypes.TotalBalance.type) {
|
||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (self.queryChartDataType === ChartDataType.ExpenseByAccount.type ||
|
||||
self.queryChartDataType === ChartDataType.ExpenseByPrimaryCategory.type ||
|
||||
self.queryChartDataType === ChartDataType.ExpenseBySecondaryCategory.type ||
|
||||
self.queryChartDataType === ChartDataType.IncomeByAccount.type ||
|
||||
self.queryChartDataType === ChartDataType.IncomeByPrimaryCategory.type ||
|
||||
self.queryChartDataType === ChartDataType.IncomeBySecondaryCategory.type ||
|
||||
self.queryChartDataType === ChartDataType.TotalExpense.type ||
|
||||
self.queryChartDataType === ChartDataType.TotalIncome.type ||
|
||||
self.queryChartDataType === ChartDataType.TotalBalance.type) {
|
||||
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
dispatchPromise = self.statisticsStore.loadCategoricalAnalysis({
|
||||
force: force
|
||||
});
|
||||
} else if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.queryAnalysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
dispatchPromise = self.statisticsStore.loadTrendAnalysis({
|
||||
force: force
|
||||
});
|
||||
}
|
||||
} else if (self.queryChartDataType === self.allChartDataTypes.AccountTotalAssets.type ||
|
||||
self.queryChartDataType === self.allChartDataTypes.AccountTotalLiabilities.type) {
|
||||
} else if (self.queryChartDataType === ChartDataType.AccountTotalAssets.type ||
|
||||
self.queryChartDataType === ChartDataType.AccountTotalLiabilities.type) {
|
||||
dispatchPromise = self.accountsStore.loadAllAccounts({
|
||||
force: force
|
||||
});
|
||||
@@ -798,14 +800,14 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isChartDataTypeAvailableForAnalysisType(this.queryChartDataType, analysisType)) {
|
||||
if (!ChartDataType.isAvailableForAnalysisType(this.queryChartDataType, analysisType)) {
|
||||
this.statisticsStore.updateTransactionStatisticsFilter({
|
||||
chartDataType: statisticsConstants.defaultChartDataType
|
||||
chartDataType: ChartDataType.Default.type
|
||||
});
|
||||
}
|
||||
|
||||
if (this.analysisType !== statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
this.trendDateAggregationType = statisticsConstants.allDateAggregationTypes.Month.type;
|
||||
if (this.analysisType !== StatisticsAnalysisType.TrendAnalysis) {
|
||||
this.trendDateAggregationType = ChartDateAggregationType.Month.type;
|
||||
}
|
||||
|
||||
this.analysisType = analysisType;
|
||||
@@ -816,11 +818,11 @@ export default {
|
||||
setChartType(chartType) {
|
||||
let changed = false;
|
||||
|
||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
||||
categoricalChartType: chartType
|
||||
});
|
||||
} else if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.queryAnalysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
||||
trendChartType: chartType
|
||||
});
|
||||
@@ -840,7 +842,7 @@ export default {
|
||||
}
|
||||
},
|
||||
setSortingType(sortingType) {
|
||||
if (sortingType < this.allSortingTypes.Amount.type || sortingType > this.allSortingTypes.Name.type) {
|
||||
if (sortingType < ChartSortingType.Amount.type || sortingType > ChartSortingType.Name.type) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -861,14 +863,14 @@ export default {
|
||||
}
|
||||
},
|
||||
setDateFilter(dateType) {
|
||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
if (dateType === this.allDateRanges.Custom.type) { // Custom
|
||||
this.showCustomDateRangeDialog = true;
|
||||
return;
|
||||
} else if (this.query.categoricalChartDateType === dateType) {
|
||||
return;
|
||||
}
|
||||
} else if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.queryAnalysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
if (dateType === this.allDateRanges.Custom.type) { // Custom
|
||||
this.showCustomMonthRangeDialog = true;
|
||||
return;
|
||||
@@ -885,13 +887,13 @@ export default {
|
||||
|
||||
let changed = false;
|
||||
|
||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
||||
categoricalChartDateType: dateRange.dateType,
|
||||
categoricalChartStartTime: dateRange.minTime,
|
||||
categoricalChartEndTime: dateRange.maxTime
|
||||
});
|
||||
} else if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.queryAnalysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
||||
trendChartDateType: dateRange.dateType,
|
||||
trendChartStartYearMonth: getYearAndMonthFromUnixTime(dateRange.minTime),
|
||||
@@ -912,7 +914,7 @@ export default {
|
||||
|
||||
let changed = false;
|
||||
|
||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
const chartDateType = getDateTypeByDateRange(startTime, endTime, this.firstDayOfWeek, DateRangeScene.Normal);
|
||||
|
||||
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
||||
@@ -922,7 +924,7 @@ export default {
|
||||
});
|
||||
|
||||
this.showCustomDateRangeDialog = false;
|
||||
} else if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.queryAnalysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
const chartDateType = getDateTypeByDateRange(getYearMonthFirstUnixTime(startTime), getYearMonthLastUnixTime(endTime), this.firstDayOfWeek, DateRangeScene.TrendAnalysis);
|
||||
|
||||
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
||||
@@ -941,22 +943,22 @@ export default {
|
||||
}
|
||||
},
|
||||
showCustomDateRange() {
|
||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
return this.query.categoricalChartDateType === this.allDateRanges.Custom.type && this.query.categoricalChartStartTime && this.query.categoricalChartEndTime;
|
||||
} else if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.queryAnalysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
return this.query.trendChartDateType === this.allDateRanges.Custom.type && this.query.trendChartStartYearMonth && this.query.trendChartEndYearMonth;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
canShiftDateRange() {
|
||||
if (this.queryChartDataType === this.allChartDataTypes.AccountTotalAssets.type || this.queryChartDataType === this.allChartDataTypes.AccountTotalLiabilities.type) {
|
||||
if (this.queryChartDataType === ChartDataType.AccountTotalAssets.type || this.queryChartDataType === ChartDataType.AccountTotalLiabilities.type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
return this.query.categoricalChartDateType !== this.allDateRanges.All.type;
|
||||
} else if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.queryAnalysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
return this.query.trendChartDateType !== this.allDateRanges.All.type;
|
||||
} else {
|
||||
return false;
|
||||
@@ -969,7 +971,7 @@ export default {
|
||||
|
||||
let changed = false;
|
||||
|
||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
const newDateRange = getShiftedDateRangeAndDateType(this.query.categoricalChartStartTime, this.query.categoricalChartEndTime, scale, this.firstDayOfWeek, DateRangeScene.Normal);
|
||||
|
||||
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
||||
@@ -977,7 +979,7 @@ export default {
|
||||
categoricalChartStartTime: newDateRange.minTime,
|
||||
categoricalChartEndTime: newDateRange.maxTime
|
||||
});
|
||||
} else if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.queryAnalysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
const newDateRange = getShiftedDateRangeAndDateType(getYearMonthFirstUnixTime(this.query.trendChartStartYearMonth), getYearMonthLastUnixTime(this.query.trendChartEndYearMonth), scale, this.firstDayOfWeek, DateRangeScene.TrendAnalysis);
|
||||
|
||||
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
||||
@@ -994,14 +996,14 @@ export default {
|
||||
}
|
||||
},
|
||||
dateRangeName() {
|
||||
if (this.queryChartDataType === this.allChartDataTypes.AccountTotalAssets.type ||
|
||||
this.queryChartDataType === this.allChartDataTypes.AccountTotalLiabilities.type) {
|
||||
if (this.queryChartDataType === ChartDataType.AccountTotalAssets.type ||
|
||||
this.queryChartDataType === ChartDataType.AccountTotalLiabilities.type) {
|
||||
return this.$t(this.allDateRanges.All.name);
|
||||
}
|
||||
|
||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
return this.$locale.getDateRangeDisplayName(this.userStore, this.query.categoricalChartDateType, this.query.categoricalChartStartTime, this.query.categoricalChartEndTime);
|
||||
} else if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.queryAnalysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
return this.$locale.getDateRangeDisplayName(this.userStore, this.query.trendChartDateType, getYearMonthFirstUnixTime(this.query.trendChartStartYearMonth), getYearMonthLastUnixTime(this.query.trendChartEndYearMonth));
|
||||
} else {
|
||||
return '';
|
||||
@@ -1044,8 +1046,8 @@ export default {
|
||||
amount = this.getDisplayCurrency(amount, currency);
|
||||
|
||||
if (!this.showAccountBalance
|
||||
&& (this.queryChartDataType === this.allChartDataTypes.AccountTotalAssets.type
|
||||
|| this.queryChartDataType === this.allChartDataTypes.AccountTotalLiabilities.type)
|
||||
&& (this.queryChartDataType === ChartDataType.AccountTotalAssets.type
|
||||
|| this.queryChartDataType === ChartDataType.AccountTotalLiabilities.type)
|
||||
) {
|
||||
return '***';
|
||||
}
|
||||
|
||||
@@ -64,16 +64,6 @@
|
||||
|
||||
<f7-block-title>{{ $t('Trend Analysis Settings') }}</f7-block-title>
|
||||
<f7-list strong inset dividers>
|
||||
<!-- <f7-list-item-->
|
||||
<!-- :title="$t('Default Chart Type')"-->
|
||||
<!-- smart-select :smart-select-params="{ openIn: 'popup', popupPush: true, closeOnSelect: true, scrollToSelectedItem: true, searchbar: true, searchbarPlaceholder: $t('Chart Type'), searchbarDisableText: $t('Cancel'), appendSearchbarNotFound: $t('No results'), popupCloseLinkText: $t('Done') }">-->
|
||||
<!-- <select v-model="defaultTrendChartType">-->
|
||||
<!-- <option :value="chartType.type"-->
|
||||
<!-- :key="chartType.type"-->
|
||||
<!-- v-for="chartType in allTrendChartTypes">{{ chartType.displayName }}</option>-->
|
||||
<!-- </select>-->
|
||||
<!-- </f7-list-item>-->
|
||||
|
||||
<f7-list-item
|
||||
:title="$t('Default Date Range')"
|
||||
smart-select :smart-select-params="{ openIn: 'popup', popupPush: true, closeOnSelect: true, scrollToSelectedItem: true, searchbar: true, searchbarPlaceholder: $t('Date Range'), searchbarDisableText: $t('Cancel'), appendSearchbarNotFound: $t('No results'), popupCloseLinkText: $t('Done') }">
|
||||
@@ -92,13 +82,13 @@ import { mapStores } from 'pinia';
|
||||
import { useSettingsStore } from '@/stores/setting.js';
|
||||
|
||||
import { DateRangeScene } from '@/core/datetime.ts';
|
||||
import statisticsConstants from '@/consts/statistics.js';
|
||||
import { StatisticsAnalysisType } from '@/core/statistics.ts';
|
||||
|
||||
export default {
|
||||
computed: {
|
||||
...mapStores(useSettingsStore),
|
||||
allChartDataTypes() {
|
||||
return this.$locale.getAllStatisticsChartDataTypes(statisticsConstants.allAnalysisTypes.CategoricalAnalysis);
|
||||
return this.$locale.getAllStatisticsChartDataTypes(StatisticsAnalysisType.CategoricalAnalysis);
|
||||
},
|
||||
allTimezoneTypesUsedForStatistics() {
|
||||
return this.$locale.getAllTimezoneTypesUsedForStatistics();
|
||||
@@ -112,9 +102,6 @@ export default {
|
||||
allCategoricalChartDateRanges() {
|
||||
return this.$locale.getAllDateRanges(DateRangeScene.Normal, false);
|
||||
},
|
||||
allTrendChartTypes() {
|
||||
return this.$locale.getAllTrendChartTypes();
|
||||
},
|
||||
allTrendChartDateRanges() {
|
||||
return this.$locale.getAllDateRanges(DateRangeScene.TrendAnalysis, false);
|
||||
},
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
:class="{ 'list-item-selected': analysisType === allAnalysisTypes.CategoricalAnalysis && query.chartDataType === dataType.type }"
|
||||
:key="dataType.type"
|
||||
v-for="dataType in allChartDataTypes"
|
||||
v-show="dataType.availableAnalysisTypes[allAnalysisTypes.CategoricalAnalysis]"
|
||||
v-show="dataType.isAvailableAnalysisType(allAnalysisTypes.CategoricalAnalysis)"
|
||||
@click="setChartDataType(allAnalysisTypes.CategoricalAnalysis, dataType.type)">
|
||||
<template #after>
|
||||
<f7-icon class="list-item-checked-icon" f7="checkmark_alt" v-if="analysisType === allAnalysisTypes.CategoricalAnalysis && query.chartDataType === dataType.type"></f7-icon>
|
||||
@@ -36,7 +36,7 @@
|
||||
:class="{ 'list-item-selected': analysisType === allAnalysisTypes.TrendAnalysis && query.chartDataType === dataType.type }"
|
||||
:key="dataType.type"
|
||||
v-for="dataType in allChartDataTypes"
|
||||
v-show="dataType.availableAnalysisTypes[allAnalysisTypes.TrendAnalysis]"
|
||||
v-show="dataType.isAvailableAnalysisType(allAnalysisTypes.TrendAnalysis)"
|
||||
@click="setChartDataType(allAnalysisTypes.TrendAnalysis, dataType.type)">
|
||||
<template #after>
|
||||
<f7-icon class="list-item-checked-icon" f7="checkmark_alt" v-if="analysisType === allAnalysisTypes.TrendAnalysis && query.chartDataType === dataType.type"></f7-icon>
|
||||
@@ -46,7 +46,7 @@
|
||||
</f7-list>
|
||||
</f7-popover>
|
||||
|
||||
<f7-card v-if="analysisType === allAnalysisTypes.CategoricalAnalysis && query.categoricalChartType === allCategoricalChartTypes.Pie">
|
||||
<f7-card v-if="analysisType === allAnalysisTypes.CategoricalAnalysis && query.categoricalChartType === allCategoricalChartTypes.Pie.type">
|
||||
<f7-card-header class="no-border display-block">
|
||||
<div class="statistics-chart-header full-line text-align-right">
|
||||
<span style="margin-right: 4px;">{{ $t('Sort by') }}</span>
|
||||
@@ -94,7 +94,7 @@
|
||||
</f7-card-content>
|
||||
</f7-card>
|
||||
|
||||
<f7-card v-else-if="analysisType === allAnalysisTypes.CategoricalAnalysis && query.categoricalChartType === allCategoricalChartTypes.Bar">
|
||||
<f7-card v-else-if="analysisType === allAnalysisTypes.CategoricalAnalysis && query.categoricalChartType === allCategoricalChartTypes.Bar.type">
|
||||
<f7-card-header class="no-border display-block">
|
||||
<div class="statistics-chart-header display-flex full-line justify-content-space-between">
|
||||
<div>
|
||||
@@ -221,7 +221,7 @@
|
||||
<f7-popover class="sorting-type-popover-menu"
|
||||
v-model:opened="showSortingTypePopover">
|
||||
<f7-list dividers>
|
||||
<f7-list-item :title="$t(sortingType.name)"
|
||||
<f7-list-item :title="sortingType.displayName"
|
||||
:class="{ 'list-item-selected': query.sortingType === sortingType.type }"
|
||||
:key="sortingType.type"
|
||||
v-for="sortingType in allSortingTypes"
|
||||
@@ -284,7 +284,7 @@
|
||||
<f7-list-item :title="aggregationType.displayName"
|
||||
:class="{ 'list-item-selected': trendDateAggregationType === aggregationType.type }"
|
||||
:key="aggregationType.type"
|
||||
v-for="aggregationType in allDateAggregationTypesArray"
|
||||
v-for="aggregationType in allDateAggregationTypes"
|
||||
@click="setTrendDateAggregationType(aggregationType.type)">
|
||||
<template #after>
|
||||
<f7-icon class="list-item-checked-icon" f7="checkmark_alt" v-if="trendDateAggregationType === aggregationType.type"></f7-icon>
|
||||
@@ -332,7 +332,13 @@ import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
|
||||
import { useStatisticsStore } from '@/stores/statistics.js';
|
||||
|
||||
import { DateRangeScene, DateRange } from '@/core/datetime.ts';
|
||||
import statisticsConstants from '@/consts/statistics.js';
|
||||
import {
|
||||
StatisticsAnalysisType,
|
||||
CategoricalChartType,
|
||||
ChartDataType,
|
||||
ChartSortingType,
|
||||
ChartDateAggregationType
|
||||
} from '@/core/statistics.ts';
|
||||
import { getNameByKeyValue, limitText } from '@/lib/common.ts';
|
||||
import { formatPercent } from '@/lib/numeral.ts';
|
||||
import {
|
||||
@@ -343,7 +349,6 @@ import {
|
||||
getDateTypeByDateRange,
|
||||
getDateRangeByDateType
|
||||
} from '@/lib/datetime.ts';
|
||||
import { isChartDataTypeAvailableForAnalysisType } from '@/lib/statistics.js';
|
||||
import { scrollToSelectedItem } from '@/lib/ui/mobile.js';
|
||||
|
||||
export default {
|
||||
@@ -355,8 +360,8 @@ export default {
|
||||
loading: true,
|
||||
loadingError: null,
|
||||
reloading: false,
|
||||
analysisType: statisticsConstants.allAnalysisTypes.CategoricalAnalysis,
|
||||
trendDateAggregationType: statisticsConstants.defaultDateAggregationType,
|
||||
analysisType: StatisticsAnalysisType.CategoricalAnalysis,
|
||||
trendDateAggregationType: ChartDateAggregationType.Default.type,
|
||||
showChartDataTypePopover: false,
|
||||
showSortingTypePopover: false,
|
||||
showDatePopover: false,
|
||||
@@ -372,7 +377,7 @@ export default {
|
||||
return this.userStore.currentUserDefaultCurrency;
|
||||
},
|
||||
defaultTrendDateAggregationType() {
|
||||
return statisticsConstants.defaultDateAggregationType;
|
||||
return ChartDateAggregationType.Default.type;
|
||||
},
|
||||
firstDayOfWeek() {
|
||||
return this.userStore.currentUserFirstDayOfWeek;
|
||||
@@ -385,9 +390,9 @@ export default {
|
||||
},
|
||||
queryChartType: {
|
||||
get: function () {
|
||||
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
return this.query.categoricalChartType;
|
||||
} else if (this.analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.analysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
return this.query.trendChartType;
|
||||
} else {
|
||||
return null;
|
||||
@@ -398,72 +403,72 @@ export default {
|
||||
}
|
||||
},
|
||||
queryChartDataTypeName() {
|
||||
const queryChartDataTypeName = getNameByKeyValue(this.allChartDataTypes, this.query.chartDataType, 'type', 'name', 'Statistics');
|
||||
const queryChartDataTypeName = getNameByKeyValue(ChartDataType.values(), this.query.chartDataType, 'type', 'name', 'Statistics');
|
||||
return this.$t(queryChartDataTypeName);
|
||||
},
|
||||
querySortingTypeName() {
|
||||
const querySortingTypeName = getNameByKeyValue(this.allSortingTypes, this.query.sortingType, 'type', 'name', 'System Default');
|
||||
const querySortingTypeName = getNameByKeyValue(ChartSortingType.values(), this.query.sortingType, 'type', 'name', 'System Default');
|
||||
return this.$t(querySortingTypeName);
|
||||
},
|
||||
queryDateType() {
|
||||
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
return this.query.categoricalChartDateType;
|
||||
} else if (this.analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.analysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
return this.query.trendChartDateType;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
queryTrendDateAggregationTypeName() {
|
||||
return getNameByKeyValue(this.allDateAggregationTypesArray, this.trendDateAggregationType, 'type', 'displayName', '');
|
||||
return getNameByKeyValue(this.allDateAggregationTypes, this.trendDateAggregationType, 'type', 'displayName', '');
|
||||
},
|
||||
queryStartTime() {
|
||||
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
return this.$locale.formatUnixTimeToLongDateTime(this.userStore, this.query.categoricalChartStartTime);
|
||||
} else if (this.analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.analysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
return this.$locale.formatUnixTimeToLongYearMonth(this.userStore, getYearMonthFirstUnixTime(this.query.trendChartStartYearMonth));
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
queryEndTime() {
|
||||
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
return this.$locale.formatUnixTimeToLongDateTime(this.userStore, this.query.categoricalChartEndTime);
|
||||
} else if (this.analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.analysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
return this.$locale.formatUnixTimeToLongYearMonth(this.userStore, getYearMonthLastUnixTime(this.query.trendChartEndYearMonth));
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
allAnalysisTypes() {
|
||||
return statisticsConstants.allAnalysisTypes;
|
||||
return StatisticsAnalysisType;
|
||||
},
|
||||
allChartTypes() {
|
||||
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
return this.$locale.getAllCategoricalChartTypes();
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
allCategoricalChartTypes() {
|
||||
return statisticsConstants.allCategoricalChartTypes;
|
||||
return CategoricalChartType.all();
|
||||
},
|
||||
allChartDataTypes() {
|
||||
return statisticsConstants.allChartDataTypes;
|
||||
return ChartDataType.all();
|
||||
},
|
||||
allSortingTypes() {
|
||||
return statisticsConstants.allSortingTypes;
|
||||
return this.$locale.getAllStatisticsSortingTypes();
|
||||
},
|
||||
allDateAggregationTypesArray() {
|
||||
allDateAggregationTypes() {
|
||||
return this.$locale.getAllStatisticsDateAggregationTypes();
|
||||
},
|
||||
allDateRanges() {
|
||||
return DateRange.all();
|
||||
},
|
||||
allDateRangesArray() {
|
||||
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
return this.$locale.getAllDateRanges(DateRangeScene.Normal, true);
|
||||
} else if (this.analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.analysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
return this.$locale.getAllDateRanges(DateRangeScene.TrendAnalysis, true);
|
||||
} else {
|
||||
return [];
|
||||
@@ -473,17 +478,17 @@ export default {
|
||||
return this.settingsStore.appSettings.showAccountBalance;
|
||||
},
|
||||
totalAmountName() {
|
||||
if (this.query.chartDataType === this.allChartDataTypes.IncomeByAccount.type
|
||||
|| this.query.chartDataType === this.allChartDataTypes.IncomeByPrimaryCategory.type
|
||||
|| this.query.chartDataType === this.allChartDataTypes.IncomeBySecondaryCategory.type) {
|
||||
if (this.query.chartDataType === ChartDataType.IncomeByAccount.type
|
||||
|| this.query.chartDataType === ChartDataType.IncomeByPrimaryCategory.type
|
||||
|| this.query.chartDataType === ChartDataType.IncomeBySecondaryCategory.type) {
|
||||
return this.$t('Total Income');
|
||||
} else if (this.query.chartDataType === this.allChartDataTypes.ExpenseByAccount.type
|
||||
|| this.query.chartDataType === this.allChartDataTypes.ExpenseByPrimaryCategory.type
|
||||
|| this.query.chartDataType === this.allChartDataTypes.ExpenseBySecondaryCategory.type) {
|
||||
} else if (this.query.chartDataType === ChartDataType.ExpenseByAccount.type
|
||||
|| this.query.chartDataType === ChartDataType.ExpenseByPrimaryCategory.type
|
||||
|| this.query.chartDataType === ChartDataType.ExpenseBySecondaryCategory.type) {
|
||||
return this.$t('Total Expense');
|
||||
} else if (this.query.chartDataType === this.allChartDataTypes.AccountTotalAssets.type) {
|
||||
} else if (this.query.chartDataType === ChartDataType.AccountTotalAssets.type) {
|
||||
return this.$t('Total Assets');
|
||||
} else if (this.query.chartDataType === this.allChartDataTypes.AccountTotalLiabilities.type) {
|
||||
} else if (this.query.chartDataType === ChartDataType.AccountTotalLiabilities.type) {
|
||||
return this.$t('Total Liabilities');
|
||||
}
|
||||
|
||||
@@ -496,13 +501,13 @@ export default {
|
||||
return this.statisticsStore.trendsAnalysisData;
|
||||
},
|
||||
translateNameInTrendsChart() {
|
||||
return this.query.chartDataType === this.allChartDataTypes.TotalExpense.type ||
|
||||
this.query.chartDataType === this.allChartDataTypes.TotalIncome.type ||
|
||||
this.query.chartDataType === this.allChartDataTypes.TotalBalance.type;
|
||||
return this.query.chartDataType === ChartDataType.TotalExpense.type ||
|
||||
this.query.chartDataType === ChartDataType.TotalIncome.type ||
|
||||
this.query.chartDataType === ChartDataType.TotalBalance.type;
|
||||
},
|
||||
showAmountInChart() {
|
||||
if (!this.showAccountBalance
|
||||
&& (this.query.chartDataType === this.allChartDataTypes.AccountTotalAssets.type || this.query.chartDataType === this.allChartDataTypes.AccountTotalLiabilities.type)) {
|
||||
&& (this.query.chartDataType === ChartDataType.AccountTotalAssets.type || this.query.chartDataType === ChartDataType.AccountTotalLiabilities.type)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -518,11 +523,11 @@ export default {
|
||||
self.accountsStore.loadAllAccounts({ force: false }),
|
||||
self.transactionCategoriesStore.loadAllCategories({ force: false })
|
||||
]).then(() => {
|
||||
if (self.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (self.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
return self.statisticsStore.loadCategoricalAnalysis({
|
||||
force: false
|
||||
});
|
||||
} else if (self.analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (self.analysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
return self.statisticsStore.loadTrendAnalysis({
|
||||
force: false
|
||||
});
|
||||
@@ -553,26 +558,26 @@ export default {
|
||||
|
||||
self.reloading = true;
|
||||
|
||||
if (self.query.chartDataType === self.allChartDataTypes.ExpenseByAccount.type ||
|
||||
self.query.chartDataType === self.allChartDataTypes.ExpenseByPrimaryCategory.type ||
|
||||
self.query.chartDataType === self.allChartDataTypes.ExpenseBySecondaryCategory.type ||
|
||||
self.query.chartDataType === self.allChartDataTypes.IncomeByAccount.type ||
|
||||
self.query.chartDataType === self.allChartDataTypes.IncomeByPrimaryCategory.type ||
|
||||
self.query.chartDataType === self.allChartDataTypes.IncomeBySecondaryCategory.type ||
|
||||
self.query.chartDataType === self.allChartDataTypes.TotalExpense.type ||
|
||||
self.query.chartDataType === self.allChartDataTypes.TotalIncome.type ||
|
||||
self.query.chartDataType === self.allChartDataTypes.TotalBalance.type) {
|
||||
if (self.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (self.query.chartDataType === ChartDataType.ExpenseByAccount.type ||
|
||||
self.query.chartDataType === ChartDataType.ExpenseByPrimaryCategory.type ||
|
||||
self.query.chartDataType === ChartDataType.ExpenseBySecondaryCategory.type ||
|
||||
self.query.chartDataType === ChartDataType.IncomeByAccount.type ||
|
||||
self.query.chartDataType === ChartDataType.IncomeByPrimaryCategory.type ||
|
||||
self.query.chartDataType === ChartDataType.IncomeBySecondaryCategory.type ||
|
||||
self.query.chartDataType === ChartDataType.TotalExpense.type ||
|
||||
self.query.chartDataType === ChartDataType.TotalIncome.type ||
|
||||
self.query.chartDataType === ChartDataType.TotalBalance.type) {
|
||||
if (self.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
dispatchPromise = self.statisticsStore.loadCategoricalAnalysis({
|
||||
force: force
|
||||
});
|
||||
} else if (self.analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (self.analysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
dispatchPromise = self.statisticsStore.loadTrendAnalysis({
|
||||
force: force
|
||||
});
|
||||
}
|
||||
} else if (self.query.chartDataType === self.allChartDataTypes.AccountTotalAssets.type ||
|
||||
self.query.chartDataType === self.allChartDataTypes.AccountTotalLiabilities.type) {
|
||||
} else if (self.query.chartDataType === ChartDataType.AccountTotalAssets.type ||
|
||||
self.query.chartDataType === ChartDataType.AccountTotalLiabilities.type) {
|
||||
dispatchPromise = self.accountsStore.loadAllAccounts({
|
||||
force: force
|
||||
});
|
||||
@@ -605,11 +610,11 @@ export default {
|
||||
}
|
||||
},
|
||||
setChartType(chartType) {
|
||||
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
this.statisticsStore.updateTransactionStatisticsFilter({
|
||||
categoricalChartType: chartType
|
||||
});
|
||||
} else if (this.analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.analysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
this.statisticsStore.updateTransactionStatisticsFilter({
|
||||
trendChartType: chartType
|
||||
});
|
||||
@@ -619,9 +624,9 @@ export default {
|
||||
let analysisTypeChanged = false;
|
||||
|
||||
if (this.analysisType !== analysisType) {
|
||||
if (!isChartDataTypeAvailableForAnalysisType(this.queryChartDataType, analysisType)) {
|
||||
if (!ChartDataType.isAvailableForAnalysisType(this.queryChartDataType, analysisType)) {
|
||||
this.statisticsStore.updateTransactionStatisticsFilter({
|
||||
chartDataType: statisticsConstants.defaultChartDataType
|
||||
chartDataType: ChartDataType.Default.type
|
||||
});
|
||||
}
|
||||
|
||||
@@ -641,7 +646,7 @@ export default {
|
||||
}
|
||||
},
|
||||
setSortingType(sortingType) {
|
||||
if (sortingType < this.allSortingTypes.Amount.type || sortingType > this.allSortingTypes.Name.type) {
|
||||
if (sortingType < ChartSortingType.Amount.type || sortingType > ChartSortingType.Name.type) {
|
||||
this.showSortingTypePopover = false;
|
||||
return;
|
||||
}
|
||||
@@ -657,7 +662,7 @@ export default {
|
||||
this.showDateAggregationPopover = false;
|
||||
},
|
||||
setDateFilter(dateType) {
|
||||
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
if (dateType === this.allDateRanges.Custom.type) { // Custom
|
||||
this.showCustomDateRangeSheet = true;
|
||||
this.showDatePopover = false;
|
||||
@@ -665,7 +670,7 @@ export default {
|
||||
} else if (this.query.categoricalChartDateType === dateType) {
|
||||
return;
|
||||
}
|
||||
} else if (this.analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.analysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
if (dateType === this.allDateRanges.Custom.type) { // Custom
|
||||
this.showCustomMonthRangeSheet = true;
|
||||
this.showDatePopover = false;
|
||||
@@ -683,13 +688,13 @@ export default {
|
||||
|
||||
let changed = false;
|
||||
|
||||
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
||||
categoricalChartDateType: dateRange.dateType,
|
||||
categoricalChartStartTime: dateRange.minTime,
|
||||
categoricalChartEndTime: dateRange.maxTime
|
||||
});
|
||||
} else if (this.analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.analysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
||||
trendChartDateType: dateRange.dateType,
|
||||
trendChartStartYearMonth: getYearAndMonthFromUnixTime(dateRange.minTime),
|
||||
@@ -710,7 +715,7 @@ export default {
|
||||
|
||||
let changed = false;
|
||||
|
||||
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
const chartDateType = getDateTypeByDateRange(startTime, endTime, this.firstDayOfWeek, DateRangeScene.Normal);
|
||||
|
||||
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
||||
@@ -720,7 +725,7 @@ export default {
|
||||
});
|
||||
|
||||
this.showCustomDateRangeSheet = false;
|
||||
} else if (this.analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.analysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
const chartDateType = getDateTypeByDateRange(getYearMonthFirstUnixTime(startTime), getYearMonthLastUnixTime(endTime), this.firstDayOfWeek, DateRangeScene.TrendAnalysis);
|
||||
|
||||
this.statisticsStore.updateTransactionStatisticsFilter({
|
||||
@@ -737,22 +742,22 @@ export default {
|
||||
}
|
||||
},
|
||||
showCustomDateRange() {
|
||||
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
return this.query.categoricalChartDateType === this.allDateRanges.Custom.type && this.query.categoricalChartStartTime && this.query.categoricalChartEndTime;
|
||||
} else if (this.analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.analysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
return this.query.trendChartDateType === this.allDateRanges.Custom.type && this.query.trendChartStartYearMonth && this.query.trendChartEndYearMonth;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
canShiftDateRange(query) {
|
||||
if (query.chartDataType === this.allChartDataTypes.AccountTotalAssets.type || query.chartDataType === this.allChartDataTypes.AccountTotalLiabilities.type) {
|
||||
if (query.chartDataType === ChartDataType.AccountTotalAssets.type || query.chartDataType === ChartDataType.AccountTotalLiabilities.type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
return query.categoricalChartDateType !== this.allDateRanges.All.type;
|
||||
} else if (this.analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.analysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
return query.trendChartDateType !== this.allDateRanges.All.type;
|
||||
} else {
|
||||
return false;
|
||||
@@ -765,7 +770,7 @@ export default {
|
||||
|
||||
let changed = false;
|
||||
|
||||
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
const newDateRange = getShiftedDateRangeAndDateType(query.categoricalChartStartTime, query.categoricalChartEndTime, scale, this.firstDayOfWeek, DateRangeScene.Normal);
|
||||
|
||||
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
||||
@@ -773,7 +778,7 @@ export default {
|
||||
categoricalChartStartTime: newDateRange.minTime,
|
||||
categoricalChartEndTime: newDateRange.maxTime
|
||||
});
|
||||
} else if (this.analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.analysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
const newDateRange = getShiftedDateRangeAndDateType(getYearMonthFirstUnixTime(query.trendChartStartYearMonth), getYearMonthLastUnixTime(query.trendChartEndYearMonth), scale, this.firstDayOfWeek, DateRangeScene.TrendAnalysis);
|
||||
|
||||
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
||||
@@ -788,14 +793,14 @@ export default {
|
||||
}
|
||||
},
|
||||
dateRangeName(query) {
|
||||
if (this.query.chartDataType === this.allChartDataTypes.AccountTotalAssets.type ||
|
||||
this.query.chartDataType === this.allChartDataTypes.AccountTotalLiabilities.type) {
|
||||
if (this.query.chartDataType === ChartDataType.AccountTotalAssets.type ||
|
||||
this.query.chartDataType === ChartDataType.AccountTotalLiabilities.type) {
|
||||
return this.$t(this.allDateRanges.All.name);
|
||||
}
|
||||
|
||||
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
||||
if (this.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||
return this.$locale.getDateRangeDisplayName(this.userStore, query.categoricalChartDateType, query.categoricalChartStartTime, query.categoricalChartEndTime);
|
||||
} else if (this.analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
||||
} else if (this.analysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||
return this.$locale.getDateRangeDisplayName(this.userStore, query.trendChartDateType, getYearMonthFirstUnixTime(query.trendChartStartYearMonth), getYearMonthLastUnixTime(query.trendChartEndYearMonth));
|
||||
} else {
|
||||
return '';
|
||||
@@ -826,8 +831,8 @@ export default {
|
||||
amount = this.getDisplayCurrency(amount, currency);
|
||||
|
||||
if (!this.showAccountBalance
|
||||
&& (this.query.chartDataType === this.allChartDataTypes.AccountTotalAssets.type
|
||||
|| this.query.chartDataType === this.allChartDataTypes.AccountTotalLiabilities.type)
|
||||
&& (this.query.chartDataType === ChartDataType.AccountTotalAssets.type
|
||||
|| this.query.chartDataType === ChartDataType.AccountTotalLiabilities.type)
|
||||
) {
|
||||
return '***';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user