convert transaction type in import transaction dialog

This commit is contained in:
MaysWind
2025-03-04 01:27:51 +08:00
parent 3f8de39683
commit e83b959930
9 changed files with 152 additions and 1 deletions
+23
View File
@@ -49,6 +49,29 @@ export function getCategorizedAccounts(allAccounts: Account[]): CategorizedAccou
return ret;
}
export function getAccountMapByName(allAccounts: Account[]): Record<string, Account> {
const ret: Record<string, Account> = {};
if (!allAccounts) {
return ret;
}
for (let i = 0; i < allAccounts.length; i++) {
const account = allAccounts[i];
if (account.type === AccountType.SingleAccount.type) {
ret[account.name] = account;
} else if (account.type === AccountType.MultiSubAccounts.type && account.subAccounts) {
for (let j = 0; j < account.subAccounts.length; j++) {
const subAccount = account.subAccounts[j];
ret[subAccount.name] = subAccount;
}
}
}
return ret;
}
export function getCategorizedAccountsWithVisibleCount(categorizedAccountsMap: Record<number, CategorizedAccount>): AccountCategoriesWithVisibleCount[] {
const ret: AccountCategoriesWithVisibleCount[] = [];
const allCategories = AccountCategory.values();
+21
View File
@@ -26,6 +26,27 @@ export function categoryTypeToTransactionType(categoryType: CategoryType): Trans
}
}
export function getSecondaryTransactionMapByName(allCategories: TransactionCategory[]): Record<string, TransactionCategory> {
const ret: Record<string, TransactionCategory> = {};
if (!allCategories) {
return ret;
}
for (let i = 0; i < allCategories.length; i++) {
const category = allCategories[i];
if (category.subCategories) {
for (let j = 0; j < category.subCategories.length; j++) {
const subCategory = category.subCategories[j];
ret[subCategory.name] = subCategory;
}
}
}
return ret;
}
export function getTransactionPrimaryCategoryName(categoryId: string | null | undefined, allCategories: TransactionCategory[]): string {
if (!allCategories) {
return '';