mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-16 07:57:33 +08:00
convert transaction type in import transaction dialog
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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 '';
|
||||
|
||||
Reference in New Issue
Block a user