support changing account category order

This commit is contained in:
MaysWind
2026-01-04 22:50:13 +08:00
parent 6e369f39a4
commit 0ce66d9070
50 changed files with 575 additions and 72 deletions
+9 -9
View File
@@ -31,9 +31,9 @@ export function getCategorizedAccountsMap(allAccounts: Account[]): Record<number
return ret;
}
export function getCategorizedAccounts(allAccounts: Account[]): CategorizedAccount[] {
export function getCategorizedAccounts(allAccounts: Account[], customAccountCategoryOrder: string): CategorizedAccount[] {
const ret: CategorizedAccount[] = [];
const allCategories = AccountCategory.values();
const allCategories = AccountCategory.values(customAccountCategoryOrder);
const categorizedAccounts = getCategorizedAccountsMap(allAccounts);
for (const category of allCategories) {
@@ -71,9 +71,9 @@ export function getAccountMapByName(allAccounts: Account[]): Record<string, Acco
return ret;
}
export function filterCategorizedAccounts(categorizedAccountsMap: Record<number, CategorizedAccount>, allowAccountName?: string, showHidden?: boolean): Record<number, CategorizedAccount> {
const ret: Record<number, CategorizedAccount> = {};
const allCategories = AccountCategory.values();
export function filterCategorizedAccounts(categorizedAccountsMap: Record<number, CategorizedAccount>, customAccountCategoryOrder: string, allowAccountName?: string, showHidden?: boolean): CategorizedAccount[] {
const ret: CategorizedAccount[] = [];
const allCategories = AccountCategory.values(customAccountCategoryOrder);
const lowercaseFilterContent = allowAccountName ? allowAccountName.toLowerCase() : '';
for (const accountCategory of allCategories) {
@@ -122,20 +122,20 @@ export function filterCategorizedAccounts(categorizedAccountsMap: Record<number,
}
if (allFilteredAccounts.length > 0) {
ret[accountCategory.type] = {
ret.push({
category: categorizedAccount.category,
name: categorizedAccount.name,
icon: categorizedAccount.icon,
accounts: allFilteredAccounts
};
});
}
}
return ret;
}
export function getAllFilteredAccountsBalance(categorizedAccounts: Record<number, CategorizedAccount>, accountFilter: (account: Account) => boolean): AccountBalance[] {
const allAccountCategories = AccountCategory.values();
export function getAllFilteredAccountsBalance(categorizedAccounts: Record<number, CategorizedAccount>, customAccountCategoryOrder: string, accountFilter: (account: Account) => boolean): AccountBalance[] {
const allAccountCategories = AccountCategory.values(customAccountCategoryOrder);
const ret: AccountBalance[] = [];
for (const accountCategory of allAccountCategories) {