mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-20 17:54:30 +08:00
migrate consts/statistics.js to ts
This commit is contained in:
@@ -12,8 +12,8 @@ import { useUserStore } from '@/stores/user.js';
|
|||||||
|
|
||||||
import { DateRangeScene } from '@/core/datetime.ts';
|
import { DateRangeScene } from '@/core/datetime.ts';
|
||||||
import { ThemeType } from '@/core/theme.ts';
|
import { ThemeType } from '@/core/theme.ts';
|
||||||
|
import { TrendChartType, ChartDateAggregationType } from '@/core/statistics.ts';
|
||||||
import { DEFAULT_ICON_COLOR, DEFAULT_CHART_COLORS } from '@/consts/color.ts';
|
import { DEFAULT_ICON_COLOR, DEFAULT_CHART_COLORS } from '@/consts/color.ts';
|
||||||
import statisticsConstants from '@/consts/statistics.js';
|
|
||||||
import {
|
import {
|
||||||
isArray,
|
isArray,
|
||||||
isNumber
|
isNumber
|
||||||
@@ -26,7 +26,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
sortStatisticsItems,
|
sortStatisticsItems,
|
||||||
getAllDateRanges
|
getAllDateRanges
|
||||||
} from '@/lib/statistics.js';
|
} from '@/lib/statistics.ts';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: [
|
props: [
|
||||||
@@ -94,11 +94,11 @@ export default {
|
|||||||
for (let i = 0; i < this.allDateRanges.length; i++) {
|
for (let i = 0; i < this.allDateRanges.length; i++) {
|
||||||
const dateRange = this.allDateRanges[i];
|
const dateRange = this.allDateRanges[i];
|
||||||
|
|
||||||
if (this.dateAggregationType === statisticsConstants.allDateAggregationTypes.Year.type) {
|
if (this.dateAggregationType === ChartDateAggregationType.Year.type) {
|
||||||
allDisplayDateRanges.push(this.$locale.formatUnixTimeToShortYear(this.userStore, dateRange.minUnixTime));
|
allDisplayDateRanges.push(this.$locale.formatUnixTimeToShortYear(this.userStore, dateRange.minUnixTime));
|
||||||
} else if (this.dateAggregationType === statisticsConstants.allDateAggregationTypes.Quarter.type) {
|
} else if (this.dateAggregationType === ChartDateAggregationType.Quarter.type) {
|
||||||
allDisplayDateRanges.push(this.$locale.formatYearQuarter(dateRange.year, dateRange.quarter));
|
allDisplayDateRanges.push(this.$locale.formatYearQuarter(dateRange.year, dateRange.quarter));
|
||||||
} else { // if (this.dateAggregationType === statisticsConstants.allDateAggregationTypes.Month.type) {
|
} else { // if (this.dateAggregationType === ChartDateAggregationType.Month.type) {
|
||||||
allDisplayDateRanges.push(this.$locale.formatUnixTimeToShortYearMonth(this.userStore, dateRange.minUnixTime));
|
allDisplayDateRanges.push(this.$locale.formatUnixTimeToShortYearMonth(this.userStore, dateRange.minUnixTime));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,11 +122,11 @@ export default {
|
|||||||
const dataItem = item.items[j];
|
const dataItem = item.items[j];
|
||||||
let dateRangeKey = '';
|
let dateRangeKey = '';
|
||||||
|
|
||||||
if (this.dateAggregationType === statisticsConstants.allDateAggregationTypes.Year.type) {
|
if (this.dateAggregationType === ChartDateAggregationType.Year.type) {
|
||||||
dateRangeKey = dataItem.year;
|
dateRangeKey = dataItem.year;
|
||||||
} else if (this.dateAggregationType === statisticsConstants.allDateAggregationTypes.Quarter.type) {
|
} else if (this.dateAggregationType === ChartDateAggregationType.Quarter.type) {
|
||||||
dateRangeKey = `${dataItem.year}-${Math.floor((dataItem.month - 1) / 3) + 1}`;
|
dateRangeKey = `${dataItem.year}-${Math.floor((dataItem.month - 1) / 3) + 1}`;
|
||||||
} else { // if (this.dateAggregationType === statisticsConstants.allDateAggregationTypes.Month.type) {
|
} else { // if (this.dateAggregationType === ChartDateAggregationType.Month.type) {
|
||||||
dateRangeKey = `${dataItem.year}-${dataItem.month}`;
|
dateRangeKey = `${dataItem.year}-${dataItem.month}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,11 +140,11 @@ export default {
|
|||||||
const dateRange = this.allDateRanges[j];
|
const dateRange = this.allDateRanges[j];
|
||||||
let dateRangeKey = '';
|
let dateRangeKey = '';
|
||||||
|
|
||||||
if (this.dateAggregationType === statisticsConstants.allDateAggregationTypes.Year.type) {
|
if (this.dateAggregationType === ChartDateAggregationType.Year.type) {
|
||||||
dateRangeKey = dateRange.year;
|
dateRangeKey = dateRange.year;
|
||||||
} else if (this.dateAggregationType === statisticsConstants.allDateAggregationTypes.Quarter.type) {
|
} else if (this.dateAggregationType === ChartDateAggregationType.Quarter.type) {
|
||||||
dateRangeKey = `${dateRange.year}-${dateRange.quarter}`;
|
dateRangeKey = `${dateRange.year}-${dateRange.quarter}`;
|
||||||
} else { // if (this.dateAggregationType === statisticsConstants.allDateAggregationTypes.Month.type) {
|
} else { // if (this.dateAggregationType === ChartDateAggregationType.Month.type) {
|
||||||
dateRangeKey = `${dateRange.year}-${dateRange.month + 1}`;
|
dateRangeKey = `${dateRange.year}-${dateRange.month + 1}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,9 +177,9 @@ export default {
|
|||||||
data: allAmounts
|
data: allAmounts
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.type === statisticsConstants.allTrendChartTypes.Area) {
|
if (this.type === TrendChartType.Area.type) {
|
||||||
finalItem.areaStyle = {};
|
finalItem.areaStyle = {};
|
||||||
} else if (this.type === statisticsConstants.allTrendChartTypes.Column) {
|
} else if (this.type === TrendChartType.Column.type) {
|
||||||
finalItem.type = 'bar';
|
finalItem.type = 'bar';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,8 +94,8 @@ import { useSettingsStore } from '@/stores/setting.js';
|
|||||||
import { useUserStore } from '@/stores/user.js';
|
import { useUserStore } from '@/stores/user.js';
|
||||||
|
|
||||||
import { DateRangeScene } from '@/core/datetime.ts';
|
import { DateRangeScene } from '@/core/datetime.ts';
|
||||||
|
import { ChartDateAggregationType } from '@/core/statistics.ts';
|
||||||
import { DEFAULT_ICON_COLOR, DEFAULT_CHART_COLORS } from '@/consts/color.ts';
|
import { DEFAULT_ICON_COLOR, DEFAULT_CHART_COLORS } from '@/consts/color.ts';
|
||||||
import statisticsConstants from '@/consts/statistics.js';
|
|
||||||
import { isNumber } from '@/lib/common.ts';
|
import { isNumber } from '@/lib/common.ts';
|
||||||
import {
|
import {
|
||||||
getYearMonthFirstUnixTime,
|
getYearMonthFirstUnixTime,
|
||||||
@@ -105,7 +105,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
sortStatisticsItems,
|
sortStatisticsItems,
|
||||||
getAllDateRanges
|
getAllDateRanges
|
||||||
} from '@/lib/statistics.js';
|
} from '@/lib/statistics.ts';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: [
|
props: [
|
||||||
@@ -170,11 +170,11 @@ export default {
|
|||||||
const dataItem = item.items[j];
|
const dataItem = item.items[j];
|
||||||
let dateRangeKey = '';
|
let dateRangeKey = '';
|
||||||
|
|
||||||
if (this.dateAggregationType === statisticsConstants.allDateAggregationTypes.Year.type) {
|
if (this.dateAggregationType === ChartDateAggregationType.Year.type) {
|
||||||
dateRangeKey = dataItem.year;
|
dateRangeKey = dataItem.year;
|
||||||
} else if (this.dateAggregationType === statisticsConstants.allDateAggregationTypes.Quarter.type) {
|
} else if (this.dateAggregationType === ChartDateAggregationType.Quarter.type) {
|
||||||
dateRangeKey = `${dataItem.year}-${Math.floor((dataItem.month - 1) / 3) + 1}`;
|
dateRangeKey = `${dataItem.year}-${Math.floor((dataItem.month - 1) / 3) + 1}`;
|
||||||
} else { // if (this.dateAggregationType === statisticsConstants.allDateAggregationTypes.Month.type) {
|
} else { // if (this.dateAggregationType === ChartDateAggregationType.Month.type) {
|
||||||
dateRangeKey = `${dataItem.year}-${dataItem.month}`;
|
dateRangeKey = `${dataItem.year}-${dataItem.month}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,21 +200,21 @@ export default {
|
|||||||
const dateRange = this.allDateRanges[i];
|
const dateRange = this.allDateRanges[i];
|
||||||
let dateRangeKey = '';
|
let dateRangeKey = '';
|
||||||
|
|
||||||
if (this.dateAggregationType === statisticsConstants.allDateAggregationTypes.Year.type) {
|
if (this.dateAggregationType === ChartDateAggregationType.Year.type) {
|
||||||
dateRangeKey = dateRange.year;
|
dateRangeKey = dateRange.year;
|
||||||
} else if (this.dateAggregationType === statisticsConstants.allDateAggregationTypes.Quarter.type) {
|
} else if (this.dateAggregationType === ChartDateAggregationType.Quarter.type) {
|
||||||
dateRangeKey = `${dateRange.year}-${dateRange.quarter}`;
|
dateRangeKey = `${dateRange.year}-${dateRange.quarter}`;
|
||||||
} else { // if (this.dateAggregationType === statisticsConstants.allDateAggregationTypes.Month.type) {
|
} else { // if (this.dateAggregationType === ChartDateAggregationType.Month.type) {
|
||||||
dateRangeKey = `${dateRange.year}-${dateRange.month + 1}`;
|
dateRangeKey = `${dateRange.year}-${dateRange.month + 1}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
let displayDateRange = '';
|
let displayDateRange = '';
|
||||||
|
|
||||||
if (this.dateAggregationType === statisticsConstants.allDateAggregationTypes.Year.type) {
|
if (this.dateAggregationType === ChartDateAggregationType.Year.type) {
|
||||||
displayDateRange = this.$locale.formatUnixTimeToShortYear(this.userStore, dateRange.minUnixTime);
|
displayDateRange = this.$locale.formatUnixTimeToShortYear(this.userStore, dateRange.minUnixTime);
|
||||||
} else if (this.dateAggregationType === statisticsConstants.allDateAggregationTypes.Quarter.type) {
|
} else if (this.dateAggregationType === ChartDateAggregationType.Quarter.type) {
|
||||||
displayDateRange = this.$locale.formatYearQuarter(dateRange.year, dateRange.quarter);
|
displayDateRange = this.$locale.formatYearQuarter(dateRange.year, dateRange.quarter);
|
||||||
} else { // if (this.dateAggregationType === statisticsConstants.allDateAggregationTypes.Month.type) {
|
} else { // if (this.dateAggregationType === ChartDateAggregationType.Month.type) {
|
||||||
displayDateRange = this.$locale.formatUnixTimeToShortYearMonth(this.userStore, dateRange.minUnixTime);
|
displayDateRange = this.$locale.formatUnixTimeToShortYearMonth(this.userStore, dateRange.minUnixTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,214 +0,0 @@
|
|||||||
import { DateRange } from '@/core/datetime.ts';
|
|
||||||
|
|
||||||
const allAnalysisTypes = {
|
|
||||||
CategoricalAnalysis: 0,
|
|
||||||
TrendAnalysis: 1
|
|
||||||
};
|
|
||||||
|
|
||||||
const allCategoricalChartTypes = {
|
|
||||||
Pie: 0,
|
|
||||||
Bar: 1
|
|
||||||
};
|
|
||||||
|
|
||||||
const allCategoricalChartTypesArray = [
|
|
||||||
{
|
|
||||||
name: 'Pie Chart',
|
|
||||||
type: allCategoricalChartTypes.Pie
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Bar Chart',
|
|
||||||
type: allCategoricalChartTypes.Bar
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
const defaultCategoricalChartType = allCategoricalChartTypes.Pie;
|
|
||||||
|
|
||||||
const allTrendChartTypes = {
|
|
||||||
Area: 0,
|
|
||||||
Column: 1
|
|
||||||
};
|
|
||||||
|
|
||||||
const allTrendChartTypesArray = [
|
|
||||||
{
|
|
||||||
name: 'Area Chart',
|
|
||||||
type: allTrendChartTypes.Area
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Column Chart',
|
|
||||||
type: allTrendChartTypes.Column
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
const defaultTrendChartType = allTrendChartTypes.Column;
|
|
||||||
|
|
||||||
const allChartDataTypes = {
|
|
||||||
ExpenseByAccount: {
|
|
||||||
type: 0,
|
|
||||||
name: 'Expense By Account',
|
|
||||||
availableAnalysisTypes: {
|
|
||||||
[allAnalysisTypes.CategoricalAnalysis]: true,
|
|
||||||
[allAnalysisTypes.TrendAnalysis]: true,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
ExpenseByPrimaryCategory: {
|
|
||||||
type: 1,
|
|
||||||
name: 'Expense By Primary Category',
|
|
||||||
availableAnalysisTypes: {
|
|
||||||
[allAnalysisTypes.CategoricalAnalysis]: true,
|
|
||||||
[allAnalysisTypes.TrendAnalysis]: true,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
ExpenseBySecondaryCategory: {
|
|
||||||
type: 2,
|
|
||||||
name: 'Expense By Secondary Category',
|
|
||||||
availableAnalysisTypes: {
|
|
||||||
[allAnalysisTypes.CategoricalAnalysis]: true,
|
|
||||||
[allAnalysisTypes.TrendAnalysis]: true,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
IncomeByAccount: {
|
|
||||||
type: 3,
|
|
||||||
name: 'Income By Account',
|
|
||||||
availableAnalysisTypes: {
|
|
||||||
[allAnalysisTypes.CategoricalAnalysis]: true,
|
|
||||||
[allAnalysisTypes.TrendAnalysis]: true,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
IncomeByPrimaryCategory: {
|
|
||||||
type: 4,
|
|
||||||
name: 'Income By Primary Category',
|
|
||||||
availableAnalysisTypes: {
|
|
||||||
[allAnalysisTypes.CategoricalAnalysis]: true,
|
|
||||||
[allAnalysisTypes.TrendAnalysis]: true,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
IncomeBySecondaryCategory: {
|
|
||||||
type: 5,
|
|
||||||
name: 'Income By Secondary Category',
|
|
||||||
availableAnalysisTypes: {
|
|
||||||
[allAnalysisTypes.CategoricalAnalysis]: true,
|
|
||||||
[allAnalysisTypes.TrendAnalysis]: true,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
AccountTotalAssets: {
|
|
||||||
type: 6,
|
|
||||||
name: 'Account Total Assets',
|
|
||||||
availableAnalysisTypes: {
|
|
||||||
[allAnalysisTypes.CategoricalAnalysis]: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
AccountTotalLiabilities: {
|
|
||||||
type: 7,
|
|
||||||
name: 'Account Total Liabilities',
|
|
||||||
availableAnalysisTypes: {
|
|
||||||
[allAnalysisTypes.CategoricalAnalysis]: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
TotalExpense: {
|
|
||||||
type: 8,
|
|
||||||
name: 'Total Expense',
|
|
||||||
availableAnalysisTypes: {
|
|
||||||
[allAnalysisTypes.TrendAnalysis]: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
TotalIncome: {
|
|
||||||
type: 9,
|
|
||||||
name: 'Total Income',
|
|
||||||
availableAnalysisTypes: {
|
|
||||||
[allAnalysisTypes.TrendAnalysis]: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
TotalBalance: {
|
|
||||||
type: 10,
|
|
||||||
name: 'Total Balance',
|
|
||||||
availableAnalysisTypes: {
|
|
||||||
[allAnalysisTypes.TrendAnalysis]: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const allChartDataTypesMap = {
|
|
||||||
[allChartDataTypes.ExpenseByAccount.type]: allChartDataTypes.ExpenseByAccount,
|
|
||||||
[allChartDataTypes.ExpenseByPrimaryCategory.type]: allChartDataTypes.ExpenseByPrimaryCategory,
|
|
||||||
[allChartDataTypes.ExpenseBySecondaryCategory.type]: allChartDataTypes.ExpenseBySecondaryCategory,
|
|
||||||
[allChartDataTypes.IncomeByAccount.type]: allChartDataTypes.IncomeByAccount,
|
|
||||||
[allChartDataTypes.IncomeByPrimaryCategory.type]: allChartDataTypes.IncomeByPrimaryCategory,
|
|
||||||
[allChartDataTypes.IncomeBySecondaryCategory.type]: allChartDataTypes.IncomeBySecondaryCategory,
|
|
||||||
[allChartDataTypes.AccountTotalAssets.type]: allChartDataTypes.AccountTotalAssets,
|
|
||||||
[allChartDataTypes.AccountTotalLiabilities.type]: allChartDataTypes.AccountTotalLiabilities,
|
|
||||||
[allChartDataTypes.TotalExpense.type]: allChartDataTypes.TotalExpense,
|
|
||||||
[allChartDataTypes.TotalIncome.type]: allChartDataTypes.TotalIncome,
|
|
||||||
[allChartDataTypes.TotalBalance.type]: allChartDataTypes.TotalBalance
|
|
||||||
};
|
|
||||||
|
|
||||||
const defaultChartDataType = allChartDataTypes.ExpenseByPrimaryCategory.type;
|
|
||||||
|
|
||||||
const allSortingTypes = {
|
|
||||||
Amount: {
|
|
||||||
type: 0,
|
|
||||||
name: 'Amount',
|
|
||||||
fullName: 'Sort by Amount'
|
|
||||||
},
|
|
||||||
DisplayOrder: {
|
|
||||||
type: 1,
|
|
||||||
name: 'Display Order',
|
|
||||||
fullName: 'Sort by Display Order'
|
|
||||||
},
|
|
||||||
Name: {
|
|
||||||
type: 2,
|
|
||||||
name: 'Name',
|
|
||||||
fullName: 'Sort by Name'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const allSortingTypesArray = [
|
|
||||||
allSortingTypes.Amount,
|
|
||||||
allSortingTypes.DisplayOrder,
|
|
||||||
allSortingTypes.Name
|
|
||||||
]
|
|
||||||
|
|
||||||
const defaultSortingType = allSortingTypes.Amount.type;
|
|
||||||
|
|
||||||
const allDateAggregationTypes = {
|
|
||||||
Month: {
|
|
||||||
type: 0,
|
|
||||||
name: 'Aggregate by Month'
|
|
||||||
},
|
|
||||||
Quarter: {
|
|
||||||
type: 1,
|
|
||||||
name: 'Aggregate by Quarter'
|
|
||||||
},
|
|
||||||
Year: {
|
|
||||||
type: 2,
|
|
||||||
name: 'Aggregate by Year'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const allDateAggregationTypesArray = [
|
|
||||||
allDateAggregationTypes.Month,
|
|
||||||
allDateAggregationTypes.Quarter,
|
|
||||||
allDateAggregationTypes.Year
|
|
||||||
]
|
|
||||||
|
|
||||||
const defaultDateAggregationType = allDateAggregationTypes.Month.type;
|
|
||||||
|
|
||||||
export default {
|
|
||||||
allAnalysisTypes: allAnalysisTypes,
|
|
||||||
allCategoricalChartTypes: allCategoricalChartTypes,
|
|
||||||
allCategoricalChartTypesArray: allCategoricalChartTypesArray,
|
|
||||||
defaultCategoricalChartType: defaultCategoricalChartType,
|
|
||||||
allTrendChartTypes: allTrendChartTypes,
|
|
||||||
allTrendChartTypesArray: allTrendChartTypesArray,
|
|
||||||
defaultTrendChartType: defaultTrendChartType,
|
|
||||||
allChartDataTypes: allChartDataTypes,
|
|
||||||
allChartDataTypesMap: allChartDataTypesMap,
|
|
||||||
defaultChartDataType: defaultChartDataType,
|
|
||||||
defaultCategoricalChartDataRangeType: DateRange.ThisMonth.type,
|
|
||||||
defaultTrendChartDataRangeType: DateRange.ThisYear.type,
|
|
||||||
allSortingTypes: allSortingTypes,
|
|
||||||
allSortingTypesArray: allSortingTypesArray,
|
|
||||||
defaultSortingType: defaultSortingType,
|
|
||||||
allDateAggregationTypes: allDateAggregationTypes,
|
|
||||||
allDateAggregationTypesArray: allDateAggregationTypesArray,
|
|
||||||
defaultDateAggregationType: defaultDateAggregationType,
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,215 @@
|
|||||||
|
import type { TypeAndName } from './base.ts';
|
||||||
|
import { DateRange } from '@/core/datetime.ts';
|
||||||
|
|
||||||
|
export enum StatisticsAnalysisType {
|
||||||
|
CategoricalAnalysis = 0,
|
||||||
|
TrendAnalysis = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
type CategoricalChartTypeName = 'Pie' | 'Bar';
|
||||||
|
|
||||||
|
export class CategoricalChartType implements TypeAndName {
|
||||||
|
private static readonly allInstances: CategoricalChartType[] = [];
|
||||||
|
private static readonly allInstancesByTypeName: Record<string, CategoricalChartType> = {};
|
||||||
|
|
||||||
|
public static readonly Pie = new CategoricalChartType(0, 'Pie', 'Pie Chart');
|
||||||
|
public static readonly Bar = new CategoricalChartType(1, 'Bar', 'Bar Chart');
|
||||||
|
|
||||||
|
public static readonly Default = CategoricalChartType.Pie;
|
||||||
|
|
||||||
|
public readonly type: number;
|
||||||
|
public readonly typeName: CategoricalChartTypeName;
|
||||||
|
public readonly name: string;
|
||||||
|
|
||||||
|
private constructor(type: number, typeName: CategoricalChartTypeName, name: string) {
|
||||||
|
this.type = type;
|
||||||
|
this.typeName = typeName;
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
CategoricalChartType.allInstances.push(this);
|
||||||
|
CategoricalChartType.allInstancesByTypeName[typeName] = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static values(): CategoricalChartType[] {
|
||||||
|
return CategoricalChartType.allInstances;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static all(): Record<CategoricalChartTypeName, CategoricalChartType> {
|
||||||
|
return CategoricalChartType.allInstancesByTypeName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type TrendChartTypeName = 'Area' | 'Column';
|
||||||
|
|
||||||
|
export class TrendChartType implements TypeAndName {
|
||||||
|
private static readonly allInstances: TrendChartType[] = [];
|
||||||
|
private static readonly allInstancesByTypeName: Record<string, TrendChartType> = {};
|
||||||
|
|
||||||
|
public static readonly Area = new TrendChartType(0, 'Area', 'Area Chart');
|
||||||
|
public static readonly Column = new TrendChartType(1, 'Column', 'Column Chart');
|
||||||
|
|
||||||
|
public static readonly Default = TrendChartType.Column;
|
||||||
|
|
||||||
|
public readonly type: number;
|
||||||
|
public readonly typeName: TrendChartTypeName;
|
||||||
|
public readonly name: string;
|
||||||
|
|
||||||
|
private constructor(type: number, typeName: TrendChartTypeName, name: string) {
|
||||||
|
this.type = type;
|
||||||
|
this.typeName = typeName;
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
TrendChartType.allInstances.push(this);
|
||||||
|
TrendChartType.allInstancesByTypeName[typeName] = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static values(): TrendChartType[] {
|
||||||
|
return TrendChartType.allInstances;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static all(): Record<TrendChartTypeName, TrendChartType> {
|
||||||
|
return TrendChartType.allInstancesByTypeName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ChartDataTypeName = 'ExpenseByAccount' | 'ExpenseByPrimaryCategory' | 'ExpenseBySecondaryCategory' | 'IncomeByAccount' | 'IncomeByPrimaryCategory' | 'IncomeBySecondaryCategory' | 'AccountTotalAssets' | 'AccountTotalLiabilities' | 'TotalExpense' | 'TotalIncome' | 'TotalBalance';
|
||||||
|
|
||||||
|
export class ChartDataType implements TypeAndName {
|
||||||
|
private static readonly allInstances: ChartDataType[] = [];
|
||||||
|
private static readonly allInstancesByType: Record<number, ChartDataType> = {};
|
||||||
|
private static readonly allInstancesByTypeName: Record<string, ChartDataType> = {};
|
||||||
|
|
||||||
|
public static readonly ExpenseByAccount = new ChartDataType(0, 'ExpenseByAccount', 'Expense By Account', StatisticsAnalysisType.CategoricalAnalysis, StatisticsAnalysisType.TrendAnalysis);
|
||||||
|
public static readonly ExpenseByPrimaryCategory = new ChartDataType(1, 'ExpenseByPrimaryCategory', 'Expense By Primary Category', StatisticsAnalysisType.CategoricalAnalysis, StatisticsAnalysisType.TrendAnalysis);
|
||||||
|
public static readonly ExpenseBySecondaryCategory = new ChartDataType(2, 'ExpenseBySecondaryCategory', 'Expense By Secondary Category', StatisticsAnalysisType.CategoricalAnalysis, StatisticsAnalysisType.TrendAnalysis);
|
||||||
|
public static readonly IncomeByAccount = new ChartDataType(3, 'IncomeByAccount', 'Income By Account', StatisticsAnalysisType.CategoricalAnalysis, StatisticsAnalysisType.TrendAnalysis);
|
||||||
|
public static readonly IncomeByPrimaryCategory = new ChartDataType(4, 'IncomeByPrimaryCategory', 'Income By Primary Category', StatisticsAnalysisType.CategoricalAnalysis, StatisticsAnalysisType.TrendAnalysis);
|
||||||
|
public static readonly IncomeBySecondaryCategory = new ChartDataType(5, 'IncomeBySecondaryCategory', 'Income By Secondary Category', StatisticsAnalysisType.CategoricalAnalysis, StatisticsAnalysisType.TrendAnalysis);
|
||||||
|
public static readonly AccountTotalAssets = new ChartDataType(6, 'AccountTotalAssets', 'Account Total Assets', StatisticsAnalysisType.CategoricalAnalysis);
|
||||||
|
public static readonly AccountTotalLiabilities = new ChartDataType(7, 'AccountTotalLiabilities', 'Account Total Liabilities', StatisticsAnalysisType.CategoricalAnalysis);
|
||||||
|
public static readonly TotalExpense = new ChartDataType(8, 'TotalExpense', 'Total Expense', StatisticsAnalysisType.TrendAnalysis);
|
||||||
|
public static readonly TotalIncome = new ChartDataType(9, 'TotalIncome', 'Total Income', StatisticsAnalysisType.TrendAnalysis);
|
||||||
|
public static readonly TotalBalance = new ChartDataType(10, 'TotalBalance', 'Total Balance', StatisticsAnalysisType.TrendAnalysis);
|
||||||
|
|
||||||
|
public static readonly Default = ChartDataType.ExpenseByPrimaryCategory;
|
||||||
|
|
||||||
|
public readonly type: number;
|
||||||
|
public readonly typeName: ChartDataTypeName;
|
||||||
|
public readonly name: string;
|
||||||
|
private readonly availableAnalysisTypes: Record<number, boolean>;
|
||||||
|
|
||||||
|
private constructor(type: number, typeName: ChartDataTypeName, name: string, ...availableAnalysisTypes: StatisticsAnalysisType[]) {
|
||||||
|
this.type = type;
|
||||||
|
this.typeName = typeName;
|
||||||
|
this.name = name;
|
||||||
|
this.availableAnalysisTypes = {};
|
||||||
|
|
||||||
|
if (availableAnalysisTypes) {
|
||||||
|
for (const analysisType of availableAnalysisTypes) {
|
||||||
|
this.availableAnalysisTypes[analysisType] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ChartDataType.allInstances.push(this);
|
||||||
|
ChartDataType.allInstancesByType[type] = this;
|
||||||
|
ChartDataType.allInstancesByTypeName[typeName] = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public isAvailableAnalysisType(analysisType: StatisticsAnalysisType): boolean {
|
||||||
|
return this.availableAnalysisTypes[analysisType] || false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static values(analysisType: StatisticsAnalysisType | undefined): ChartDataType[] {
|
||||||
|
if (analysisType === undefined) {
|
||||||
|
return ChartDataType.allInstances;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ret: ChartDataType[] = [];
|
||||||
|
|
||||||
|
for (const chartDataType of ChartDataType.allInstances) {
|
||||||
|
if (chartDataType.isAvailableAnalysisType(analysisType)) {
|
||||||
|
ret.push(chartDataType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static all(): Record<ChartDataTypeName, ChartDataType> {
|
||||||
|
return ChartDataType.allInstancesByTypeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static valueOf(type: number): ChartDataType {
|
||||||
|
return ChartDataType.allInstancesByType[type];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static isAvailableForAnalysisType(type: number, analysisType: StatisticsAnalysisType): boolean {
|
||||||
|
const chartDataType = ChartDataType.allInstancesByType[type];
|
||||||
|
return chartDataType?.isAvailableAnalysisType(analysisType) || false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ChartSortingType implements TypeAndName {
|
||||||
|
private static readonly allInstances: ChartSortingType[] = [];
|
||||||
|
private static readonly allInstancesByType: Record<number, ChartSortingType> = {};
|
||||||
|
|
||||||
|
public static readonly Amount = new ChartSortingType(0, 'Amount', 'Sort by Amount');
|
||||||
|
public static readonly DisplayOrder = new ChartSortingType(1, 'Display Order', 'Sort by Display Order');
|
||||||
|
public static readonly Name = new ChartSortingType(2, 'Name', 'Sort by Name');
|
||||||
|
|
||||||
|
public static readonly Default = ChartSortingType.Amount;
|
||||||
|
|
||||||
|
public readonly type: number;
|
||||||
|
public readonly name: string;
|
||||||
|
public readonly fullName: string;
|
||||||
|
|
||||||
|
private constructor(type: number, name: string, fullName: string) {
|
||||||
|
this.type = type;
|
||||||
|
this.name = name;
|
||||||
|
this.fullName = fullName;
|
||||||
|
|
||||||
|
ChartSortingType.allInstances.push(this);
|
||||||
|
ChartSortingType.allInstancesByType[type] = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static values(): ChartSortingType[] {
|
||||||
|
return ChartSortingType.allInstances;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static valueOf(type: number): ChartSortingType {
|
||||||
|
return ChartSortingType.allInstancesByType[type];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ChartDateAggregationType implements TypeAndName {
|
||||||
|
private static readonly allInstances: ChartDateAggregationType[] = [];
|
||||||
|
private static readonly allInstancesByType: Record<number, ChartDateAggregationType> = {};
|
||||||
|
|
||||||
|
public static readonly Month = new ChartDateAggregationType(0, 'Aggregate by Month');
|
||||||
|
public static readonly Quarter = new ChartDateAggregationType(1, 'Aggregate by Quarter');
|
||||||
|
public static readonly Year = new ChartDateAggregationType(2, 'Aggregate by Year');
|
||||||
|
|
||||||
|
public static readonly Default = ChartDateAggregationType.Month;
|
||||||
|
|
||||||
|
public readonly type: number;
|
||||||
|
public readonly name: string;
|
||||||
|
|
||||||
|
private constructor(type: number, name: string) {
|
||||||
|
this.type = type;
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
ChartDateAggregationType.allInstances.push(this);
|
||||||
|
ChartDateAggregationType.allInstancesByType[type] = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static values(): ChartDateAggregationType[] {
|
||||||
|
return ChartDateAggregationType.allInstances;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static valueOf(type: number): ChartDateAggregationType {
|
||||||
|
return ChartDateAggregationType.allInstancesByType[type];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const DEFAULT_CATEGORICAL_CHART_DATA_RANGE: DateRange = DateRange.ThisMonth;
|
||||||
|
export const DEFAULT_TREND_CHART_DATA_RANGE: DateRange = DateRange.ThisYear;
|
||||||
+6
-80
@@ -12,16 +12,15 @@ import { AccountType, AccountCategory } from '@/core/account.ts';
|
|||||||
import { CategoryType } from '@/core/category.ts';
|
import { CategoryType } from '@/core/category.ts';
|
||||||
import { TransactionEditScopeType, TransactionTagFilterType } from '@/core/transaction.ts';
|
import { TransactionEditScopeType, TransactionTagFilterType } from '@/core/transaction.ts';
|
||||||
import { ScheduledTemplateFrequencyType } from '@/core/template.ts';
|
import { ScheduledTemplateFrequencyType } from '@/core/template.ts';
|
||||||
|
import { CategoricalChartType, TrendChartType, ChartDataType, ChartSortingType, ChartDateAggregationType } from '@/core/statistics.ts';
|
||||||
|
|
||||||
import { UTC_TIMEZONE, ALL_TIMEZONES } from '@/consts/timezone.ts';
|
import { UTC_TIMEZONE, ALL_TIMEZONES } from '@/consts/timezone.ts';
|
||||||
import { ALL_CURRENCIES } from '@/consts/currency.ts';
|
import { ALL_CURRENCIES } from '@/consts/currency.ts';
|
||||||
import { SUPPORTED_IMPORT_FILE_TYPES } from '@/consts/file.ts';
|
import { SUPPORTED_IMPORT_FILE_TYPES } from '@/consts/file.ts';
|
||||||
import { DEFAULT_EXPENSE_CATEGORIES, DEFAULT_INCOME_CATEGORIES, DEFAULT_TRANSFER_CATEGORIES } from '@/consts/category.ts';
|
import { DEFAULT_EXPENSE_CATEGORIES, DEFAULT_INCOME_CATEGORIES, DEFAULT_TRANSFER_CATEGORIES } from '@/consts/category.ts';
|
||||||
import statisticsConstants from '@/consts/statistics.js';
|
|
||||||
import { KnownErrorCode, SPECIFIED_API_NOT_FOUND_ERRORS, PARAMETERIZED_ERRORS } from '@/consts/api.ts';
|
import { KnownErrorCode, SPECIFIED_API_NOT_FOUND_ERRORS, PARAMETERIZED_ERRORS } from '@/consts/api.ts';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
isDefined,
|
|
||||||
isString,
|
isString,
|
||||||
isNumber,
|
isNumber,
|
||||||
isBoolean,
|
isBoolean,
|
||||||
@@ -1109,96 +1108,23 @@ function getAllAccountTypes(translateFn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getAllCategoricalChartTypes(translateFn) {
|
function getAllCategoricalChartTypes(translateFn) {
|
||||||
const allChartTypes = [];
|
return getLocalizedDisplayNameAndType(CategoricalChartType.values(), translateFn);
|
||||||
|
|
||||||
for (let i = 0; i < statisticsConstants.allCategoricalChartTypesArray.length; i++) {
|
|
||||||
const chartType = statisticsConstants.allCategoricalChartTypesArray[i];
|
|
||||||
|
|
||||||
allChartTypes.push({
|
|
||||||
type: chartType.type,
|
|
||||||
displayName: translateFn(chartType.name)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return allChartTypes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllTrendChartTypes(translateFn) {
|
function getAllTrendChartTypes(translateFn) {
|
||||||
const allChartTypes = [];
|
return getLocalizedDisplayNameAndType(TrendChartType.values(), translateFn);
|
||||||
|
|
||||||
for (let i = 0; i < statisticsConstants.allTrendChartTypesArray.length; i++) {
|
|
||||||
const chartType = statisticsConstants.allTrendChartTypesArray[i];
|
|
||||||
|
|
||||||
allChartTypes.push({
|
|
||||||
type: chartType.type,
|
|
||||||
displayName: translateFn(chartType.name)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return allChartTypes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllStatisticsChartDataTypes(translateFn, analysisType) {
|
function getAllStatisticsChartDataTypes(translateFn, analysisType) {
|
||||||
const allChartDataTypes = [];
|
return getLocalizedDisplayNameAndType(ChartDataType.values(analysisType), translateFn);
|
||||||
|
|
||||||
for (const dataTypeField in statisticsConstants.allChartDataTypes) {
|
|
||||||
if (!Object.prototype.hasOwnProperty.call(statisticsConstants.allChartDataTypes, dataTypeField)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const chartDataType = statisticsConstants.allChartDataTypes[dataTypeField];
|
|
||||||
|
|
||||||
if (isDefined(analysisType) && !chartDataType.availableAnalysisTypes[analysisType]) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
allChartDataTypes.push({
|
|
||||||
type: chartDataType.type,
|
|
||||||
displayName: translateFn(chartDataType.name),
|
|
||||||
availableAnalysisTypes: chartDataType.availableAnalysisTypes
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return allChartDataTypes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllStatisticsSortingTypes(translateFn) {
|
function getAllStatisticsSortingTypes(translateFn) {
|
||||||
const allSortingTypes = [];
|
return getLocalizedDisplayNameAndType(ChartSortingType.values(), translateFn);
|
||||||
|
|
||||||
for (const sortingTypeField in statisticsConstants.allSortingTypes) {
|
|
||||||
if (!Object.prototype.hasOwnProperty.call(statisticsConstants.allSortingTypes, sortingTypeField)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const sortingType = statisticsConstants.allSortingTypes[sortingTypeField];
|
|
||||||
|
|
||||||
allSortingTypes.push({
|
|
||||||
type: sortingType.type,
|
|
||||||
displayName: translateFn(sortingType.name),
|
|
||||||
displayFullName: translateFn(sortingType.fullName)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return allSortingTypes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllStatisticsDateAggregationTypes(translateFn) {
|
function getAllStatisticsDateAggregationTypes(translateFn) {
|
||||||
const aggregationTypes = [];
|
return getLocalizedDisplayNameAndType(ChartDateAggregationType.values(), translateFn);
|
||||||
|
|
||||||
for (const aggregationTypeField in statisticsConstants.allDateAggregationTypes) {
|
|
||||||
if (!Object.prototype.hasOwnProperty.call(statisticsConstants.allDateAggregationTypes, aggregationTypeField)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const aggregationType = statisticsConstants.allDateAggregationTypes[aggregationTypeField];
|
|
||||||
|
|
||||||
aggregationTypes.push({
|
|
||||||
type: aggregationType.type,
|
|
||||||
displayName: translateFn(aggregationType.name)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return aggregationTypes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllTransactionEditScopeTypes(translateFn) {
|
function getAllTransactionEditScopeTypes(translateFn) {
|
||||||
|
|||||||
+14
-7
@@ -1,6 +1,13 @@
|
|||||||
import { TimezoneTypeForStatistics } from '@/core/timezone.ts';
|
import { TimezoneTypeForStatistics } from '@/core/timezone.ts';
|
||||||
import { CurrencySortingType } from '@/core/currency.ts';
|
import { CurrencySortingType } from '@/core/currency.ts';
|
||||||
import statisticsConstants from '@/consts/statistics.js';
|
import {
|
||||||
|
CategoricalChartType,
|
||||||
|
TrendChartType,
|
||||||
|
ChartDataType,
|
||||||
|
ChartSortingType,
|
||||||
|
DEFAULT_CATEGORICAL_CHART_DATA_RANGE,
|
||||||
|
DEFAULT_TREND_CHART_DATA_RANGE
|
||||||
|
} from '@/core/statistics.ts';
|
||||||
|
|
||||||
const settingsLocalStorageKey = 'ebk_app_settings';
|
const settingsLocalStorageKey = 'ebk_app_settings';
|
||||||
|
|
||||||
@@ -22,15 +29,15 @@ const defaultSettings = {
|
|||||||
showAccountBalance: true,
|
showAccountBalance: true,
|
||||||
currencySortByInExchangeRatesPage: CurrencySortingType.Default.type,
|
currencySortByInExchangeRatesPage: CurrencySortingType.Default.type,
|
||||||
statistics: {
|
statistics: {
|
||||||
defaultChartDataType: statisticsConstants.defaultChartDataType,
|
defaultChartDataType: ChartDataType.Default.type,
|
||||||
defaultTimezoneType: TimezoneTypeForStatistics.Default.type,
|
defaultTimezoneType: TimezoneTypeForStatistics.Default.type,
|
||||||
defaultAccountFilter: {},
|
defaultAccountFilter: {},
|
||||||
defaultTransactionCategoryFilter: {},
|
defaultTransactionCategoryFilter: {},
|
||||||
defaultSortingType: statisticsConstants.defaultSortingType,
|
defaultSortingType: ChartSortingType.Default.type,
|
||||||
defaultCategoricalChartType: statisticsConstants.defaultCategoricalChartType,
|
defaultCategoricalChartType: CategoricalChartType.Default.type,
|
||||||
defaultCategoricalChartDataRangeType: statisticsConstants.defaultCategoricalChartDataRangeType,
|
defaultCategoricalChartDataRangeType: DEFAULT_CATEGORICAL_CHART_DATA_RANGE.type,
|
||||||
defaultTrendChartType: statisticsConstants.defaultTrendChartType,
|
defaultTrendChartType: TrendChartType.Default.type,
|
||||||
defaultTrendChartDataRangeType: statisticsConstants.defaultTrendChartDataRangeType,
|
defaultTrendChartDataRangeType: DEFAULT_TREND_CHART_DATA_RANGE,
|
||||||
},
|
},
|
||||||
animate: true
|
animate: true
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import statisticsConstants from '@/consts/statistics.js';
|
import type { YearMonth, YearUnixTime, YearQuarterUnixTime, YearMonthUnixTime } from '@/core/datetime.ts';
|
||||||
|
import { ChartSortingType, ChartDateAggregationType } from '@/core/statistics.ts';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getAllMonthsStartAndEndUnixTimes,
|
getAllMonthsStartAndEndUnixTimes,
|
||||||
@@ -6,26 +7,8 @@ import {
|
|||||||
getAllYearsStartAndEndUnixTimes
|
getAllYearsStartAndEndUnixTimes
|
||||||
} from '@/lib/datetime.ts';
|
} from '@/lib/datetime.ts';
|
||||||
|
|
||||||
export function isChartDataTypeAvailableForAnalysisType(chartDataType, analysisType) {
|
export function sortStatisticsItems(items: { name: string, totalAmount: number, displayOrders: number[] }[], sortingType: number): void {
|
||||||
for (const dataTypeField in statisticsConstants.allChartDataTypes) {
|
if (sortingType === ChartSortingType.DisplayOrder.type) {
|
||||||
if (!Object.prototype.hasOwnProperty.call(statisticsConstants.allChartDataTypes, dataTypeField)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const dataTypeItem = statisticsConstants.allChartDataTypes[dataTypeField];
|
|
||||||
|
|
||||||
if (dataTypeItem.type !== chartDataType) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return !!dataTypeItem.availableAnalysisTypes[analysisType];
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function sortStatisticsItems(items, sortingType) {
|
|
||||||
if (sortingType === statisticsConstants.allSortingTypes.DisplayOrder.type) {
|
|
||||||
items.sort(function (data1, data2) {
|
items.sort(function (data1, data2) {
|
||||||
for (let i = 0; i < Math.min(data1.displayOrders.length, data2.displayOrders.length); i++) {
|
for (let i = 0; i < Math.min(data1.displayOrders.length, data2.displayOrders.length); i++) {
|
||||||
if (data1.displayOrders[i] !== data2.displayOrders[i]) {
|
if (data1.displayOrders[i] !== data2.displayOrders[i]) {
|
||||||
@@ -38,7 +21,7 @@ export function sortStatisticsItems(items, sortingType) {
|
|||||||
sensitivity: 'base'
|
sensitivity: 'base'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else if (sortingType === statisticsConstants.allSortingTypes.Name.type) {
|
} else if (sortingType === ChartSortingType.Name.type) {
|
||||||
items.sort(function (data1, data2) {
|
items.sort(function (data1, data2) {
|
||||||
return data1.name.localeCompare(data2.name, undefined, { // asc
|
return data1.name.localeCompare(data2.name, undefined, { // asc
|
||||||
numeric: true,
|
numeric: true,
|
||||||
@@ -59,7 +42,7 @@ export function sortStatisticsItems(items, sortingType) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAllDateRanges(items, startYearMonth, endYearMonth, dateAggregationType) {
|
export function getAllDateRanges(items: { items: YearMonth[] }[], startYearMonth: YearMonth | string, endYearMonth: YearMonth | string, dateAggregationType: number): YearUnixTime[] | YearQuarterUnixTime[] | YearMonthUnixTime[] {
|
||||||
if ((!startYearMonth || !endYearMonth) && items && items.length) {
|
if ((!startYearMonth || !endYearMonth) && items && items.length) {
|
||||||
let minYear = Number.MAX_SAFE_INTEGER, minMonth = Number.MAX_SAFE_INTEGER, maxYear = 0, maxMonth = 0;
|
let minYear = Number.MAX_SAFE_INTEGER, minMonth = Number.MAX_SAFE_INTEGER, maxYear = 0, maxMonth = 0;
|
||||||
|
|
||||||
@@ -88,11 +71,12 @@ export function getAllDateRanges(items, startYearMonth, endYearMonth, dateAggreg
|
|||||||
if (!startYearMonth || !endYearMonth) {
|
if (!startYearMonth || !endYearMonth) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
if (dateAggregationType === statisticsConstants.allDateAggregationTypes.Year.type) {
|
|
||||||
|
if (dateAggregationType === ChartDateAggregationType.Year.type) {
|
||||||
return getAllYearsStartAndEndUnixTimes(startYearMonth, endYearMonth);
|
return getAllYearsStartAndEndUnixTimes(startYearMonth, endYearMonth);
|
||||||
} else if (dateAggregationType === statisticsConstants.allDateAggregationTypes.Quarter.type) {
|
} else if (dateAggregationType === ChartDateAggregationType.Quarter.type) {
|
||||||
return getAllQuartersStartAndEndUnixTimes(startYearMonth, endYearMonth);
|
return getAllQuartersStartAndEndUnixTimes(startYearMonth, endYearMonth);
|
||||||
} else { // if (dateAggregationType === statisticsConstants.allDateAggregationTypes.Month.type) {
|
} else { // if (dateAggregationType === ChartDateAggregationType.Month.type) {
|
||||||
return getAllMonthsStartAndEndUnixTimes(startYearMonth, endYearMonth);
|
return getAllMonthsStartAndEndUnixTimes(startYearMonth, endYearMonth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+98
-90
@@ -9,7 +9,16 @@ import { useExchangeRatesStore } from './exchangeRates.js';
|
|||||||
import { DateRangeScene, DateRange } from '@/core/datetime';
|
import { DateRangeScene, DateRange } from '@/core/datetime';
|
||||||
import { CategoryType } from '@/core/category.ts';
|
import { CategoryType } from '@/core/category.ts';
|
||||||
import { TransactionTagFilterType } from '@/core/transaction.ts';
|
import { TransactionTagFilterType } from '@/core/transaction.ts';
|
||||||
import statisticsConstants from '@/consts/statistics.js';
|
import {
|
||||||
|
StatisticsAnalysisType,
|
||||||
|
CategoricalChartType,
|
||||||
|
TrendChartType,
|
||||||
|
ChartDataType,
|
||||||
|
ChartSortingType,
|
||||||
|
ChartDateAggregationType,
|
||||||
|
DEFAULT_CATEGORICAL_CHART_DATA_RANGE,
|
||||||
|
DEFAULT_TREND_CHART_DATA_RANGE
|
||||||
|
} from '@/core/statistics.ts';
|
||||||
import { DEFAULT_ACCOUNT_ICON, DEFAULT_CATEGORY_ICON } from '@/consts/icon.ts';
|
import { DEFAULT_ACCOUNT_ICON, DEFAULT_CATEGORY_ICON } from '@/consts/icon.ts';
|
||||||
import { DEFAULT_ACCOUNT_COLOR, DEFAULT_CATEGORY_COLOR } from '@/consts/color.ts';
|
import { DEFAULT_ACCOUNT_COLOR, DEFAULT_CATEGORY_COLOR } from '@/consts/color.ts';
|
||||||
import services from '@/lib/services.js';
|
import services from '@/lib/services.js';
|
||||||
@@ -37,7 +46,7 @@ import {
|
|||||||
} from '@/lib/category.js';
|
} from '@/lib/category.js';
|
||||||
import {
|
import {
|
||||||
sortStatisticsItems
|
sortStatisticsItems
|
||||||
} from '@/lib/statistics.js';
|
} from '@/lib/statistics.ts';
|
||||||
|
|
||||||
function assembleAccountAndCategoryInfo(userStore, accountsStore, transactionCategoriesStore, exchangeRatesStore, items) {
|
function assembleAccountAndCategoryInfo(userStore, accountsStore, transactionCategoriesStore, exchangeRatesStore, items) {
|
||||||
const finalItems = [];
|
const finalItems = [];
|
||||||
@@ -101,21 +110,21 @@ function getCategoryTotalAmountItems(items, transactionStatisticsFilter) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.ExpenseByAccount.type ||
|
if (transactionStatisticsFilter.chartDataType === ChartDataType.ExpenseByAccount.type ||
|
||||||
transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.ExpenseByPrimaryCategory.type ||
|
transactionStatisticsFilter.chartDataType === ChartDataType.ExpenseByPrimaryCategory.type ||
|
||||||
transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.ExpenseBySecondaryCategory.type ||
|
transactionStatisticsFilter.chartDataType === ChartDataType.ExpenseBySecondaryCategory.type ||
|
||||||
transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.TotalExpense.type) {
|
transactionStatisticsFilter.chartDataType === ChartDataType.TotalExpense.type) {
|
||||||
if (item.category.type !== CategoryType.Expense) {
|
if (item.category.type !== CategoryType.Expense) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if (transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.IncomeByAccount.type ||
|
} else if (transactionStatisticsFilter.chartDataType === ChartDataType.IncomeByAccount.type ||
|
||||||
transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.IncomeByPrimaryCategory.type ||
|
transactionStatisticsFilter.chartDataType === ChartDataType.IncomeByPrimaryCategory.type ||
|
||||||
transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.IncomeBySecondaryCategory.type ||
|
transactionStatisticsFilter.chartDataType === ChartDataType.IncomeBySecondaryCategory.type ||
|
||||||
transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.TotalIncome.type) {
|
transactionStatisticsFilter.chartDataType === ChartDataType.TotalIncome.type) {
|
||||||
if (item.category.type !== CategoryType.Income) {
|
if (item.category.type !== CategoryType.Income) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if (transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.TotalBalance.type) {
|
} else if (transactionStatisticsFilter.chartDataType === ChartDataType.TotalBalance.type) {
|
||||||
// Do Nothing
|
// Do Nothing
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
@@ -129,8 +138,8 @@ function getCategoryTotalAmountItems(items, transactionStatisticsFilter) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.ExpenseByAccount.type ||
|
if (transactionStatisticsFilter.chartDataType === ChartDataType.ExpenseByAccount.type ||
|
||||||
transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.IncomeByAccount.type) {
|
transactionStatisticsFilter.chartDataType === ChartDataType.IncomeByAccount.type) {
|
||||||
if (isNumber(item.amountInDefaultCurrency)) {
|
if (isNumber(item.amountInDefaultCurrency)) {
|
||||||
let data = allDataItems[item.account.id];
|
let data = allDataItems[item.account.id];
|
||||||
|
|
||||||
@@ -157,8 +166,8 @@ function getCategoryTotalAmountItems(items, transactionStatisticsFilter) {
|
|||||||
|
|
||||||
allDataItems[item.account.id] = data;
|
allDataItems[item.account.id] = data;
|
||||||
}
|
}
|
||||||
} else if (transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.ExpenseByPrimaryCategory.type ||
|
} else if (transactionStatisticsFilter.chartDataType === ChartDataType.ExpenseByPrimaryCategory.type ||
|
||||||
transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.IncomeByPrimaryCategory.type) {
|
transactionStatisticsFilter.chartDataType === ChartDataType.IncomeByPrimaryCategory.type) {
|
||||||
if (isNumber(item.amountInDefaultCurrency)) {
|
if (isNumber(item.amountInDefaultCurrency)) {
|
||||||
let data = allDataItems[item.primaryCategory.id];
|
let data = allDataItems[item.primaryCategory.id];
|
||||||
|
|
||||||
@@ -185,8 +194,8 @@ function getCategoryTotalAmountItems(items, transactionStatisticsFilter) {
|
|||||||
|
|
||||||
allDataItems[item.primaryCategory.id] = data;
|
allDataItems[item.primaryCategory.id] = data;
|
||||||
}
|
}
|
||||||
} else if (transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.ExpenseBySecondaryCategory.type ||
|
} else if (transactionStatisticsFilter.chartDataType === ChartDataType.ExpenseBySecondaryCategory.type ||
|
||||||
transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.IncomeBySecondaryCategory.type) {
|
transactionStatisticsFilter.chartDataType === ChartDataType.IncomeBySecondaryCategory.type) {
|
||||||
if (isNumber(item.amountInDefaultCurrency)) {
|
if (isNumber(item.amountInDefaultCurrency)) {
|
||||||
let data = allDataItems[item.category.id];
|
let data = allDataItems[item.category.id];
|
||||||
|
|
||||||
@@ -213,14 +222,14 @@ function getCategoryTotalAmountItems(items, transactionStatisticsFilter) {
|
|||||||
|
|
||||||
allDataItems[item.category.id] = data;
|
allDataItems[item.category.id] = data;
|
||||||
}
|
}
|
||||||
} else if (transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.TotalExpense.type ||
|
} else if (transactionStatisticsFilter.chartDataType === ChartDataType.TotalExpense.type ||
|
||||||
transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.TotalIncome.type ||
|
transactionStatisticsFilter.chartDataType === ChartDataType.TotalIncome.type ||
|
||||||
transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.TotalBalance.type) {
|
transactionStatisticsFilter.chartDataType === ChartDataType.TotalBalance.type) {
|
||||||
if (isNumber(item.amountInDefaultCurrency)) {
|
if (isNumber(item.amountInDefaultCurrency)) {
|
||||||
let data = allDataItems['total'];
|
let data = allDataItems['total'];
|
||||||
let amount = item.amountInDefaultCurrency;
|
let amount = item.amountInDefaultCurrency;
|
||||||
|
|
||||||
if (transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.TotalBalance.type &&
|
if (transactionStatisticsFilter.chartDataType === ChartDataType.TotalBalance.type &&
|
||||||
item.category.type === CategoryType.Expense) {
|
item.category.type === CategoryType.Expense) {
|
||||||
amount = -amount;
|
amount = -amount;
|
||||||
}
|
}
|
||||||
@@ -230,12 +239,12 @@ function getCategoryTotalAmountItems(items, transactionStatisticsFilter) {
|
|||||||
} else {
|
} else {
|
||||||
let name = '';
|
let name = '';
|
||||||
|
|
||||||
if (transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.TotalExpense.type) {
|
if (transactionStatisticsFilter.chartDataType === ChartDataType.TotalExpense.type) {
|
||||||
name = statisticsConstants.allChartDataTypes.TotalExpense.name;
|
name = ChartDataType.TotalExpense.name;
|
||||||
} else if (transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.TotalIncome.type) {
|
} else if (transactionStatisticsFilter.chartDataType === ChartDataType.TotalIncome.type) {
|
||||||
name = statisticsConstants.allChartDataTypes.TotalIncome.name;
|
name = ChartDataType.TotalIncome.name;
|
||||||
} else if (transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.TotalBalance.type) {
|
} else if (transactionStatisticsFilter.chartDataType === ChartDataType.TotalBalance.type) {
|
||||||
name = statisticsConstants.allChartDataTypes.TotalBalance.name;
|
name = ChartDataType.TotalBalance.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
@@ -275,13 +284,13 @@ function sortCategoryTotalAmountItems(items, transactionStatisticsFilter) {
|
|||||||
export const useStatisticsStore = defineStore('statistics', {
|
export const useStatisticsStore = defineStore('statistics', {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
transactionStatisticsFilter: {
|
transactionStatisticsFilter: {
|
||||||
chartDataType: statisticsConstants.defaultChartDataType,
|
chartDataType: ChartDataType.Default.type,
|
||||||
categoricalChartType: statisticsConstants.defaultCategoricalChartType,
|
categoricalChartType: CategoricalChartType.Default.type,
|
||||||
categoricalChartDateType: statisticsConstants.defaultCategoricalChartDataRangeType,
|
categoricalChartDateType: DEFAULT_CATEGORICAL_CHART_DATA_RANGE.type,
|
||||||
categoricalChartStartTime: 0,
|
categoricalChartStartTime: 0,
|
||||||
categoricalChartEndTime: 0,
|
categoricalChartEndTime: 0,
|
||||||
trendChartType: statisticsConstants.defaultTrendChartType,
|
trendChartType: TrendChartType.Default.type,
|
||||||
trendChartDateType: statisticsConstants.defaultTrendChartDataRangeType,
|
trendChartDateType: DEFAULT_TREND_CHART_DATA_RANGE.type,
|
||||||
trendChartStartYearMonth: '',
|
trendChartStartYearMonth: '',
|
||||||
trendChartEndYearMonth: '',
|
trendChartEndYearMonth: '',
|
||||||
filterAccountIds: {},
|
filterAccountIds: {},
|
||||||
@@ -295,15 +304,15 @@ export const useStatisticsStore = defineStore('statistics', {
|
|||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
categoricalAnalysisChartDataCategory(state) {
|
categoricalAnalysisChartDataCategory(state) {
|
||||||
if (state.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.ExpenseByAccount.type ||
|
if (state.transactionStatisticsFilter.chartDataType === ChartDataType.ExpenseByAccount.type ||
|
||||||
state.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.IncomeByAccount.type ||
|
state.transactionStatisticsFilter.chartDataType === ChartDataType.IncomeByAccount.type ||
|
||||||
state.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.AccountTotalAssets.type ||
|
state.transactionStatisticsFilter.chartDataType === ChartDataType.AccountTotalAssets.type ||
|
||||||
state.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.AccountTotalLiabilities.type) {
|
state.transactionStatisticsFilter.chartDataType === ChartDataType.AccountTotalLiabilities.type) {
|
||||||
return 'account';
|
return 'account';
|
||||||
} else if (state.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.ExpenseByPrimaryCategory.type ||
|
} else if (state.transactionStatisticsFilter.chartDataType === ChartDataType.ExpenseByPrimaryCategory.type ||
|
||||||
state.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.ExpenseBySecondaryCategory.type ||
|
state.transactionStatisticsFilter.chartDataType === ChartDataType.ExpenseBySecondaryCategory.type ||
|
||||||
state.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.IncomeByPrimaryCategory.type ||
|
state.transactionStatisticsFilter.chartDataType === ChartDataType.IncomeByPrimaryCategory.type ||
|
||||||
state.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.IncomeBySecondaryCategory.type) {
|
state.transactionStatisticsFilter.chartDataType === ChartDataType.IncomeBySecondaryCategory.type) {
|
||||||
return 'category';
|
return 'category';
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
@@ -351,11 +360,11 @@ export const useStatisticsStore = defineStore('statistics', {
|
|||||||
for (let i = 0; i < accountsStore.allPlainAccounts.length; i++) {
|
for (let i = 0; i < accountsStore.allPlainAccounts.length; i++) {
|
||||||
const account = accountsStore.allPlainAccounts[i];
|
const account = accountsStore.allPlainAccounts[i];
|
||||||
|
|
||||||
if (state.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.AccountTotalAssets.type) {
|
if (state.transactionStatisticsFilter.chartDataType === ChartDataType.AccountTotalAssets.type) {
|
||||||
if (!account.isAsset) {
|
if (!account.isAsset) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if (state.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.AccountTotalLiabilities.type) {
|
} else if (state.transactionStatisticsFilter.chartDataType === ChartDataType.AccountTotalLiabilities.type) {
|
||||||
if (!account.isLiability) {
|
if (!account.isLiability) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -417,15 +426,15 @@ export const useStatisticsStore = defineStore('statistics', {
|
|||||||
totalAmount: 0
|
totalAmount: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
if (state.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.ExpenseByAccount.type ||
|
if (state.transactionStatisticsFilter.chartDataType === ChartDataType.ExpenseByAccount.type ||
|
||||||
state.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.ExpenseByPrimaryCategory.type ||
|
state.transactionStatisticsFilter.chartDataType === ChartDataType.ExpenseByPrimaryCategory.type ||
|
||||||
state.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.ExpenseBySecondaryCategory.type ||
|
state.transactionStatisticsFilter.chartDataType === ChartDataType.ExpenseBySecondaryCategory.type ||
|
||||||
state.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.IncomeByAccount.type ||
|
state.transactionStatisticsFilter.chartDataType === ChartDataType.IncomeByAccount.type ||
|
||||||
state.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.IncomeByPrimaryCategory.type ||
|
state.transactionStatisticsFilter.chartDataType === ChartDataType.IncomeByPrimaryCategory.type ||
|
||||||
state.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.IncomeBySecondaryCategory.type) {
|
state.transactionStatisticsFilter.chartDataType === ChartDataType.IncomeBySecondaryCategory.type) {
|
||||||
combinedData = state.transactionCategoryTotalAmountAnalysisData;
|
combinedData = state.transactionCategoryTotalAmountAnalysisData;
|
||||||
} else if (state.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.AccountTotalAssets.type ||
|
} else if (state.transactionStatisticsFilter.chartDataType === ChartDataType.AccountTotalAssets.type ||
|
||||||
state.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.AccountTotalLiabilities.type) {
|
state.transactionStatisticsFilter.chartDataType === ChartDataType.AccountTotalLiabilities.type) {
|
||||||
combinedData = state.accountTotalAmountAnalysisData;
|
combinedData = state.accountTotalAmountAnalysisData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -553,13 +562,13 @@ export const useStatisticsStore = defineStore('statistics', {
|
|||||||
this.transactionStatisticsStateInvalid = invalidState;
|
this.transactionStatisticsStateInvalid = invalidState;
|
||||||
},
|
},
|
||||||
resetTransactionStatistics() {
|
resetTransactionStatistics() {
|
||||||
this.transactionStatisticsFilter.chartDataType = statisticsConstants.defaultChartDataType;
|
this.transactionStatisticsFilter.chartDataType = ChartDataType.Default.type;
|
||||||
this.transactionStatisticsFilter.categoricalChartType = statisticsConstants.defaultCategoricalChartType;
|
this.transactionStatisticsFilter.categoricalChartType = CategoricalChartType.Default.type;
|
||||||
this.transactionStatisticsFilter.categoricalChartDateType = statisticsConstants.defaultCategoricalChartDataRangeType;
|
this.transactionStatisticsFilter.categoricalChartDateType = DEFAULT_CATEGORICAL_CHART_DATA_RANGE.type;
|
||||||
this.transactionStatisticsFilter.categoricalChartStartTime = 0;
|
this.transactionStatisticsFilter.categoricalChartStartTime = 0;
|
||||||
this.transactionStatisticsFilter.categoricalChartEndTime = 0;
|
this.transactionStatisticsFilter.categoricalChartEndTime = 0;
|
||||||
this.transactionStatisticsFilter.trendChartType = statisticsConstants.defaultTrendChartType;
|
this.transactionStatisticsFilter.trendChartType = TrendChartType.Default.type;
|
||||||
this.transactionStatisticsFilter.trendChartDateType = statisticsConstants.defaultTrendChartDataRangeType;
|
this.transactionStatisticsFilter.trendChartDateType = DEFAULT_TREND_CHART_DATA_RANGE.type;
|
||||||
this.transactionStatisticsFilter.trendChartStartYearMonth = '';
|
this.transactionStatisticsFilter.trendChartStartYearMonth = '';
|
||||||
this.transactionStatisticsFilter.trendChartEndYearMonth = '';
|
this.transactionStatisticsFilter.trendChartEndYearMonth = '';
|
||||||
this.transactionStatisticsFilter.filterAccountIds = {};
|
this.transactionStatisticsFilter.filterAccountIds = {};
|
||||||
@@ -580,10 +589,9 @@ export const useStatisticsStore = defineStore('statistics', {
|
|||||||
this.transactionStatisticsFilter.chartDataType = settingsStore.appSettings.statistics.defaultChartDataType;
|
this.transactionStatisticsFilter.chartDataType = settingsStore.appSettings.statistics.defaultChartDataType;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis || analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
if (analysisType === StatisticsAnalysisType.CategoricalAnalysis || analysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||||
if (!statisticsConstants.allChartDataTypesMap[this.transactionStatisticsFilter.chartDataType] ||
|
if (!ChartDataType.isAvailableForAnalysisType(this.transactionStatisticsFilter.chartDataType, analysisType)) {
|
||||||
!statisticsConstants.allChartDataTypesMap[this.transactionStatisticsFilter.chartDataType].availableAnalysisTypes[analysisType]) {
|
this.transactionStatisticsFilter.chartDataType = ChartDataType.Default.type;
|
||||||
this.transactionStatisticsFilter.chartDataType = statisticsConstants.defaultChartDataType;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -593,8 +601,8 @@ export const useStatisticsStore = defineStore('statistics', {
|
|||||||
this.transactionStatisticsFilter.categoricalChartType = settingsStore.appSettings.statistics.defaultCategoricalChartType;
|
this.transactionStatisticsFilter.categoricalChartType = settingsStore.appSettings.statistics.defaultCategoricalChartType;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.transactionStatisticsFilter.categoricalChartType !== statisticsConstants.allCategoricalChartTypes.Pie && this.transactionStatisticsFilter.categoricalChartType !== statisticsConstants.allCategoricalChartTypes.Bar) {
|
if (this.transactionStatisticsFilter.categoricalChartType !== CategoricalChartType.Pie.type && this.transactionStatisticsFilter.categoricalChartType !== CategoricalChartType.Bar.type) {
|
||||||
this.transactionStatisticsFilter.categoricalChartType = statisticsConstants.defaultCategoricalChartType;
|
this.transactionStatisticsFilter.categoricalChartType = CategoricalChartType.Default.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter && isInteger(filter.categoricalChartDateType)) {
|
if (filter && isInteger(filter.categoricalChartDateType)) {
|
||||||
@@ -606,7 +614,7 @@ export const useStatisticsStore = defineStore('statistics', {
|
|||||||
let categoricalChartDateTypeValid = true;
|
let categoricalChartDateTypeValid = true;
|
||||||
|
|
||||||
if (!DateRange.isAvailableForScene(this.transactionStatisticsFilter.categoricalChartDateType, DateRangeScene.Normal)) {
|
if (!DateRange.isAvailableForScene(this.transactionStatisticsFilter.categoricalChartDateType, DateRangeScene.Normal)) {
|
||||||
this.transactionStatisticsFilter.categoricalChartDateType = statisticsConstants.defaultCategoricalChartDataRangeType;
|
this.transactionStatisticsFilter.categoricalChartDateType = DEFAULT_CATEGORICAL_CHART_DATA_RANGE.type;
|
||||||
categoricalChartDateTypeValid = false;
|
categoricalChartDateTypeValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -635,8 +643,8 @@ export const useStatisticsStore = defineStore('statistics', {
|
|||||||
this.transactionStatisticsFilter.trendChartType = settingsStore.appSettings.statistics.defaultTrendChartType;
|
this.transactionStatisticsFilter.trendChartType = settingsStore.appSettings.statistics.defaultTrendChartType;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.transactionStatisticsFilter.trendChartType !== statisticsConstants.allTrendChartTypes.Area && this.transactionStatisticsFilter.trendChartType !== statisticsConstants.allTrendChartTypes.Column) {
|
if (this.transactionStatisticsFilter.trendChartType !== TrendChartType.Area.type && this.transactionStatisticsFilter.trendChartType !== TrendChartType.Column.type) {
|
||||||
this.transactionStatisticsFilter.trendChartType = statisticsConstants.defaultTrendChartType;
|
this.transactionStatisticsFilter.trendChartType = TrendChartType.Default.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter && isInteger(filter.trendChartDateType)) {
|
if (filter && isInteger(filter.trendChartDateType)) {
|
||||||
@@ -648,7 +656,7 @@ export const useStatisticsStore = defineStore('statistics', {
|
|||||||
let trendChartDateTypeValid = true;
|
let trendChartDateTypeValid = true;
|
||||||
|
|
||||||
if (!DateRange.isAvailableForScene(this.transactionStatisticsFilter.trendChartDateType, DateRangeScene.TrendAnalysis)) {
|
if (!DateRange.isAvailableForScene(this.transactionStatisticsFilter.trendChartDateType, DateRangeScene.TrendAnalysis)) {
|
||||||
this.transactionStatisticsFilter.trendChartDateType = statisticsConstants.defaultTrendChartDataRangeType;
|
this.transactionStatisticsFilter.trendChartDateType = DEFAULT_TREND_CHART_DATA_RANGE.type;
|
||||||
trendChartDateTypeValid = false;
|
trendChartDateTypeValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -701,8 +709,8 @@ export const useStatisticsStore = defineStore('statistics', {
|
|||||||
this.transactionStatisticsFilter.sortingType = settingsStore.appSettings.statistics.defaultSortingType;
|
this.transactionStatisticsFilter.sortingType = settingsStore.appSettings.statistics.defaultSortingType;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.transactionStatisticsFilter.sortingType < statisticsConstants.allSortingTypes.Amount.type || this.transactionStatisticsFilter.sortingType > statisticsConstants.allSortingTypes.Name.type) {
|
if (this.transactionStatisticsFilter.sortingType < ChartSortingType.Amount.type || this.transactionStatisticsFilter.sortingType > ChartSortingType.Name.type) {
|
||||||
this.transactionStatisticsFilter.sortingType = statisticsConstants.defaultSortingType;
|
this.transactionStatisticsFilter.sortingType = ChartSortingType.Default.type;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateTransactionStatisticsFilter(filter) {
|
updateTransactionStatisticsFilter(filter) {
|
||||||
@@ -786,7 +794,7 @@ export const useStatisticsStore = defineStore('statistics', {
|
|||||||
querys.push('analysisType=' + analysisType);
|
querys.push('analysisType=' + analysisType);
|
||||||
querys.push('chartDataType=' + this.transactionStatisticsFilter.chartDataType);
|
querys.push('chartDataType=' + this.transactionStatisticsFilter.chartDataType);
|
||||||
|
|
||||||
if (analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
querys.push('chartType=' + this.transactionStatisticsFilter.categoricalChartType);
|
querys.push('chartType=' + this.transactionStatisticsFilter.categoricalChartType);
|
||||||
querys.push('chartDateType=' + this.transactionStatisticsFilter.categoricalChartDateType);
|
querys.push('chartDateType=' + this.transactionStatisticsFilter.categoricalChartDateType);
|
||||||
|
|
||||||
@@ -794,7 +802,7 @@ export const useStatisticsStore = defineStore('statistics', {
|
|||||||
querys.push('startTime=' + this.transactionStatisticsFilter.categoricalChartStartTime);
|
querys.push('startTime=' + this.transactionStatisticsFilter.categoricalChartStartTime);
|
||||||
querys.push('endTime=' + this.transactionStatisticsFilter.categoricalChartEndTime);
|
querys.push('endTime=' + this.transactionStatisticsFilter.categoricalChartEndTime);
|
||||||
}
|
}
|
||||||
} else if (analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
} else if (analysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||||
querys.push('chartType=' + this.transactionStatisticsFilter.trendChartType);
|
querys.push('chartType=' + this.transactionStatisticsFilter.trendChartType);
|
||||||
querys.push('chartDateType=' + this.transactionStatisticsFilter.trendChartDateType);
|
querys.push('chartDateType=' + this.transactionStatisticsFilter.trendChartDateType);
|
||||||
|
|
||||||
@@ -803,7 +811,7 @@ export const useStatisticsStore = defineStore('statistics', {
|
|||||||
querys.push('endTime=' + this.transactionStatisticsFilter.trendChartEndYearMonth);
|
querys.push('endTime=' + this.transactionStatisticsFilter.trendChartEndYearMonth);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trendDateAggregationType !== statisticsConstants.allDateAggregationTypes.Month.type) {
|
if (trendDateAggregationType !== ChartDateAggregationType.Month.type) {
|
||||||
querys.push('trendDateAggregationType=' + trendDateAggregationType);
|
querys.push('trendDateAggregationType=' + trendDateAggregationType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -841,31 +849,31 @@ export const useStatisticsStore = defineStore('statistics', {
|
|||||||
const transactionCategoriesStore = useTransactionCategoriesStore();
|
const transactionCategoriesStore = useTransactionCategoriesStore();
|
||||||
const querys = [];
|
const querys = [];
|
||||||
|
|
||||||
if (this.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.IncomeByAccount.type
|
if (this.transactionStatisticsFilter.chartDataType === ChartDataType.IncomeByAccount.type
|
||||||
|| this.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.IncomeByPrimaryCategory.type
|
|| this.transactionStatisticsFilter.chartDataType === ChartDataType.IncomeByPrimaryCategory.type
|
||||||
|| this.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.IncomeBySecondaryCategory.type
|
|| this.transactionStatisticsFilter.chartDataType === ChartDataType.IncomeBySecondaryCategory.type
|
||||||
|| this.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.TotalIncome.type) {
|
|| this.transactionStatisticsFilter.chartDataType === ChartDataType.TotalIncome.type) {
|
||||||
querys.push('type=2');
|
querys.push('type=2');
|
||||||
} else if (this.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.ExpenseByAccount.type
|
} else if (this.transactionStatisticsFilter.chartDataType === ChartDataType.ExpenseByAccount.type
|
||||||
|| this.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.ExpenseByPrimaryCategory.type
|
|| this.transactionStatisticsFilter.chartDataType === ChartDataType.ExpenseByPrimaryCategory.type
|
||||||
|| this.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.ExpenseBySecondaryCategory.type
|
|| this.transactionStatisticsFilter.chartDataType === ChartDataType.ExpenseBySecondaryCategory.type
|
||||||
|| this.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.TotalExpense.type) {
|
|| this.transactionStatisticsFilter.chartDataType === ChartDataType.TotalExpense.type) {
|
||||||
querys.push('type=3');
|
querys.push('type=3');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemId && (this.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.IncomeByAccount.type
|
if (itemId && (this.transactionStatisticsFilter.chartDataType === ChartDataType.IncomeByAccount.type
|
||||||
|| this.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.ExpenseByAccount.type
|
|| this.transactionStatisticsFilter.chartDataType === ChartDataType.ExpenseByAccount.type
|
||||||
|| this.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.AccountTotalAssets.type
|
|| this.transactionStatisticsFilter.chartDataType === ChartDataType.AccountTotalAssets.type
|
||||||
|| this.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.AccountTotalLiabilities.type)) {
|
|| this.transactionStatisticsFilter.chartDataType === ChartDataType.AccountTotalLiabilities.type)) {
|
||||||
querys.push('accountIds=' + itemId);
|
querys.push('accountIds=' + itemId);
|
||||||
|
|
||||||
if (!isObjectEmpty(this.transactionStatisticsFilter.filterCategoryIds)) {
|
if (!isObjectEmpty(this.transactionStatisticsFilter.filterCategoryIds)) {
|
||||||
querys.push('categoryIds=' + getFinalCategoryIdsByFilteredCategoryIds(transactionCategoriesStore.allTransactionCategoriesMap, this.transactionStatisticsFilter.filterCategoryIds));
|
querys.push('categoryIds=' + getFinalCategoryIdsByFilteredCategoryIds(transactionCategoriesStore.allTransactionCategoriesMap, this.transactionStatisticsFilter.filterCategoryIds));
|
||||||
}
|
}
|
||||||
} else if (itemId && (this.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.IncomeByPrimaryCategory.type
|
} else if (itemId && (this.transactionStatisticsFilter.chartDataType === ChartDataType.IncomeByPrimaryCategory.type
|
||||||
|| this.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.IncomeBySecondaryCategory.type
|
|| this.transactionStatisticsFilter.chartDataType === ChartDataType.IncomeBySecondaryCategory.type
|
||||||
|| this.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.ExpenseByPrimaryCategory.type
|
|| this.transactionStatisticsFilter.chartDataType === ChartDataType.ExpenseByPrimaryCategory.type
|
||||||
|| this.transactionStatisticsFilter.chartDataType === statisticsConstants.allChartDataTypes.ExpenseBySecondaryCategory.type)) {
|
|| this.transactionStatisticsFilter.chartDataType === ChartDataType.ExpenseBySecondaryCategory.type)) {
|
||||||
querys.push('categoryIds=' + itemId);
|
querys.push('categoryIds=' + itemId);
|
||||||
|
|
||||||
if (!isObjectEmpty(this.transactionStatisticsFilter.filterAccountIds)) {
|
if (!isObjectEmpty(this.transactionStatisticsFilter.filterAccountIds)) {
|
||||||
@@ -889,16 +897,16 @@ export const useStatisticsStore = defineStore('statistics', {
|
|||||||
querys.push('tagFilterType=' + this.transactionStatisticsFilter.tagFilterType);
|
querys.push('tagFilterType=' + this.transactionStatisticsFilter.tagFilterType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis
|
if (analysisType === StatisticsAnalysisType.CategoricalAnalysis
|
||||||
&& this.transactionStatisticsFilter.chartDataType !== statisticsConstants.allChartDataTypes.AccountTotalAssets.type
|
&& this.transactionStatisticsFilter.chartDataType !== ChartDataType.AccountTotalAssets.type
|
||||||
&& this.transactionStatisticsFilter.chartDataType !== statisticsConstants.allChartDataTypes.AccountTotalLiabilities.type) {
|
&& this.transactionStatisticsFilter.chartDataType !== ChartDataType.AccountTotalLiabilities.type) {
|
||||||
querys.push('dateType=' + this.transactionStatisticsFilter.categoricalChartDateType);
|
querys.push('dateType=' + this.transactionStatisticsFilter.categoricalChartDateType);
|
||||||
|
|
||||||
if (this.transactionStatisticsFilter.categoricalChartDateType === DateRange.Custom.type) {
|
if (this.transactionStatisticsFilter.categoricalChartDateType === DateRange.Custom.type) {
|
||||||
querys.push('minTime=' + this.transactionStatisticsFilter.categoricalChartStartTime);
|
querys.push('minTime=' + this.transactionStatisticsFilter.categoricalChartStartTime);
|
||||||
querys.push('maxTime=' + this.transactionStatisticsFilter.categoricalChartEndTime);
|
querys.push('maxTime=' + this.transactionStatisticsFilter.categoricalChartEndTime);
|
||||||
}
|
}
|
||||||
} else if (analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis && dateRange) {
|
} else if (analysisType === StatisticsAnalysisType.TrendAnalysis && dateRange) {
|
||||||
querys.push('dateType=' + dateRange.type);
|
querys.push('dateType=' + dateRange.type);
|
||||||
querys.push('minTime=' + dateRange.minTime);
|
querys.push('minTime=' + dateRange.minTime);
|
||||||
querys.push('maxTime=' + dateRange.maxTime);
|
querys.push('maxTime=' + dateRange.maxTime);
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ import { mapStores } from 'pinia';
|
|||||||
import { useSettingsStore } from '@/stores/setting.js';
|
import { useSettingsStore } from '@/stores/setting.js';
|
||||||
|
|
||||||
import { DateRangeScene } from '@/core/datetime.ts';
|
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 AccountFilterSettingsCard from '@/views/desktop/common/cards/AccountFilterSettingsCard.vue';
|
||||||
import CategoryFilterSettingsCard from '@/views/desktop/common/cards/CategoryFilterSettingsCard.vue';
|
import CategoryFilterSettingsCard from '@/views/desktop/common/cards/CategoryFilterSettingsCard.vue';
|
||||||
@@ -142,7 +142,7 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
...mapStores(useSettingsStore),
|
...mapStores(useSettingsStore),
|
||||||
allChartDataTypes() {
|
allChartDataTypes() {
|
||||||
return this.$locale.getAllStatisticsChartDataTypes(statisticsConstants.allAnalysisTypes.CategoricalAnalysis);
|
return this.$locale.getAllStatisticsChartDataTypes(StatisticsAnalysisType.CategoricalAnalysis);
|
||||||
},
|
},
|
||||||
allTimezoneTypesUsedForStatistics() {
|
allTimezoneTypesUsedForStatistics() {
|
||||||
return this.$locale.getAllTimezoneTypesUsedForStatistics();
|
return this.$locale.getAllTimezoneTypesUsedForStatistics();
|
||||||
|
|||||||
@@ -31,14 +31,14 @@
|
|||||||
class="mt-2"
|
class="mt-2"
|
||||||
density="compact"
|
density="compact"
|
||||||
:disabled="loading"
|
:disabled="loading"
|
||||||
:items="allSortingTypesArray"
|
:items="allSortingTypes"
|
||||||
v-model="querySortingType"
|
v-model="querySortingType"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<v-tabs show-arrows class="my-4" direction="vertical"
|
<v-tabs show-arrows class="my-4" direction="vertical"
|
||||||
:disabled="loading" v-model="queryChartDataType">
|
:disabled="loading" v-model="queryChartDataType">
|
||||||
<v-tab class="tab-text-truncate" :key="dataType.type" :value="dataType.type"
|
<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>
|
<span class="text-truncate">{{ $t(dataType.name) }}</span>
|
||||||
<v-tooltip activator="parent" location="right">{{ $t(dataType.name) }}</v-tooltip>
|
<v-tooltip activator="parent" location="right">{{ $t(dataType.name) }}</v-tooltip>
|
||||||
</v-tab>
|
</v-tab>
|
||||||
@@ -97,7 +97,7 @@
|
|||||||
<v-list-item class="cursor-pointer" :key="aggregationType.type" :value="aggregationType.type"
|
<v-list-item class="cursor-pointer" :key="aggregationType.type" :value="aggregationType.type"
|
||||||
:append-icon="(trendDateAggregationType === aggregationType.type ? icons.check : null)"
|
:append-icon="(trendDateAggregationType === aggregationType.type ? icons.check : null)"
|
||||||
:title="aggregationType.displayName"
|
:title="aggregationType.displayName"
|
||||||
v-for="aggregationType in allDateAggregationTypesArray"
|
v-for="aggregationType in allDateAggregationTypes"
|
||||||
@click="setTrendDateAggregationType(aggregationType.type)">
|
@click="setTrendDateAggregationType(aggregationType.type)">
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</v-list>
|
</v-list>
|
||||||
@@ -155,7 +155,7 @@
|
|||||||
<span class="statistics-subtitle statistics-overview-empty-tip">{{ $t('No transaction data') }}</span>
|
<span class="statistics-subtitle statistics-overview-empty-tip">{{ $t('No transaction data') }}</span>
|
||||||
</v-card-text>
|
</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
|
<pie-chart
|
||||||
:items="[
|
:items="[
|
||||||
{id: '1', name: '---', value: 60, color: '7c7c7f'},
|
{id: '1', name: '---', value: 60, color: '7c7c7f'},
|
||||||
@@ -185,7 +185,7 @@
|
|||||||
/>
|
/>
|
||||||
</v-card-text>
|
</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">
|
<v-list rounded lines="two" v-if="initing">
|
||||||
<template :key="itemIdx" v-for="itemIdx in [ 1, 2, 3 ]">
|
<template :key="itemIdx" v-for="itemIdx in [ 1, 2, 3 ]">
|
||||||
<v-list-item class="pl-0">
|
<v-list-item class="pl-0">
|
||||||
@@ -325,7 +325,13 @@ import { useStatisticsStore } from '@/stores/statistics.js';
|
|||||||
|
|
||||||
import { DateRangeScene, DateRange } from '@/core/datetime.ts';
|
import { DateRangeScene, DateRange } from '@/core/datetime.ts';
|
||||||
import { ThemeType } from '@/core/theme.ts';
|
import { ThemeType } from '@/core/theme.ts';
|
||||||
import statisticsConstants from '@/consts/statistics.js';
|
import {
|
||||||
|
StatisticsAnalysisType,
|
||||||
|
CategoricalChartType,
|
||||||
|
ChartDataType,
|
||||||
|
ChartSortingType,
|
||||||
|
ChartDateAggregationType
|
||||||
|
} from '@/core/statistics.ts';
|
||||||
import {
|
import {
|
||||||
isDefined,
|
isDefined,
|
||||||
limitText,
|
limitText,
|
||||||
@@ -341,7 +347,6 @@ import {
|
|||||||
getDateTypeByDateRange,
|
getDateTypeByDateRange,
|
||||||
getDateRangeByDateType
|
getDateRangeByDateType
|
||||||
} from '@/lib/datetime.ts';
|
} from '@/lib/datetime.ts';
|
||||||
import { isChartDataTypeAvailableForAnalysisType } from '@/lib/statistics.js';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
mdiCheck,
|
mdiCheck,
|
||||||
@@ -390,8 +395,8 @@ export default {
|
|||||||
loading: true,
|
loading: true,
|
||||||
alwaysShowNav: mdAndUp.value,
|
alwaysShowNav: mdAndUp.value,
|
||||||
showNav: mdAndUp.value,
|
showNav: mdAndUp.value,
|
||||||
analysisType: statisticsConstants.allAnalysisTypes.CategoricalAnalysis,
|
analysisType: StatisticsAnalysisType.CategoricalAnalysis,
|
||||||
trendDateAggregationType: statisticsConstants.defaultDateAggregationType,
|
trendDateAggregationType: ChartDateAggregationType.Default.type,
|
||||||
showCustomDateRangeDialog: false,
|
showCustomDateRangeDialog: false,
|
||||||
showCustomMonthRangeDialog: false,
|
showCustomMonthRangeDialog: false,
|
||||||
showFilterAccountDialog: false,
|
showFilterAccountDialog: false,
|
||||||
@@ -439,9 +444,9 @@ export default {
|
|||||||
},
|
},
|
||||||
queryChartType: {
|
queryChartType: {
|
||||||
get: function () {
|
get: function () {
|
||||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
return this.query.categoricalChartType;
|
return this.query.categoricalChartType;
|
||||||
} else if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
} else if (this.queryAnalysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||||
return this.query.trendChartType;
|
return this.query.trendChartType;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
@@ -468,69 +473,66 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
queryDateType() {
|
queryDateType() {
|
||||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
return this.query.categoricalChartDateType;
|
return this.query.categoricalChartDateType;
|
||||||
} else if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
} else if (this.queryAnalysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||||
return this.query.trendChartDateType;
|
return this.query.trendChartDateType;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
queryTrendDateAggregationTypeName() {
|
queryTrendDateAggregationTypeName() {
|
||||||
return getNameByKeyValue(this.allDateAggregationTypesArray, this.trendDateAggregationType, 'type', 'displayName', '');
|
return getNameByKeyValue(this.allDateAggregationTypes, this.trendDateAggregationType, 'type', 'displayName', '');
|
||||||
},
|
},
|
||||||
queryStartTime() {
|
queryStartTime() {
|
||||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
return this.$locale.formatUnixTimeToLongDateTime(this.userStore, this.query.categoricalChartStartTime);
|
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));
|
return this.$locale.formatUnixTimeToLongYearMonth(this.userStore, getYearMonthFirstUnixTime(this.query.trendChartStartYearMonth));
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
queryEndTime() {
|
queryEndTime() {
|
||||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
return this.$locale.formatUnixTimeToLongDateTime(this.userStore, this.query.categoricalChartEndTime);
|
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));
|
return this.$locale.formatUnixTimeToLongYearMonth(this.userStore, getYearMonthLastUnixTime(this.query.trendChartEndYearMonth));
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
allAnalysisTypes() {
|
allAnalysisTypes() {
|
||||||
return statisticsConstants.allAnalysisTypes;
|
return StatisticsAnalysisType;
|
||||||
},
|
},
|
||||||
allChartTypes() {
|
allChartTypes() {
|
||||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
return this.$locale.getAllCategoricalChartTypes();
|
return this.$locale.getAllCategoricalChartTypes();
|
||||||
} else if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
} else if (this.queryAnalysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||||
return this.$locale.getAllTrendChartTypes();
|
return this.$locale.getAllTrendChartTypes();
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
allCategoricalChartTypes() {
|
allCategoricalChartTypes() {
|
||||||
return statisticsConstants.allCategoricalChartTypes;
|
return CategoricalChartType.all();
|
||||||
},
|
},
|
||||||
allChartDataTypes() {
|
allChartDataTypes() {
|
||||||
return statisticsConstants.allChartDataTypes;
|
return ChartDataType.all();
|
||||||
},
|
},
|
||||||
allSortingTypes() {
|
allSortingTypes() {
|
||||||
return statisticsConstants.allSortingTypes;
|
|
||||||
},
|
|
||||||
allSortingTypesArray() {
|
|
||||||
return this.$locale.getAllStatisticsSortingTypes();
|
return this.$locale.getAllStatisticsSortingTypes();
|
||||||
},
|
},
|
||||||
allDateAggregationTypesArray() {
|
allDateAggregationTypes() {
|
||||||
return this.$locale.getAllStatisticsDateAggregationTypes();
|
return this.$locale.getAllStatisticsDateAggregationTypes();
|
||||||
},
|
},
|
||||||
allDateRanges() {
|
allDateRanges() {
|
||||||
return DateRange.all();
|
return DateRange.all();
|
||||||
},
|
},
|
||||||
allDateRangesArray() {
|
allDateRangesArray() {
|
||||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
return this.$locale.getAllDateRanges(DateRangeScene.Normal, true);
|
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);
|
return this.$locale.getAllDateRanges(DateRangeScene.TrendAnalysis, true);
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
@@ -540,17 +542,17 @@ export default {
|
|||||||
return this.settingsStore.appSettings.showAccountBalance;
|
return this.settingsStore.appSettings.showAccountBalance;
|
||||||
},
|
},
|
||||||
totalAmountName() {
|
totalAmountName() {
|
||||||
if (this.queryChartDataType === this.allChartDataTypes.IncomeByAccount.type
|
if (this.queryChartDataType === ChartDataType.IncomeByAccount.type
|
||||||
|| this.queryChartDataType === this.allChartDataTypes.IncomeByPrimaryCategory.type
|
|| this.queryChartDataType === ChartDataType.IncomeByPrimaryCategory.type
|
||||||
|| this.queryChartDataType === this.allChartDataTypes.IncomeBySecondaryCategory.type) {
|
|| this.queryChartDataType === ChartDataType.IncomeBySecondaryCategory.type) {
|
||||||
return this.$t('Total Income');
|
return this.$t('Total Income');
|
||||||
} else if (this.queryChartDataType === this.allChartDataTypes.ExpenseByAccount.type
|
} else if (this.queryChartDataType === ChartDataType.ExpenseByAccount.type
|
||||||
|| this.queryChartDataType === this.allChartDataTypes.ExpenseByPrimaryCategory.type
|
|| this.queryChartDataType === ChartDataType.ExpenseByPrimaryCategory.type
|
||||||
|| this.queryChartDataType === this.allChartDataTypes.ExpenseBySecondaryCategory.type) {
|
|| this.queryChartDataType === ChartDataType.ExpenseBySecondaryCategory.type) {
|
||||||
return this.$t('Total Expense');
|
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');
|
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');
|
return this.$t('Total Liabilities');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -563,23 +565,23 @@ export default {
|
|||||||
return this.statisticsStore.trendsAnalysisData;
|
return this.statisticsStore.trendsAnalysisData;
|
||||||
},
|
},
|
||||||
translateNameInTrendsChart() {
|
translateNameInTrendsChart() {
|
||||||
return this.queryChartDataType === this.allChartDataTypes.TotalExpense.type ||
|
return this.queryChartDataType === ChartDataType.TotalExpense.type ||
|
||||||
this.queryChartDataType === this.allChartDataTypes.TotalIncome.type ||
|
this.queryChartDataType === ChartDataType.TotalIncome.type ||
|
||||||
this.queryChartDataType === this.allChartDataTypes.TotalBalance.type;
|
this.queryChartDataType === ChartDataType.TotalBalance.type;
|
||||||
},
|
},
|
||||||
showTotalAmountInTrendsChart() {
|
showTotalAmountInTrendsChart() {
|
||||||
return this.queryChartDataType !== this.allChartDataTypes.TotalExpense.type &&
|
return this.queryChartDataType !== ChartDataType.TotalExpense.type &&
|
||||||
this.queryChartDataType !== this.allChartDataTypes.TotalIncome.type &&
|
this.queryChartDataType !== ChartDataType.TotalIncome.type &&
|
||||||
this.queryChartDataType !== this.allChartDataTypes.TotalBalance.type;
|
this.queryChartDataType !== ChartDataType.TotalBalance.type;
|
||||||
},
|
},
|
||||||
statisticsTextColor() {
|
statisticsTextColor() {
|
||||||
if (this.queryChartDataType === this.allChartDataTypes.ExpenseByAccount.type ||
|
if (this.queryChartDataType === ChartDataType.ExpenseByAccount.type ||
|
||||||
this.queryChartDataType === this.allChartDataTypes.ExpenseByPrimaryCategory.type ||
|
this.queryChartDataType === ChartDataType.ExpenseByPrimaryCategory.type ||
|
||||||
this.queryChartDataType === this.allChartDataTypes.ExpenseBySecondaryCategory.type) {
|
this.queryChartDataType === ChartDataType.ExpenseBySecondaryCategory.type) {
|
||||||
return 'text-expense';
|
return 'text-expense';
|
||||||
} else if (this.queryChartDataType === this.allChartDataTypes.IncomeByAccount.type ||
|
} else if (this.queryChartDataType === ChartDataType.IncomeByAccount.type ||
|
||||||
this.queryChartDataType === this.allChartDataTypes.IncomeByPrimaryCategory.type ||
|
this.queryChartDataType === ChartDataType.IncomeByPrimaryCategory.type ||
|
||||||
this.queryChartDataType === this.allChartDataTypes.IncomeBySecondaryCategory.type) {
|
this.queryChartDataType === ChartDataType.IncomeBySecondaryCategory.type) {
|
||||||
return 'text-income';
|
return 'text-income';
|
||||||
} else {
|
} else {
|
||||||
return 'text-default';
|
return 'text-default';
|
||||||
@@ -587,7 +589,7 @@ export default {
|
|||||||
},
|
},
|
||||||
showAmountInChart() {
|
showAmountInChart() {
|
||||||
if (!this.showAccountBalance
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -662,7 +664,7 @@ export default {
|
|||||||
sortingType: query.sortingType ? parseInt(query.sortingType) : undefined
|
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.categoricalChartType = query.chartType ? parseInt(query.chartType) : undefined;
|
||||||
filter.categoricalChartDateType = query.chartDateType ? parseInt(query.chartDateType) : undefined;
|
filter.categoricalChartDateType = query.chartDateType ? parseInt(query.chartDateType) : undefined;
|
||||||
filter.categoricalChartStartTime = query.startTime ? parseInt(query.startTime) : undefined;
|
filter.categoricalChartStartTime = query.startTime ? parseInt(query.startTime) : undefined;
|
||||||
@@ -678,10 +680,10 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (query.analysisType !== self.queryAnalysisType.toString()) {
|
if (query.analysisType !== self.queryAnalysisType.toString()) {
|
||||||
self.analysisType = statisticsConstants.allAnalysisTypes.CategoricalAnalysis;
|
self.analysisType = StatisticsAnalysisType.CategoricalAnalysis;
|
||||||
needReload = true;
|
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.trendChartType = query.chartType ? parseInt(query.chartType) : undefined;
|
||||||
filter.trendChartDateType = query.chartDateType ? parseInt(query.chartDateType) : undefined;
|
filter.trendChartDateType = query.chartDateType ? parseInt(query.chartDateType) : undefined;
|
||||||
filter.trendChartStartYearMonth = query.startTime;
|
filter.trendChartStartYearMonth = query.startTime;
|
||||||
@@ -697,7 +699,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (query.analysisType !== self.queryAnalysisType.toString()) {
|
if (query.analysisType !== self.queryAnalysisType.toString()) {
|
||||||
self.analysisType = statisticsConstants.allAnalysisTypes.TrendAnalysis;
|
self.analysisType = StatisticsAnalysisType.TrendAnalysis;
|
||||||
needReload = true;
|
needReload = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -707,7 +709,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isDefined(query.analysisType)) {
|
if (!isDefined(query.analysisType)) {
|
||||||
self.analysisType = statisticsConstants.allAnalysisTypes.CategoricalAnalysis;
|
self.analysisType = StatisticsAnalysisType.CategoricalAnalysis;
|
||||||
filter = null;
|
filter = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -723,11 +725,11 @@ export default {
|
|||||||
self.accountsStore.loadAllAccounts({force: false}),
|
self.accountsStore.loadAllAccounts({force: false}),
|
||||||
self.transactionCategoriesStore.loadAllCategories({force: false})
|
self.transactionCategoriesStore.loadAllCategories({force: false})
|
||||||
]).then(() => {
|
]).then(() => {
|
||||||
if (self.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (self.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
return self.statisticsStore.loadCategoricalAnalysis({
|
return self.statisticsStore.loadCategoricalAnalysis({
|
||||||
force: false
|
force: false
|
||||||
});
|
});
|
||||||
} else if (self.queryAnalysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
} else if (self.queryAnalysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||||
return self.statisticsStore.loadTrendAnalysis({
|
return self.statisticsStore.loadTrendAnalysis({
|
||||||
force: false
|
force: false
|
||||||
});
|
});
|
||||||
@@ -750,26 +752,26 @@ export default {
|
|||||||
|
|
||||||
self.loading = true;
|
self.loading = true;
|
||||||
|
|
||||||
if (self.queryChartDataType === self.allChartDataTypes.ExpenseByAccount.type ||
|
if (self.queryChartDataType === ChartDataType.ExpenseByAccount.type ||
|
||||||
self.queryChartDataType === self.allChartDataTypes.ExpenseByPrimaryCategory.type ||
|
self.queryChartDataType === ChartDataType.ExpenseByPrimaryCategory.type ||
|
||||||
self.queryChartDataType === self.allChartDataTypes.ExpenseBySecondaryCategory.type ||
|
self.queryChartDataType === ChartDataType.ExpenseBySecondaryCategory.type ||
|
||||||
self.queryChartDataType === self.allChartDataTypes.IncomeByAccount.type ||
|
self.queryChartDataType === ChartDataType.IncomeByAccount.type ||
|
||||||
self.queryChartDataType === self.allChartDataTypes.IncomeByPrimaryCategory.type ||
|
self.queryChartDataType === ChartDataType.IncomeByPrimaryCategory.type ||
|
||||||
self.queryChartDataType === self.allChartDataTypes.IncomeBySecondaryCategory.type ||
|
self.queryChartDataType === ChartDataType.IncomeBySecondaryCategory.type ||
|
||||||
self.queryChartDataType === self.allChartDataTypes.TotalExpense.type ||
|
self.queryChartDataType === ChartDataType.TotalExpense.type ||
|
||||||
self.queryChartDataType === self.allChartDataTypes.TotalIncome.type ||
|
self.queryChartDataType === ChartDataType.TotalIncome.type ||
|
||||||
self.queryChartDataType === self.allChartDataTypes.TotalBalance.type) {
|
self.queryChartDataType === ChartDataType.TotalBalance.type) {
|
||||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
dispatchPromise = self.statisticsStore.loadCategoricalAnalysis({
|
dispatchPromise = self.statisticsStore.loadCategoricalAnalysis({
|
||||||
force: force
|
force: force
|
||||||
});
|
});
|
||||||
} else if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
} else if (this.queryAnalysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||||
dispatchPromise = self.statisticsStore.loadTrendAnalysis({
|
dispatchPromise = self.statisticsStore.loadTrendAnalysis({
|
||||||
force: force
|
force: force
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (self.queryChartDataType === self.allChartDataTypes.AccountTotalAssets.type ||
|
} else if (self.queryChartDataType === ChartDataType.AccountTotalAssets.type ||
|
||||||
self.queryChartDataType === self.allChartDataTypes.AccountTotalLiabilities.type) {
|
self.queryChartDataType === ChartDataType.AccountTotalLiabilities.type) {
|
||||||
dispatchPromise = self.accountsStore.loadAllAccounts({
|
dispatchPromise = self.accountsStore.loadAllAccounts({
|
||||||
force: force
|
force: force
|
||||||
});
|
});
|
||||||
@@ -798,14 +800,14 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isChartDataTypeAvailableForAnalysisType(this.queryChartDataType, analysisType)) {
|
if (!ChartDataType.isAvailableForAnalysisType(this.queryChartDataType, analysisType)) {
|
||||||
this.statisticsStore.updateTransactionStatisticsFilter({
|
this.statisticsStore.updateTransactionStatisticsFilter({
|
||||||
chartDataType: statisticsConstants.defaultChartDataType
|
chartDataType: ChartDataType.Default.type
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.analysisType !== statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
if (this.analysisType !== StatisticsAnalysisType.TrendAnalysis) {
|
||||||
this.trendDateAggregationType = statisticsConstants.allDateAggregationTypes.Month.type;
|
this.trendDateAggregationType = ChartDateAggregationType.Month.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.analysisType = analysisType;
|
this.analysisType = analysisType;
|
||||||
@@ -816,11 +818,11 @@ export default {
|
|||||||
setChartType(chartType) {
|
setChartType(chartType) {
|
||||||
let changed = false;
|
let changed = false;
|
||||||
|
|
||||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
||||||
categoricalChartType: chartType
|
categoricalChartType: chartType
|
||||||
});
|
});
|
||||||
} else if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
} else if (this.queryAnalysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||||
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
||||||
trendChartType: chartType
|
trendChartType: chartType
|
||||||
});
|
});
|
||||||
@@ -840,7 +842,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
setSortingType(sortingType) {
|
setSortingType(sortingType) {
|
||||||
if (sortingType < this.allSortingTypes.Amount.type || sortingType > this.allSortingTypes.Name.type) {
|
if (sortingType < ChartSortingType.Amount.type || sortingType > ChartSortingType.Name.type) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -861,14 +863,14 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
setDateFilter(dateType) {
|
setDateFilter(dateType) {
|
||||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
if (dateType === this.allDateRanges.Custom.type) { // Custom
|
if (dateType === this.allDateRanges.Custom.type) { // Custom
|
||||||
this.showCustomDateRangeDialog = true;
|
this.showCustomDateRangeDialog = true;
|
||||||
return;
|
return;
|
||||||
} else if (this.query.categoricalChartDateType === dateType) {
|
} else if (this.query.categoricalChartDateType === dateType) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
} else if (this.queryAnalysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||||
if (dateType === this.allDateRanges.Custom.type) { // Custom
|
if (dateType === this.allDateRanges.Custom.type) { // Custom
|
||||||
this.showCustomMonthRangeDialog = true;
|
this.showCustomMonthRangeDialog = true;
|
||||||
return;
|
return;
|
||||||
@@ -885,13 +887,13 @@ export default {
|
|||||||
|
|
||||||
let changed = false;
|
let changed = false;
|
||||||
|
|
||||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
||||||
categoricalChartDateType: dateRange.dateType,
|
categoricalChartDateType: dateRange.dateType,
|
||||||
categoricalChartStartTime: dateRange.minTime,
|
categoricalChartStartTime: dateRange.minTime,
|
||||||
categoricalChartEndTime: dateRange.maxTime
|
categoricalChartEndTime: dateRange.maxTime
|
||||||
});
|
});
|
||||||
} else if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
} else if (this.queryAnalysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||||
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
||||||
trendChartDateType: dateRange.dateType,
|
trendChartDateType: dateRange.dateType,
|
||||||
trendChartStartYearMonth: getYearAndMonthFromUnixTime(dateRange.minTime),
|
trendChartStartYearMonth: getYearAndMonthFromUnixTime(dateRange.minTime),
|
||||||
@@ -912,7 +914,7 @@ export default {
|
|||||||
|
|
||||||
let changed = false;
|
let changed = false;
|
||||||
|
|
||||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
const chartDateType = getDateTypeByDateRange(startTime, endTime, this.firstDayOfWeek, DateRangeScene.Normal);
|
const chartDateType = getDateTypeByDateRange(startTime, endTime, this.firstDayOfWeek, DateRangeScene.Normal);
|
||||||
|
|
||||||
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
||||||
@@ -922,7 +924,7 @@ export default {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.showCustomDateRangeDialog = false;
|
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);
|
const chartDateType = getDateTypeByDateRange(getYearMonthFirstUnixTime(startTime), getYearMonthLastUnixTime(endTime), this.firstDayOfWeek, DateRangeScene.TrendAnalysis);
|
||||||
|
|
||||||
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
||||||
@@ -941,22 +943,22 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
showCustomDateRange() {
|
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;
|
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;
|
return this.query.trendChartDateType === this.allDateRanges.Custom.type && this.query.trendChartStartYearMonth && this.query.trendChartEndYearMonth;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
canShiftDateRange() {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.queryAnalysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (this.queryAnalysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
return this.query.categoricalChartDateType !== this.allDateRanges.All.type;
|
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;
|
return this.query.trendChartDateType !== this.allDateRanges.All.type;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@@ -969,7 +971,7 @@ export default {
|
|||||||
|
|
||||||
let changed = false;
|
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);
|
const newDateRange = getShiftedDateRangeAndDateType(this.query.categoricalChartStartTime, this.query.categoricalChartEndTime, scale, this.firstDayOfWeek, DateRangeScene.Normal);
|
||||||
|
|
||||||
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
||||||
@@ -977,7 +979,7 @@ export default {
|
|||||||
categoricalChartStartTime: newDateRange.minTime,
|
categoricalChartStartTime: newDateRange.minTime,
|
||||||
categoricalChartEndTime: newDateRange.maxTime
|
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);
|
const newDateRange = getShiftedDateRangeAndDateType(getYearMonthFirstUnixTime(this.query.trendChartStartYearMonth), getYearMonthLastUnixTime(this.query.trendChartEndYearMonth), scale, this.firstDayOfWeek, DateRangeScene.TrendAnalysis);
|
||||||
|
|
||||||
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
||||||
@@ -994,14 +996,14 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
dateRangeName() {
|
dateRangeName() {
|
||||||
if (this.queryChartDataType === this.allChartDataTypes.AccountTotalAssets.type ||
|
if (this.queryChartDataType === ChartDataType.AccountTotalAssets.type ||
|
||||||
this.queryChartDataType === this.allChartDataTypes.AccountTotalLiabilities.type) {
|
this.queryChartDataType === ChartDataType.AccountTotalLiabilities.type) {
|
||||||
return this.$t(this.allDateRanges.All.name);
|
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);
|
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));
|
return this.$locale.getDateRangeDisplayName(this.userStore, this.query.trendChartDateType, getYearMonthFirstUnixTime(this.query.trendChartStartYearMonth), getYearMonthLastUnixTime(this.query.trendChartEndYearMonth));
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
@@ -1044,8 +1046,8 @@ export default {
|
|||||||
amount = this.getDisplayCurrency(amount, currency);
|
amount = this.getDisplayCurrency(amount, currency);
|
||||||
|
|
||||||
if (!this.showAccountBalance
|
if (!this.showAccountBalance
|
||||||
&& (this.queryChartDataType === this.allChartDataTypes.AccountTotalAssets.type
|
&& (this.queryChartDataType === ChartDataType.AccountTotalAssets.type
|
||||||
|| this.queryChartDataType === this.allChartDataTypes.AccountTotalLiabilities.type)
|
|| this.queryChartDataType === ChartDataType.AccountTotalLiabilities.type)
|
||||||
) {
|
) {
|
||||||
return '***';
|
return '***';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,16 +64,6 @@
|
|||||||
|
|
||||||
<f7-block-title>{{ $t('Trend Analysis Settings') }}</f7-block-title>
|
<f7-block-title>{{ $t('Trend Analysis Settings') }}</f7-block-title>
|
||||||
<f7-list strong inset dividers>
|
<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
|
<f7-list-item
|
||||||
:title="$t('Default Date Range')"
|
: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') }">
|
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 { useSettingsStore } from '@/stores/setting.js';
|
||||||
|
|
||||||
import { DateRangeScene } from '@/core/datetime.ts';
|
import { DateRangeScene } from '@/core/datetime.ts';
|
||||||
import statisticsConstants from '@/consts/statistics.js';
|
import { StatisticsAnalysisType } from '@/core/statistics.ts';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
computed: {
|
computed: {
|
||||||
...mapStores(useSettingsStore),
|
...mapStores(useSettingsStore),
|
||||||
allChartDataTypes() {
|
allChartDataTypes() {
|
||||||
return this.$locale.getAllStatisticsChartDataTypes(statisticsConstants.allAnalysisTypes.CategoricalAnalysis);
|
return this.$locale.getAllStatisticsChartDataTypes(StatisticsAnalysisType.CategoricalAnalysis);
|
||||||
},
|
},
|
||||||
allTimezoneTypesUsedForStatistics() {
|
allTimezoneTypesUsedForStatistics() {
|
||||||
return this.$locale.getAllTimezoneTypesUsedForStatistics();
|
return this.$locale.getAllTimezoneTypesUsedForStatistics();
|
||||||
@@ -112,9 +102,6 @@ export default {
|
|||||||
allCategoricalChartDateRanges() {
|
allCategoricalChartDateRanges() {
|
||||||
return this.$locale.getAllDateRanges(DateRangeScene.Normal, false);
|
return this.$locale.getAllDateRanges(DateRangeScene.Normal, false);
|
||||||
},
|
},
|
||||||
allTrendChartTypes() {
|
|
||||||
return this.$locale.getAllTrendChartTypes();
|
|
||||||
},
|
|
||||||
allTrendChartDateRanges() {
|
allTrendChartDateRanges() {
|
||||||
return this.$locale.getAllDateRanges(DateRangeScene.TrendAnalysis, false);
|
return this.$locale.getAllDateRanges(DateRangeScene.TrendAnalysis, false);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
:class="{ 'list-item-selected': analysisType === allAnalysisTypes.CategoricalAnalysis && query.chartDataType === dataType.type }"
|
:class="{ 'list-item-selected': analysisType === allAnalysisTypes.CategoricalAnalysis && query.chartDataType === dataType.type }"
|
||||||
:key="dataType.type"
|
:key="dataType.type"
|
||||||
v-for="dataType in allChartDataTypes"
|
v-for="dataType in allChartDataTypes"
|
||||||
v-show="dataType.availableAnalysisTypes[allAnalysisTypes.CategoricalAnalysis]"
|
v-show="dataType.isAvailableAnalysisType(allAnalysisTypes.CategoricalAnalysis)"
|
||||||
@click="setChartDataType(allAnalysisTypes.CategoricalAnalysis, dataType.type)">
|
@click="setChartDataType(allAnalysisTypes.CategoricalAnalysis, dataType.type)">
|
||||||
<template #after>
|
<template #after>
|
||||||
<f7-icon class="list-item-checked-icon" f7="checkmark_alt" v-if="analysisType === allAnalysisTypes.CategoricalAnalysis && query.chartDataType === dataType.type"></f7-icon>
|
<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 }"
|
:class="{ 'list-item-selected': analysisType === allAnalysisTypes.TrendAnalysis && query.chartDataType === dataType.type }"
|
||||||
:key="dataType.type"
|
:key="dataType.type"
|
||||||
v-for="dataType in allChartDataTypes"
|
v-for="dataType in allChartDataTypes"
|
||||||
v-show="dataType.availableAnalysisTypes[allAnalysisTypes.TrendAnalysis]"
|
v-show="dataType.isAvailableAnalysisType(allAnalysisTypes.TrendAnalysis)"
|
||||||
@click="setChartDataType(allAnalysisTypes.TrendAnalysis, dataType.type)">
|
@click="setChartDataType(allAnalysisTypes.TrendAnalysis, dataType.type)">
|
||||||
<template #after>
|
<template #after>
|
||||||
<f7-icon class="list-item-checked-icon" f7="checkmark_alt" v-if="analysisType === allAnalysisTypes.TrendAnalysis && query.chartDataType === dataType.type"></f7-icon>
|
<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-list>
|
||||||
</f7-popover>
|
</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">
|
<f7-card-header class="no-border display-block">
|
||||||
<div class="statistics-chart-header full-line text-align-right">
|
<div class="statistics-chart-header full-line text-align-right">
|
||||||
<span style="margin-right: 4px;">{{ $t('Sort by') }}</span>
|
<span style="margin-right: 4px;">{{ $t('Sort by') }}</span>
|
||||||
@@ -94,7 +94,7 @@
|
|||||||
</f7-card-content>
|
</f7-card-content>
|
||||||
</f7-card>
|
</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">
|
<f7-card-header class="no-border display-block">
|
||||||
<div class="statistics-chart-header display-flex full-line justify-content-space-between">
|
<div class="statistics-chart-header display-flex full-line justify-content-space-between">
|
||||||
<div>
|
<div>
|
||||||
@@ -221,7 +221,7 @@
|
|||||||
<f7-popover class="sorting-type-popover-menu"
|
<f7-popover class="sorting-type-popover-menu"
|
||||||
v-model:opened="showSortingTypePopover">
|
v-model:opened="showSortingTypePopover">
|
||||||
<f7-list dividers>
|
<f7-list dividers>
|
||||||
<f7-list-item :title="$t(sortingType.name)"
|
<f7-list-item :title="sortingType.displayName"
|
||||||
:class="{ 'list-item-selected': query.sortingType === sortingType.type }"
|
:class="{ 'list-item-selected': query.sortingType === sortingType.type }"
|
||||||
:key="sortingType.type"
|
:key="sortingType.type"
|
||||||
v-for="sortingType in allSortingTypes"
|
v-for="sortingType in allSortingTypes"
|
||||||
@@ -284,7 +284,7 @@
|
|||||||
<f7-list-item :title="aggregationType.displayName"
|
<f7-list-item :title="aggregationType.displayName"
|
||||||
:class="{ 'list-item-selected': trendDateAggregationType === aggregationType.type }"
|
:class="{ 'list-item-selected': trendDateAggregationType === aggregationType.type }"
|
||||||
:key="aggregationType.type"
|
:key="aggregationType.type"
|
||||||
v-for="aggregationType in allDateAggregationTypesArray"
|
v-for="aggregationType in allDateAggregationTypes"
|
||||||
@click="setTrendDateAggregationType(aggregationType.type)">
|
@click="setTrendDateAggregationType(aggregationType.type)">
|
||||||
<template #after>
|
<template #after>
|
||||||
<f7-icon class="list-item-checked-icon" f7="checkmark_alt" v-if="trendDateAggregationType === aggregationType.type"></f7-icon>
|
<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 { useStatisticsStore } from '@/stores/statistics.js';
|
||||||
|
|
||||||
import { DateRangeScene, DateRange } from '@/core/datetime.ts';
|
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 { getNameByKeyValue, limitText } from '@/lib/common.ts';
|
||||||
import { formatPercent } from '@/lib/numeral.ts';
|
import { formatPercent } from '@/lib/numeral.ts';
|
||||||
import {
|
import {
|
||||||
@@ -343,7 +349,6 @@ import {
|
|||||||
getDateTypeByDateRange,
|
getDateTypeByDateRange,
|
||||||
getDateRangeByDateType
|
getDateRangeByDateType
|
||||||
} from '@/lib/datetime.ts';
|
} from '@/lib/datetime.ts';
|
||||||
import { isChartDataTypeAvailableForAnalysisType } from '@/lib/statistics.js';
|
|
||||||
import { scrollToSelectedItem } from '@/lib/ui/mobile.js';
|
import { scrollToSelectedItem } from '@/lib/ui/mobile.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -355,8 +360,8 @@ export default {
|
|||||||
loading: true,
|
loading: true,
|
||||||
loadingError: null,
|
loadingError: null,
|
||||||
reloading: false,
|
reloading: false,
|
||||||
analysisType: statisticsConstants.allAnalysisTypes.CategoricalAnalysis,
|
analysisType: StatisticsAnalysisType.CategoricalAnalysis,
|
||||||
trendDateAggregationType: statisticsConstants.defaultDateAggregationType,
|
trendDateAggregationType: ChartDateAggregationType.Default.type,
|
||||||
showChartDataTypePopover: false,
|
showChartDataTypePopover: false,
|
||||||
showSortingTypePopover: false,
|
showSortingTypePopover: false,
|
||||||
showDatePopover: false,
|
showDatePopover: false,
|
||||||
@@ -372,7 +377,7 @@ export default {
|
|||||||
return this.userStore.currentUserDefaultCurrency;
|
return this.userStore.currentUserDefaultCurrency;
|
||||||
},
|
},
|
||||||
defaultTrendDateAggregationType() {
|
defaultTrendDateAggregationType() {
|
||||||
return statisticsConstants.defaultDateAggregationType;
|
return ChartDateAggregationType.Default.type;
|
||||||
},
|
},
|
||||||
firstDayOfWeek() {
|
firstDayOfWeek() {
|
||||||
return this.userStore.currentUserFirstDayOfWeek;
|
return this.userStore.currentUserFirstDayOfWeek;
|
||||||
@@ -385,9 +390,9 @@ export default {
|
|||||||
},
|
},
|
||||||
queryChartType: {
|
queryChartType: {
|
||||||
get: function () {
|
get: function () {
|
||||||
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (this.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
return this.query.categoricalChartType;
|
return this.query.categoricalChartType;
|
||||||
} else if (this.analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
} else if (this.analysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||||
return this.query.trendChartType;
|
return this.query.trendChartType;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
@@ -398,72 +403,72 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
queryChartDataTypeName() {
|
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);
|
return this.$t(queryChartDataTypeName);
|
||||||
},
|
},
|
||||||
querySortingTypeName() {
|
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);
|
return this.$t(querySortingTypeName);
|
||||||
},
|
},
|
||||||
queryDateType() {
|
queryDateType() {
|
||||||
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (this.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
return this.query.categoricalChartDateType;
|
return this.query.categoricalChartDateType;
|
||||||
} else if (this.analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
} else if (this.analysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||||
return this.query.trendChartDateType;
|
return this.query.trendChartDateType;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
queryTrendDateAggregationTypeName() {
|
queryTrendDateAggregationTypeName() {
|
||||||
return getNameByKeyValue(this.allDateAggregationTypesArray, this.trendDateAggregationType, 'type', 'displayName', '');
|
return getNameByKeyValue(this.allDateAggregationTypes, this.trendDateAggregationType, 'type', 'displayName', '');
|
||||||
},
|
},
|
||||||
queryStartTime() {
|
queryStartTime() {
|
||||||
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (this.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
return this.$locale.formatUnixTimeToLongDateTime(this.userStore, this.query.categoricalChartStartTime);
|
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));
|
return this.$locale.formatUnixTimeToLongYearMonth(this.userStore, getYearMonthFirstUnixTime(this.query.trendChartStartYearMonth));
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
queryEndTime() {
|
queryEndTime() {
|
||||||
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (this.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
return this.$locale.formatUnixTimeToLongDateTime(this.userStore, this.query.categoricalChartEndTime);
|
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));
|
return this.$locale.formatUnixTimeToLongYearMonth(this.userStore, getYearMonthLastUnixTime(this.query.trendChartEndYearMonth));
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
allAnalysisTypes() {
|
allAnalysisTypes() {
|
||||||
return statisticsConstants.allAnalysisTypes;
|
return StatisticsAnalysisType;
|
||||||
},
|
},
|
||||||
allChartTypes() {
|
allChartTypes() {
|
||||||
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (this.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
return this.$locale.getAllCategoricalChartTypes();
|
return this.$locale.getAllCategoricalChartTypes();
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
allCategoricalChartTypes() {
|
allCategoricalChartTypes() {
|
||||||
return statisticsConstants.allCategoricalChartTypes;
|
return CategoricalChartType.all();
|
||||||
},
|
},
|
||||||
allChartDataTypes() {
|
allChartDataTypes() {
|
||||||
return statisticsConstants.allChartDataTypes;
|
return ChartDataType.all();
|
||||||
},
|
},
|
||||||
allSortingTypes() {
|
allSortingTypes() {
|
||||||
return statisticsConstants.allSortingTypes;
|
return this.$locale.getAllStatisticsSortingTypes();
|
||||||
},
|
},
|
||||||
allDateAggregationTypesArray() {
|
allDateAggregationTypes() {
|
||||||
return this.$locale.getAllStatisticsDateAggregationTypes();
|
return this.$locale.getAllStatisticsDateAggregationTypes();
|
||||||
},
|
},
|
||||||
allDateRanges() {
|
allDateRanges() {
|
||||||
return DateRange.all();
|
return DateRange.all();
|
||||||
},
|
},
|
||||||
allDateRangesArray() {
|
allDateRangesArray() {
|
||||||
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (this.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
return this.$locale.getAllDateRanges(DateRangeScene.Normal, true);
|
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);
|
return this.$locale.getAllDateRanges(DateRangeScene.TrendAnalysis, true);
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
@@ -473,17 +478,17 @@ export default {
|
|||||||
return this.settingsStore.appSettings.showAccountBalance;
|
return this.settingsStore.appSettings.showAccountBalance;
|
||||||
},
|
},
|
||||||
totalAmountName() {
|
totalAmountName() {
|
||||||
if (this.query.chartDataType === this.allChartDataTypes.IncomeByAccount.type
|
if (this.query.chartDataType === ChartDataType.IncomeByAccount.type
|
||||||
|| this.query.chartDataType === this.allChartDataTypes.IncomeByPrimaryCategory.type
|
|| this.query.chartDataType === ChartDataType.IncomeByPrimaryCategory.type
|
||||||
|| this.query.chartDataType === this.allChartDataTypes.IncomeBySecondaryCategory.type) {
|
|| this.query.chartDataType === ChartDataType.IncomeBySecondaryCategory.type) {
|
||||||
return this.$t('Total Income');
|
return this.$t('Total Income');
|
||||||
} else if (this.query.chartDataType === this.allChartDataTypes.ExpenseByAccount.type
|
} else if (this.query.chartDataType === ChartDataType.ExpenseByAccount.type
|
||||||
|| this.query.chartDataType === this.allChartDataTypes.ExpenseByPrimaryCategory.type
|
|| this.query.chartDataType === ChartDataType.ExpenseByPrimaryCategory.type
|
||||||
|| this.query.chartDataType === this.allChartDataTypes.ExpenseBySecondaryCategory.type) {
|
|| this.query.chartDataType === ChartDataType.ExpenseBySecondaryCategory.type) {
|
||||||
return this.$t('Total Expense');
|
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');
|
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');
|
return this.$t('Total Liabilities');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -496,13 +501,13 @@ export default {
|
|||||||
return this.statisticsStore.trendsAnalysisData;
|
return this.statisticsStore.trendsAnalysisData;
|
||||||
},
|
},
|
||||||
translateNameInTrendsChart() {
|
translateNameInTrendsChart() {
|
||||||
return this.query.chartDataType === this.allChartDataTypes.TotalExpense.type ||
|
return this.query.chartDataType === ChartDataType.TotalExpense.type ||
|
||||||
this.query.chartDataType === this.allChartDataTypes.TotalIncome.type ||
|
this.query.chartDataType === ChartDataType.TotalIncome.type ||
|
||||||
this.query.chartDataType === this.allChartDataTypes.TotalBalance.type;
|
this.query.chartDataType === ChartDataType.TotalBalance.type;
|
||||||
},
|
},
|
||||||
showAmountInChart() {
|
showAmountInChart() {
|
||||||
if (!this.showAccountBalance
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -518,11 +523,11 @@ export default {
|
|||||||
self.accountsStore.loadAllAccounts({ force: false }),
|
self.accountsStore.loadAllAccounts({ force: false }),
|
||||||
self.transactionCategoriesStore.loadAllCategories({ force: false })
|
self.transactionCategoriesStore.loadAllCategories({ force: false })
|
||||||
]).then(() => {
|
]).then(() => {
|
||||||
if (self.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (self.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
return self.statisticsStore.loadCategoricalAnalysis({
|
return self.statisticsStore.loadCategoricalAnalysis({
|
||||||
force: false
|
force: false
|
||||||
});
|
});
|
||||||
} else if (self.analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
} else if (self.analysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||||
return self.statisticsStore.loadTrendAnalysis({
|
return self.statisticsStore.loadTrendAnalysis({
|
||||||
force: false
|
force: false
|
||||||
});
|
});
|
||||||
@@ -553,26 +558,26 @@ export default {
|
|||||||
|
|
||||||
self.reloading = true;
|
self.reloading = true;
|
||||||
|
|
||||||
if (self.query.chartDataType === self.allChartDataTypes.ExpenseByAccount.type ||
|
if (self.query.chartDataType === ChartDataType.ExpenseByAccount.type ||
|
||||||
self.query.chartDataType === self.allChartDataTypes.ExpenseByPrimaryCategory.type ||
|
self.query.chartDataType === ChartDataType.ExpenseByPrimaryCategory.type ||
|
||||||
self.query.chartDataType === self.allChartDataTypes.ExpenseBySecondaryCategory.type ||
|
self.query.chartDataType === ChartDataType.ExpenseBySecondaryCategory.type ||
|
||||||
self.query.chartDataType === self.allChartDataTypes.IncomeByAccount.type ||
|
self.query.chartDataType === ChartDataType.IncomeByAccount.type ||
|
||||||
self.query.chartDataType === self.allChartDataTypes.IncomeByPrimaryCategory.type ||
|
self.query.chartDataType === ChartDataType.IncomeByPrimaryCategory.type ||
|
||||||
self.query.chartDataType === self.allChartDataTypes.IncomeBySecondaryCategory.type ||
|
self.query.chartDataType === ChartDataType.IncomeBySecondaryCategory.type ||
|
||||||
self.query.chartDataType === self.allChartDataTypes.TotalExpense.type ||
|
self.query.chartDataType === ChartDataType.TotalExpense.type ||
|
||||||
self.query.chartDataType === self.allChartDataTypes.TotalIncome.type ||
|
self.query.chartDataType === ChartDataType.TotalIncome.type ||
|
||||||
self.query.chartDataType === self.allChartDataTypes.TotalBalance.type) {
|
self.query.chartDataType === ChartDataType.TotalBalance.type) {
|
||||||
if (self.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (self.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
dispatchPromise = self.statisticsStore.loadCategoricalAnalysis({
|
dispatchPromise = self.statisticsStore.loadCategoricalAnalysis({
|
||||||
force: force
|
force: force
|
||||||
});
|
});
|
||||||
} else if (self.analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
} else if (self.analysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||||
dispatchPromise = self.statisticsStore.loadTrendAnalysis({
|
dispatchPromise = self.statisticsStore.loadTrendAnalysis({
|
||||||
force: force
|
force: force
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (self.query.chartDataType === self.allChartDataTypes.AccountTotalAssets.type ||
|
} else if (self.query.chartDataType === ChartDataType.AccountTotalAssets.type ||
|
||||||
self.query.chartDataType === self.allChartDataTypes.AccountTotalLiabilities.type) {
|
self.query.chartDataType === ChartDataType.AccountTotalLiabilities.type) {
|
||||||
dispatchPromise = self.accountsStore.loadAllAccounts({
|
dispatchPromise = self.accountsStore.loadAllAccounts({
|
||||||
force: force
|
force: force
|
||||||
});
|
});
|
||||||
@@ -605,11 +610,11 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
setChartType(chartType) {
|
setChartType(chartType) {
|
||||||
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (this.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
this.statisticsStore.updateTransactionStatisticsFilter({
|
this.statisticsStore.updateTransactionStatisticsFilter({
|
||||||
categoricalChartType: chartType
|
categoricalChartType: chartType
|
||||||
});
|
});
|
||||||
} else if (this.analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
} else if (this.analysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||||
this.statisticsStore.updateTransactionStatisticsFilter({
|
this.statisticsStore.updateTransactionStatisticsFilter({
|
||||||
trendChartType: chartType
|
trendChartType: chartType
|
||||||
});
|
});
|
||||||
@@ -619,9 +624,9 @@ export default {
|
|||||||
let analysisTypeChanged = false;
|
let analysisTypeChanged = false;
|
||||||
|
|
||||||
if (this.analysisType !== analysisType) {
|
if (this.analysisType !== analysisType) {
|
||||||
if (!isChartDataTypeAvailableForAnalysisType(this.queryChartDataType, analysisType)) {
|
if (!ChartDataType.isAvailableForAnalysisType(this.queryChartDataType, analysisType)) {
|
||||||
this.statisticsStore.updateTransactionStatisticsFilter({
|
this.statisticsStore.updateTransactionStatisticsFilter({
|
||||||
chartDataType: statisticsConstants.defaultChartDataType
|
chartDataType: ChartDataType.Default.type
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -641,7 +646,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
setSortingType(sortingType) {
|
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;
|
this.showSortingTypePopover = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -657,7 +662,7 @@ export default {
|
|||||||
this.showDateAggregationPopover = false;
|
this.showDateAggregationPopover = false;
|
||||||
},
|
},
|
||||||
setDateFilter(dateType) {
|
setDateFilter(dateType) {
|
||||||
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (this.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
if (dateType === this.allDateRanges.Custom.type) { // Custom
|
if (dateType === this.allDateRanges.Custom.type) { // Custom
|
||||||
this.showCustomDateRangeSheet = true;
|
this.showCustomDateRangeSheet = true;
|
||||||
this.showDatePopover = false;
|
this.showDatePopover = false;
|
||||||
@@ -665,7 +670,7 @@ export default {
|
|||||||
} else if (this.query.categoricalChartDateType === dateType) {
|
} else if (this.query.categoricalChartDateType === dateType) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (this.analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
} else if (this.analysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||||
if (dateType === this.allDateRanges.Custom.type) { // Custom
|
if (dateType === this.allDateRanges.Custom.type) { // Custom
|
||||||
this.showCustomMonthRangeSheet = true;
|
this.showCustomMonthRangeSheet = true;
|
||||||
this.showDatePopover = false;
|
this.showDatePopover = false;
|
||||||
@@ -683,13 +688,13 @@ export default {
|
|||||||
|
|
||||||
let changed = false;
|
let changed = false;
|
||||||
|
|
||||||
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (this.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
||||||
categoricalChartDateType: dateRange.dateType,
|
categoricalChartDateType: dateRange.dateType,
|
||||||
categoricalChartStartTime: dateRange.minTime,
|
categoricalChartStartTime: dateRange.minTime,
|
||||||
categoricalChartEndTime: dateRange.maxTime
|
categoricalChartEndTime: dateRange.maxTime
|
||||||
});
|
});
|
||||||
} else if (this.analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) {
|
} else if (this.analysisType === StatisticsAnalysisType.TrendAnalysis) {
|
||||||
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
||||||
trendChartDateType: dateRange.dateType,
|
trendChartDateType: dateRange.dateType,
|
||||||
trendChartStartYearMonth: getYearAndMonthFromUnixTime(dateRange.minTime),
|
trendChartStartYearMonth: getYearAndMonthFromUnixTime(dateRange.minTime),
|
||||||
@@ -710,7 +715,7 @@ export default {
|
|||||||
|
|
||||||
let changed = false;
|
let changed = false;
|
||||||
|
|
||||||
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (this.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
const chartDateType = getDateTypeByDateRange(startTime, endTime, this.firstDayOfWeek, DateRangeScene.Normal);
|
const chartDateType = getDateTypeByDateRange(startTime, endTime, this.firstDayOfWeek, DateRangeScene.Normal);
|
||||||
|
|
||||||
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
||||||
@@ -720,7 +725,7 @@ export default {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.showCustomDateRangeSheet = false;
|
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);
|
const chartDateType = getDateTypeByDateRange(getYearMonthFirstUnixTime(startTime), getYearMonthLastUnixTime(endTime), this.firstDayOfWeek, DateRangeScene.TrendAnalysis);
|
||||||
|
|
||||||
this.statisticsStore.updateTransactionStatisticsFilter({
|
this.statisticsStore.updateTransactionStatisticsFilter({
|
||||||
@@ -737,22 +742,22 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
showCustomDateRange() {
|
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;
|
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;
|
return this.query.trendChartDateType === this.allDateRanges.Custom.type && this.query.trendChartStartYearMonth && this.query.trendChartEndYearMonth;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
canShiftDateRange(query) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) {
|
if (this.analysisType === StatisticsAnalysisType.CategoricalAnalysis) {
|
||||||
return query.categoricalChartDateType !== this.allDateRanges.All.type;
|
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;
|
return query.trendChartDateType !== this.allDateRanges.All.type;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@@ -765,7 +770,7 @@ export default {
|
|||||||
|
|
||||||
let changed = false;
|
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);
|
const newDateRange = getShiftedDateRangeAndDateType(query.categoricalChartStartTime, query.categoricalChartEndTime, scale, this.firstDayOfWeek, DateRangeScene.Normal);
|
||||||
|
|
||||||
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
||||||
@@ -773,7 +778,7 @@ export default {
|
|||||||
categoricalChartStartTime: newDateRange.minTime,
|
categoricalChartStartTime: newDateRange.minTime,
|
||||||
categoricalChartEndTime: newDateRange.maxTime
|
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);
|
const newDateRange = getShiftedDateRangeAndDateType(getYearMonthFirstUnixTime(query.trendChartStartYearMonth), getYearMonthLastUnixTime(query.trendChartEndYearMonth), scale, this.firstDayOfWeek, DateRangeScene.TrendAnalysis);
|
||||||
|
|
||||||
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
changed = this.statisticsStore.updateTransactionStatisticsFilter({
|
||||||
@@ -788,14 +793,14 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
dateRangeName(query) {
|
dateRangeName(query) {
|
||||||
if (this.query.chartDataType === this.allChartDataTypes.AccountTotalAssets.type ||
|
if (this.query.chartDataType === ChartDataType.AccountTotalAssets.type ||
|
||||||
this.query.chartDataType === this.allChartDataTypes.AccountTotalLiabilities.type) {
|
this.query.chartDataType === ChartDataType.AccountTotalLiabilities.type) {
|
||||||
return this.$t(this.allDateRanges.All.name);
|
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);
|
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));
|
return this.$locale.getDateRangeDisplayName(this.userStore, query.trendChartDateType, getYearMonthFirstUnixTime(query.trendChartStartYearMonth), getYearMonthLastUnixTime(query.trendChartEndYearMonth));
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
@@ -826,8 +831,8 @@ export default {
|
|||||||
amount = this.getDisplayCurrency(amount, currency);
|
amount = this.getDisplayCurrency(amount, currency);
|
||||||
|
|
||||||
if (!this.showAccountBalance
|
if (!this.showAccountBalance
|
||||||
&& (this.query.chartDataType === this.allChartDataTypes.AccountTotalAssets.type
|
&& (this.query.chartDataType === ChartDataType.AccountTotalAssets.type
|
||||||
|| this.query.chartDataType === this.allChartDataTypes.AccountTotalLiabilities.type)
|
|| this.query.chartDataType === ChartDataType.AccountTotalLiabilities.type)
|
||||||
) {
|
) {
|
||||||
return '***';
|
return '***';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user