remove compatibility code for migration

This commit is contained in:
MaysWind
2025-02-09 16:51:21 +08:00
parent f2c043a299
commit 0e4cd10376
20 changed files with 171 additions and 214 deletions
+18 -18
View File
@@ -78,12 +78,12 @@ export function getCategorizedAccountsWithVisibleCount(categorizedAccountsMap: R
}
}
if (account.type === AccountType.MultiSubAccounts.type && account.childrenAccounts) {
if (account.type === AccountType.MultiSubAccounts.type && account.subAccounts) {
let visibleSubAccountCount = 0;
let firstVisibleSubAccountIndex = -1;
for (let k = 0; k < account.childrenAccounts.length; k++) {
const subAccount = account.childrenAccounts[k];
for (let k = 0; k < account.subAccounts.length; k++) {
const subAccount = account.subAccounts[k];
if (!subAccount.hidden) {
visibleSubAccountCount++;
@@ -94,8 +94,8 @@ export function getCategorizedAccountsWithVisibleCount(categorizedAccountsMap: R
}
}
if (account.childrenAccounts.length > 0) {
allSubAccounts[account.id] = account.childrenAccounts;
if (account.subAccounts.length > 0) {
allSubAccounts[account.id] = account.subAccounts;
allVisibleSubAccountCounts[account.id] = visibleSubAccountCount;
allFirstVisibleSubAccountIndexes[account.id] = firstVisibleSubAccountIndex;
}
@@ -145,9 +145,9 @@ export function getAllFilteredAccountsBalance(categorizedAccounts: Record<number
isLiability: !!account.isLiability,
currency: account.currency
});
} else if (account.type === AccountType.MultiSubAccounts.type && account.childrenAccounts) {
for (let subAccountIdx = 0; subAccountIdx < account.childrenAccounts.length; subAccountIdx++) {
const subAccount = account.childrenAccounts[subAccountIdx];
} else if (account.type === AccountType.MultiSubAccounts.type && account.subAccounts) {
for (let subAccountIdx = 0; subAccountIdx < account.subAccounts.length; subAccountIdx++) {
const subAccount = account.subAccounts[subAccountIdx];
if (subAccount.hidden || !accountFilter(subAccount)) {
continue;
@@ -231,12 +231,12 @@ export function selectAccountOrSubAccounts(filterAccountIds: Record<string, bool
if (account.type === AccountType.SingleAccount.type) {
filterAccountIds[account.id] = value;
} else if (account.type === AccountType.MultiSubAccounts.type) {
if (!account.childrenAccounts || !account.childrenAccounts.length) {
if (!account.subAccounts || !account.subAccounts.length) {
return;
}
for (let i = 0; i < account.childrenAccounts.length; i++) {
const subAccount = account.childrenAccounts[i];
for (let i = 0; i < account.subAccounts.length; i++) {
const subAccount = account.subAccounts[i];
filterAccountIds[subAccount.id] = value;
}
}
@@ -285,12 +285,12 @@ export function selectInvert(filterAccountIds: Record<string, boolean>, allAccou
}
export function isAccountOrSubAccountsAllChecked(account: Account, filterAccountIds: Record<string, boolean>): boolean {
if (!account.childrenAccounts) {
if (!account.subAccounts) {
return !filterAccountIds[account.id];
}
for (let i = 0; i < account.childrenAccounts.length; i++) {
const subAccount = account.childrenAccounts[i];
for (let i = 0; i < account.subAccounts.length; i++) {
const subAccount = account.subAccounts[i];
if (filterAccountIds[subAccount.id]) {
return false;
}
@@ -300,20 +300,20 @@ export function isAccountOrSubAccountsAllChecked(account: Account, filterAccount
}
export function isAccountOrSubAccountsHasButNotAllChecked(account: Account, filterAccountIds: Record<string, boolean>): boolean {
if (!account.childrenAccounts) {
if (!account.subAccounts) {
return false;
}
let checkedCount = 0;
for (let i = 0; i < account.childrenAccounts.length; i++) {
const subAccount = account.childrenAccounts[i];
for (let i = 0; i < account.subAccounts.length; i++) {
const subAccount = account.subAccounts[i];
if (!filterAccountIds[subAccount.id]) {
checkedCount++;
}
}
return checkedCount > 0 && checkedCount < account.childrenAccounts.length;
return checkedCount > 0 && checkedCount < account.subAccounts.length;
}
export function setAccountSuitableIcon(account: Account, oldCategory: number, newCategory: number): void {
+23 -23
View File
@@ -32,7 +32,7 @@ export function getTransactionPrimaryCategoryName(categoryId: string | null | un
}
for (let i = 0; i < allCategories.length; i++) {
const subCategoryList = allCategories[i].secondaryCategories;
const subCategoryList = allCategories[i].subCategories;
if (!subCategoryList) {
continue;
@@ -55,7 +55,7 @@ export function getTransactionSecondaryCategoryName(categoryId: string | null |
}
for (let i = 0; i < allCategories.length; i++) {
const subCategoryList = allCategories[i].secondaryCategories;
const subCategoryList = allCategories[i].subCategories;
if (!subCategoryList) {
continue;
@@ -110,12 +110,12 @@ export function allTransactionCategoriesWithVisibleCount(allTransactionCategorie
}
}
if (category.secondaryCategories) {
if (category.subCategories) {
let visibleSubCategoryCount = 0;
let firstVisibleSubCategoryIndex = -1;
for (let k = 0; k < category.secondaryCategories.length; k++) {
const subCategory = category.secondaryCategories[k];
for (let k = 0; k < category.subCategories.length; k++) {
const subCategory = category.subCategories[k];
if (!subCategory.hidden) {
visibleSubCategoryCount++;
@@ -126,8 +126,8 @@ export function allTransactionCategoriesWithVisibleCount(allTransactionCategorie
}
}
if (category.secondaryCategories.length > 0) {
allSubCategories[category.id] = category.secondaryCategories;
if (category.subCategories.length > 0) {
allSubCategories[category.id] = category.subCategories;
allVisibleSubCategoryCounts[category.id] = visibleSubCategoryCount;
allFirstVisibleSubCategoryIndexes[category.id] = firstVisibleSubCategoryIndex;
}
@@ -209,7 +209,7 @@ export function isSubCategoryIdAvailable(categories: TransactionCategory[], cate
continue;
}
const subCategoryList = primaryCategory.secondaryCategories;
const subCategoryList = primaryCategory.subCategories;
if (!subCategoryList) {
continue;
@@ -243,7 +243,7 @@ export function getFirstAvailableCategoryId(categories: TransactionCategory[]):
continue;
}
const subCategoryList = primaryCategory.secondaryCategories;
const subCategoryList = primaryCategory.subCategories;
if (!subCategoryList) {
continue;
@@ -275,7 +275,7 @@ export function getFirstAvailableSubCategoryId(categories: TransactionCategory[]
continue;
}
const subCategoryList = primaryCategory.secondaryCategories;
const subCategoryList = primaryCategory.subCategories;
if (!subCategoryList) {
return '';
@@ -382,12 +382,12 @@ export function containsAvailableCategory(allTransactionCategories: Record<numbe
}
export function selectAllSubCategories(filterCategoryIds: Record<string, boolean>, category: TransactionCategory, value: boolean): void {
if (!category || !category.secondaryCategories || !category.secondaryCategories.length) {
if (!category || !category.subCategories || !category.subCategories.length) {
return;
}
for (let i = 0; i < category.secondaryCategories.length; i++) {
const subCategory = category.secondaryCategories[i];
for (let i = 0; i < category.subCategories.length; i++) {
const subCategory = category.subCategories[i];
filterCategoryIds[subCategory.id] = value;
}
}
@@ -435,12 +435,12 @@ export function selectInvert(filterCategoryIds: Record<string, boolean>, allTran
}
export function isCategoryOrSubCategoriesAllChecked(category: TransactionCategory, filterCategoryIds: Record<string, boolean>): boolean {
if (!category.secondaryCategories || category.secondaryCategories.length < 1) {
if (!category.subCategories || category.subCategories.length < 1) {
return !filterCategoryIds[category.id];
}
for (let i = 0; i < category.secondaryCategories.length; i++) {
const subCategory = category.secondaryCategories[i];
for (let i = 0; i < category.subCategories.length; i++) {
const subCategory = category.subCategories[i];
if (filterCategoryIds[subCategory.id]) {
return false;
}
@@ -450,12 +450,12 @@ export function isCategoryOrSubCategoriesAllChecked(category: TransactionCategor
}
export function isSubCategoriesAllChecked(category: TransactionCategory, filterCategoryIds: Record<string, boolean>): boolean {
if (!category.secondaryCategories || category.secondaryCategories.length < 1) {
if (!category.subCategories || category.subCategories.length < 1) {
return false;
}
for (let i = 0; i < category.secondaryCategories.length; i++) {
const subCategory = category.secondaryCategories[i];
for (let i = 0; i < category.subCategories.length; i++) {
const subCategory = category.subCategories[i];
if (filterCategoryIds[subCategory.id]) {
return false;
}
@@ -467,16 +467,16 @@ export function isSubCategoriesAllChecked(category: TransactionCategory, filterC
export function isSubCategoriesHasButNotAllChecked(category: TransactionCategory, filterCategoryIds: Record<string, boolean>): boolean {
let checkedCount = 0;
if (!category.secondaryCategories || category.secondaryCategories.length < 1) {
if (!category.subCategories || category.subCategories.length < 1) {
return false;
}
for (let i = 0; i < category.secondaryCategories.length; i++) {
const subCategory = category.secondaryCategories[i];
for (let i = 0; i < category.subCategories.length; i++) {
const subCategory = category.subCategories[i];
if (!filterCategoryIds[subCategory.id]) {
checkedCount++;
}
}
return checkedCount > 0 && checkedCount < category.secondaryCategories.length;
return checkedCount > 0 && checkedCount < category.subCategories.length;
}