migrate lib/account.js to typescript

This commit is contained in:
MaysWind
2025-01-17 00:37:41 +08:00
parent 6878d5260d
commit 749bdfd164
14 changed files with 359 additions and 208 deletions
+1 -1
View File
@@ -271,7 +271,7 @@ import {
getSubAccountCurrencies,
getAccountOrSubAccountId,
getAccountOrSubAccountComment
} from '@/lib/account.js';
} from '@/lib/account.ts';
import {
mdiEyeOutline,
@@ -203,12 +203,10 @@ import { useAccountsStore } from '@/stores/account.js';
import { AccountType, AccountCategory } from '@/core/account.ts';
import { ALL_ACCOUNT_ICONS } from '@/consts/icon.ts';
import { ALL_ACCOUNT_COLORS } from '@/consts/color.ts';
import { isNumber } from '@/lib/common.ts';
import { generateRandomUUID } from '@/lib/misc.ts';
import {
setAccountModelByAnotherAccount,
setAccountSuitableIcon
} from '@/lib/account.js';
import { setAccountSuitableIcon } from '@/lib/account.ts';
import {
mdiDotsVertical,
@@ -324,7 +322,7 @@ export default {
self.submitting = false;
const newAccount = self.accountsStore.generateNewAccountModel();
setAccountModelByAnotherAccount(self.account, newAccount);
self.account.from(newAccount);
self.subAccounts = [];
self.currentAccountIndex = -1;
@@ -485,13 +483,13 @@ export default {
}
},
setAccount(account) {
setAccountModelByAnotherAccount(this.account, account);
this.account.from(account);
this.subAccounts = [];
if (account.subAccounts && account.subAccounts.length > 0) {
for (let i = 0; i < account.subAccounts.length; i++) {
if (account.childrenAccounts && account.childrenAccounts.length > 0) {
for (let i = 0; i < account.childrenAccounts.length; i++) {
const subAccount = this.accountsStore.generateNewSubAccountModel(this.account);
setAccountModelByAnotherAccount(subAccount, account.subAccounts[i]);
subAccount.from(account.childrenAccounts[i]);
this.subAccounts.push(subAccount);
}
@@ -162,7 +162,7 @@ import {
selectInvert,
isAccountOrSubAccountsAllChecked,
isAccountOrSubAccountsHasButNotAllChecked
} from '@/lib/account.js';
} from '@/lib/account.ts';
import {
mdiSelectAll,
+1 -1
View File
@@ -628,7 +628,7 @@ import {
categoryTypeToTransactionType,
transactionTypeToCategoryType
} from '@/lib/category.ts';
import { getUnifiedSelectedAccountsCurrencyOrDefaultCurrency } from '@/lib/account.js';
import { getUnifiedSelectedAccountsCurrencyOrDefaultCurrency } from '@/lib/account.ts';
import { getTransactionDisplayAmount } from '@/lib/transaction.js';
import { isDataImportingEnabled } from '@/lib/server_settings.ts';
import { scrollToSelectedItem } from '@/lib/ui/desktop.ts';
@@ -341,7 +341,7 @@ import { WeekDay } from '@/core/datetime.ts';
import { SUPPORTED_IMAGE_EXTENSIONS } from '@/consts/file.ts';
import { getNameByKeyValue } from '@/lib/common.ts';
import { generateRandomUUID } from '@/lib/misc.ts';
import { getCategorizedAccounts } from '@/lib/account.js';
import { getCategorizedAccounts } from '@/lib/account.ts';
import { isUserVerifyEmailEnabled } from '@/lib/server_settings.ts';
import { setExpenseAndIncomeAmountColor } from '@/lib/ui/common.ts';
+6 -8
View File
@@ -497,12 +497,10 @@ import { AccountType, AccountCategory } from '@/core/account.ts';
import { ALL_ACCOUNT_ICONS } from '@/consts/icon.ts';
import { ALL_ACCOUNT_COLORS } from '@/consts/color.ts';
import { TRANSACTION_MIN_AMOUNT, TRANSACTION_MAX_AMOUNT } from '@/consts/transaction.ts';
import { getNameByKeyValue } from '@/lib/common.ts';
import { generateRandomUUID } from '@/lib/misc.ts';
import {
setAccountModelByAnotherAccount,
setAccountSuitableIcon
} from '@/lib/account.js';
import { setAccountSuitableIcon } from '@/lib/account.ts';
import {
getTimezoneOffsetMinutes,
getBrowserTimezoneOffsetMinutes,
@@ -618,13 +616,13 @@ export default {
self.accountsStore.getAccount({
accountId: self.editAccountId
}).then(account => {
setAccountModelByAnotherAccount(self.account, account);
self.account.from(account);
self.subAccounts = [];
if (account.subAccounts && account.subAccounts.length > 0) {
for (let i = 0; i < account.subAccounts.length; i++) {
if (account.childrenAccounts && account.childrenAccounts.length > 0) {
for (let i = 0; i < account.childrenAccounts.length; i++) {
const subAccount = self.accountsStore.generateNewSubAccountModel(self.account);
setAccountModelByAnotherAccount(subAccount, account.subAccounts[i]);
subAccount.from(account.childrenAccounts[i]);
subAccount.showIconSelectionSheet = false;
subAccount.showColorSelectionSheet = false;
subAccount.showBalanceSheet = false;
@@ -148,7 +148,7 @@ import {
selectInvert,
isAccountOrSubAccountsAllChecked,
isAccountOrSubAccountsHasButNotAllChecked
} from '@/lib/account.js';
} from '@/lib/account.ts';
export default {
props: [
+1 -1
View File
@@ -549,7 +549,7 @@ import {
getDateRangeByBillingCycleDateType
} from '@/lib/datetime.ts';
import { categoryTypeToTransactionType, transactionTypeToCategoryType } from '@/lib/category.ts';
import { getUnifiedSelectedAccountsCurrencyOrDefaultCurrency } from '@/lib/account.js';
import { getUnifiedSelectedAccountsCurrencyOrDefaultCurrency } from '@/lib/account.ts';
import { getTransactionDisplayAmount } from '@/lib/transaction.js';
import { onSwipeoutDeleted, scrollToSelectedItem } from '@/lib/ui/mobile.ts';
+1 -1
View File
@@ -340,7 +340,7 @@ import { useAccountsStore } from '@/stores/account.js';
import { useOverviewStore } from '@/stores/overview.ts';
import { getNameByKeyValue } from '@/lib/common.ts';
import { getCategorizedAccounts } from '@/lib/account.js';
import { getCategorizedAccounts } from '@/lib/account.ts';
import { isUserVerifyEmailEnabled } from '@/lib/server_settings.ts';
import { setExpenseAndIncomeAmountColor } from '@/lib/ui/common.ts';