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