From 68cb5bc523772dce6486a1202e22e9684bd98343 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Thu, 6 Feb 2025 20:44:18 +0800 Subject: [PATCH] remove unused code --- src/core/account.ts | 34 ++++++++++++------------------ src/core/statistics.ts | 48 ++++++++++++++++-------------------------- src/core/template.ts | 12 ++++------- 3 files changed, 35 insertions(+), 59 deletions(-) diff --git a/src/core/account.ts b/src/core/account.ts index a43f094e..7d34f5fb 100644 --- a/src/core/account.ts +++ b/src/core/account.ts @@ -1,20 +1,16 @@ import type { TypeAndName, TypeAndDisplayName } from './base.ts'; -type AccountTypeName = 'SingleAccount' | 'MultiSubAccounts'; - export class AccountType implements TypeAndName { private static readonly allInstances: AccountType[] = []; - public static readonly SingleAccount = new AccountType(1, 'SingleAccount', 'Single Account'); - public static readonly MultiSubAccounts = new AccountType(2, 'MultiSubAccounts', 'Multiple Sub-accounts'); + public static readonly SingleAccount = new AccountType(1, 'Single Account'); + public static readonly MultiSubAccounts = new AccountType(2, 'Multiple Sub-accounts'); public readonly type: number; - public readonly typeName: AccountTypeName; public readonly name: string; - private constructor(type: number, typeName: AccountTypeName, name: string) { + private constructor(type: number, name: string) { this.type = type; - this.typeName = typeName; this.name = name; AccountType.allInstances.push(this); @@ -25,32 +21,28 @@ export class AccountType implements TypeAndName { } } -type AccountCategoryTypeName = 'Cash' | 'CheckingAccount' | 'SavingsAccount' | 'CreditCard' | 'VirtualAccount' | 'DebtAccount' | 'Receivables' | 'CertificateOfDeposit' | 'InvestmentAccount'; - export class AccountCategory implements TypeAndName { private static readonly allInstances: AccountCategory[] = []; private static readonly allInstancesByType: Record = {}; - public static readonly Cash = new AccountCategory(1, 'Cash', 'Cash', '1'); - public static readonly CheckingAccount = new AccountCategory(2, 'CheckingAccount', 'Checking Account', '100'); - public static readonly SavingsAccount = new AccountCategory(8, 'SavingsAccount', 'Savings Account', '100'); - public static readonly CreditCard = new AccountCategory(3, 'CreditCard', 'Credit Card', '100'); - public static readonly VirtualAccount = new AccountCategory(4, 'VirtualAccount', 'Virtual Account', '500'); - public static readonly DebtAccount = new AccountCategory(5, 'DebtAccount', 'Debt Account', '600'); - public static readonly Receivables = new AccountCategory(6, 'Receivables', 'Receivables', '700'); - public static readonly CertificateOfDeposit = new AccountCategory(9, 'CertificateOfDeposit', 'Certificate of Deposit', '110'); - public static readonly InvestmentAccount = new AccountCategory(7, 'InvestmentAccount', 'Investment Account', '800'); + public static readonly Cash = new AccountCategory(1, 'Cash', '1'); + public static readonly CheckingAccount = new AccountCategory(2, 'Checking Account', '100'); + public static readonly SavingsAccount = new AccountCategory(8, 'Savings Account', '100'); + public static readonly CreditCard = new AccountCategory(3, 'Credit Card', '100'); + public static readonly VirtualAccount = new AccountCategory(4, 'Virtual Account', '500'); + public static readonly DebtAccount = new AccountCategory(5, 'Debt Account', '600'); + public static readonly Receivables = new AccountCategory(6, 'Receivables', '700'); + public static readonly CertificateOfDeposit = new AccountCategory(9, 'Certificate of Deposit', '110'); + public static readonly InvestmentAccount = new AccountCategory(7, 'Investment Account', '800'); public static readonly Default = AccountCategory.Cash; public readonly type: number; - public readonly typeName: AccountCategoryTypeName; public readonly name: string; public readonly defaultAccountIconId: string; - private constructor(type: number, typeName: AccountCategoryTypeName, name: string, defaultAccountIconId: string) { + private constructor(type: number, name: string, defaultAccountIconId: string) { this.type = type; - this.typeName = typeName; this.name = name; this.defaultAccountIconId = defaultAccountIconId; diff --git a/src/core/statistics.ts b/src/core/statistics.ts index 779e71da..a4693eb2 100644 --- a/src/core/statistics.ts +++ b/src/core/statistics.ts @@ -6,23 +6,19 @@ export enum StatisticsAnalysisType { TrendAnalysis = 1 } -type CategoricalChartTypeName = 'Pie' | 'Bar'; - export class CategoricalChartType implements TypeAndName { private static readonly allInstances: CategoricalChartType[] = []; - public static readonly Pie = new CategoricalChartType(0, 'Pie', 'Pie Chart'); - public static readonly Bar = new CategoricalChartType(1, 'Bar', 'Bar Chart'); + public static readonly Pie = new CategoricalChartType(0, 'Pie Chart'); + public static readonly Bar = new CategoricalChartType(1, '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) { + private constructor(type: number, name: string) { this.type = type; - this.typeName = typeName; this.name = name; CategoricalChartType.allInstances.push(this); @@ -33,23 +29,19 @@ export class CategoricalChartType implements TypeAndName { } } -type TrendChartTypeName = 'Area' | 'Column'; - export class TrendChartType implements TypeAndName { private static readonly allInstances: TrendChartType[] = []; - public static readonly Area = new TrendChartType(0, 'Area', 'Area Chart'); - public static readonly Column = new TrendChartType(1, 'Column', 'Column Chart'); + public static readonly Area = new TrendChartType(0, 'Area Chart'); + public static readonly Column = new TrendChartType(1, '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) { + private constructor(type: number, name: string) { this.type = type; - this.typeName = typeName; this.name = name; TrendChartType.allInstances.push(this); @@ -60,34 +52,30 @@ export class TrendChartType implements TypeAndName { } } -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 = {}; - 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 ExpenseByAccount = new ChartDataType(0, 'Expense By Account', StatisticsAnalysisType.CategoricalAnalysis, StatisticsAnalysisType.TrendAnalysis); + public static readonly ExpenseByPrimaryCategory = new ChartDataType(1, 'Expense By Primary Category', StatisticsAnalysisType.CategoricalAnalysis, StatisticsAnalysisType.TrendAnalysis); + public static readonly ExpenseBySecondaryCategory = new ChartDataType(2, 'Expense By Secondary Category', StatisticsAnalysisType.CategoricalAnalysis, StatisticsAnalysisType.TrendAnalysis); + public static readonly IncomeByAccount = new ChartDataType(3, 'Income By Account', StatisticsAnalysisType.CategoricalAnalysis, StatisticsAnalysisType.TrendAnalysis); + public static readonly IncomeByPrimaryCategory = new ChartDataType(4, 'Income By Primary Category', StatisticsAnalysisType.CategoricalAnalysis, StatisticsAnalysisType.TrendAnalysis); + public static readonly IncomeBySecondaryCategory = new ChartDataType(5, 'Income By Secondary Category', StatisticsAnalysisType.CategoricalAnalysis, StatisticsAnalysisType.TrendAnalysis); + public static readonly AccountTotalAssets = new ChartDataType(6, 'Account Total Assets', StatisticsAnalysisType.CategoricalAnalysis); + public static readonly AccountTotalLiabilities = new ChartDataType(7, 'Account Total Liabilities', StatisticsAnalysisType.CategoricalAnalysis); + public static readonly TotalExpense = new ChartDataType(8, 'Total Expense', StatisticsAnalysisType.TrendAnalysis); + public static readonly TotalIncome = new ChartDataType(9, 'Total Income', StatisticsAnalysisType.TrendAnalysis); + public static readonly TotalBalance = new ChartDataType(10, '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; - private constructor(type: number, typeName: ChartDataTypeName, name: string, ...availableAnalysisTypes: StatisticsAnalysisType[]) { + private constructor(type: number, name: string, ...availableAnalysisTypes: StatisticsAnalysisType[]) { this.type = type; - this.typeName = typeName; this.name = name; this.availableAnalysisTypes = {}; diff --git a/src/core/template.ts b/src/core/template.ts index dd31ec65..95136ae8 100644 --- a/src/core/template.ts +++ b/src/core/template.ts @@ -1,7 +1,5 @@ import type { TypeAndName } from './base.ts'; -type TemplateTypeName = 'Normal' | 'Schedule'; - export class TemplateType implements TypeAndName { private static readonly allInstances: TemplateType[] = []; private static readonly allInstancesByType: Record = {}; @@ -10,9 +8,9 @@ export class TemplateType implements TypeAndName { public static readonly Schedule = new TemplateType(2, 'Schedule'); public readonly type: number; - public readonly name: TemplateTypeName; + public readonly name: string; - private constructor(type: number, name: TemplateTypeName) { + private constructor(type: number, name: string) { this.type = type; this.name = name; @@ -29,8 +27,6 @@ export class TemplateType implements TypeAndName { } } -type ScheduledTemplateFrequencyTypeName = 'Disabled' | 'Weekly' | 'Monthly'; - export class ScheduledTemplateFrequencyType implements TypeAndName { private static readonly allInstances: ScheduledTemplateFrequencyType[] = []; private static readonly allInstancesByType: Record = {}; @@ -40,9 +36,9 @@ export class ScheduledTemplateFrequencyType implements TypeAndName { public static readonly Monthly = new ScheduledTemplateFrequencyType(2, 'Monthly'); public readonly type: number; - public readonly name: ScheduledTemplateFrequencyTypeName; + public readonly name: string; - private constructor(type: number, name: ScheduledTemplateFrequencyTypeName) { + private constructor(type: number, name: string) { this.type = type; this.name = name;