mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-16 07:57:33 +08:00
remove compatibility code for migration
This commit is contained in:
+31
-31
@@ -38,9 +38,9 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
if (account.type === AccountType.SingleAccount.type) {
|
||||
allAccountsList.push(account);
|
||||
} else if (account.type === AccountType.MultiSubAccounts.type) {
|
||||
if (account.childrenAccounts) {
|
||||
for (let j = 0; j < account.childrenAccounts.length; j++) {
|
||||
const subAccount = account.childrenAccounts[j];
|
||||
if (account.subAccounts) {
|
||||
for (let j = 0; j < account.subAccounts.length; j++) {
|
||||
const subAccount = account.subAccounts[j];
|
||||
allAccountsList.push(subAccount);
|
||||
}
|
||||
}
|
||||
@@ -63,9 +63,9 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
if (account.type === AccountType.SingleAccount.type) {
|
||||
allVisibleAccounts.push(account);
|
||||
} else if (account.type === AccountType.MultiSubAccounts.type) {
|
||||
if (account.childrenAccounts) {
|
||||
for (let j = 0; j < account.childrenAccounts.length; j++) {
|
||||
const subAccount = account.childrenAccounts[j];
|
||||
if (account.subAccounts) {
|
||||
for (let j = 0; j < account.subAccounts.length; j++) {
|
||||
const subAccount = account.subAccounts[j];
|
||||
allVisibleAccounts.push(subAccount);
|
||||
}
|
||||
}
|
||||
@@ -117,9 +117,9 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
const account = accounts[i];
|
||||
allAccountsMap.value[account.id] = account;
|
||||
|
||||
if (account.childrenAccounts) {
|
||||
for (let j = 0; j < account.childrenAccounts.length; j++) {
|
||||
const subAccount = account.childrenAccounts[j];
|
||||
if (account.subAccounts) {
|
||||
for (let j = 0; j < account.subAccounts.length; j++) {
|
||||
const subAccount = account.subAccounts[j];
|
||||
allAccountsMap.value[subAccount.id] = subAccount;
|
||||
}
|
||||
}
|
||||
@@ -142,9 +142,9 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
|
||||
allAccountsMap.value[account.id] = account;
|
||||
|
||||
if (account.childrenAccounts) {
|
||||
for (let i = 0; i < account.childrenAccounts.length; i++) {
|
||||
const subAccount = account.childrenAccounts[i];
|
||||
if (account.subAccounts) {
|
||||
for (let i = 0; i < account.subAccounts.length; i++) {
|
||||
const subAccount = account.subAccounts[i];
|
||||
allAccountsMap.value[subAccount.id] = subAccount;
|
||||
}
|
||||
}
|
||||
@@ -167,9 +167,9 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
|
||||
allAccountsMap.value[account.id] = account;
|
||||
|
||||
if (account.childrenAccounts) {
|
||||
for (let i = 0; i < account.childrenAccounts.length; i++) {
|
||||
const subAccount = account.childrenAccounts[i];
|
||||
if (account.subAccounts) {
|
||||
for (let i = 0; i < account.subAccounts.length; i++) {
|
||||
const subAccount = account.subAccounts[i];
|
||||
allAccountsMap.value[subAccount.id] = subAccount;
|
||||
}
|
||||
}
|
||||
@@ -240,8 +240,8 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
}
|
||||
}
|
||||
|
||||
if (allAccountsMap.value[account.id] && allAccountsMap.value[account.id].childrenAccounts) {
|
||||
const subAccounts = allAccountsMap.value[account.id].childrenAccounts as Account[];
|
||||
if (allAccountsMap.value[account.id] && allAccountsMap.value[account.id].subAccounts) {
|
||||
const subAccounts = allAccountsMap.value[account.id].subAccounts as Account[];
|
||||
|
||||
for (let i = 0; i < subAccounts.length; i++) {
|
||||
const subAccount = subAccounts[i];
|
||||
@@ -298,9 +298,9 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
for (let i = 0; i < accounts.length; i++) {
|
||||
const account = accounts[i];
|
||||
|
||||
if (account.type === AccountType.MultiSubAccounts.type && account.childrenAccounts) {
|
||||
for (let j = 0; j < account.childrenAccounts.length; j++) {
|
||||
const subAccount = account.childrenAccounts[j];
|
||||
if (account.type === AccountType.MultiSubAccounts.type && account.subAccounts) {
|
||||
for (let j = 0; j < account.subAccounts.length; j++) {
|
||||
const subAccount = account.subAccounts[j];
|
||||
|
||||
if (showHidden || !subAccount.hidden) {
|
||||
ret.subAccounts[account.id] = subAccount.id;
|
||||
@@ -339,9 +339,9 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
for (let i = accounts.length - 1; i >= 0; i--) {
|
||||
const account = accounts[i];
|
||||
|
||||
if (account.type === AccountType.MultiSubAccounts.type && account.childrenAccounts) {
|
||||
for (let j = account.childrenAccounts.length - 1; j >= 0; j--) {
|
||||
const subAccount = account.childrenAccounts[j];
|
||||
if (account.type === AccountType.MultiSubAccounts.type && account.subAccounts) {
|
||||
for (let j = account.subAccounts.length - 1; j >= 0; j--) {
|
||||
const subAccount = account.subAccounts[j];
|
||||
|
||||
if (showHidden || !subAccount.hidden) {
|
||||
ret.subAccounts[account.id] = subAccount.id;
|
||||
@@ -563,7 +563,7 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
|
||||
let resultCurrency = userStore.currentUserDefaultCurrency;
|
||||
|
||||
if (!account.childrenAccounts || !account.childrenAccounts.length) {
|
||||
if (!account.subAccounts || !account.subAccounts.length) {
|
||||
return {
|
||||
balance: showAccountBalance ? '0' : '***',
|
||||
currency: resultCurrency
|
||||
@@ -574,8 +574,8 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
const allSubAccountCurrencies: string[] = [];
|
||||
let totalBalance = 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 (!showHidden && subAccount.hidden) {
|
||||
continue;
|
||||
@@ -600,8 +600,8 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
|
||||
let hasUnCalculatedAmount = false;
|
||||
|
||||
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 (!showHidden && subAccount.hidden) {
|
||||
continue;
|
||||
@@ -679,12 +679,12 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
}
|
||||
|
||||
function hasVisibleSubAccount(showHidden: boolean, account: Account): boolean {
|
||||
if (!account || account.type !== AccountType.MultiSubAccounts.type || !account.childrenAccounts) {
|
||||
if (!account || account.type !== AccountType.MultiSubAccounts.type || !account.subAccounts) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let i = 0; i < account.childrenAccounts.length; i++) {
|
||||
if (showHidden || !account.childrenAccounts[i].hidden) {
|
||||
for (let i = 0; i < account.subAccounts.length; i++) {
|
||||
if (showHidden || !account.subAccounts[i].hidden) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+20
-11
@@ -24,15 +24,12 @@ import {
|
||||
import { DEFAULT_ACCOUNT_ICON, DEFAULT_CATEGORY_ICON } from '@/consts/icon.ts';
|
||||
import { DEFAULT_ACCOUNT_COLOR, DEFAULT_CATEGORY_COLOR } from '@/consts/color.ts';
|
||||
|
||||
import type { AccountInfoResponse } from '@/models/account.ts';
|
||||
import type { TransactionCategoryInfoResponse } from '@/models/transaction_category.ts';
|
||||
import type { Account } from '@/models/account.ts';
|
||||
import type { TransactionCategory } from '@/models/transaction_category.ts';
|
||||
import type {
|
||||
TransactionStatisticResponse,
|
||||
TransactionStatisticResponseItem,
|
||||
TransactionStatisticResponseWithInfo,
|
||||
TransactionStatisticResponseItemWithInfo,
|
||||
TransactionStatisticTrendsResponseItem,
|
||||
TransactionStatisticTrendsResponseItemWithInfo,
|
||||
TransactionStatisticDataItemType,
|
||||
TransactionStatisticDataItemBase,
|
||||
TransactionCategoricalAnalysisData,
|
||||
@@ -60,17 +57,29 @@ import { sortStatisticsItems } from '@/lib/statistics.ts';
|
||||
import logger from '@/lib/logger.ts';
|
||||
import services from '@/lib/services.ts';
|
||||
|
||||
interface WritableTransactionStatisticResponseItemWithInfo extends TransactionStatisticResponseItemWithInfo {
|
||||
interface TransactionStatisticResponseItemWithInfo extends TransactionStatisticResponseItem {
|
||||
categoryId: string;
|
||||
accountId: string;
|
||||
amount: number;
|
||||
account?: AccountInfoResponse;
|
||||
primaryAccount?: AccountInfoResponse;
|
||||
category?: TransactionCategoryInfoResponse;
|
||||
primaryCategory?: TransactionCategoryInfoResponse;
|
||||
account?: Account;
|
||||
primaryAccount?: Account;
|
||||
category?: TransactionCategory;
|
||||
primaryCategory?: TransactionCategory;
|
||||
amountInDefaultCurrency: number | null;
|
||||
}
|
||||
|
||||
interface TransactionStatisticResponseWithInfo {
|
||||
readonly startTime: number;
|
||||
readonly endTime: number;
|
||||
readonly items: TransactionStatisticResponseItemWithInfo[];
|
||||
}
|
||||
|
||||
interface TransactionStatisticTrendsResponseItemWithInfo {
|
||||
readonly year: number;
|
||||
readonly month: number;
|
||||
readonly items: TransactionStatisticResponseItemWithInfo[];
|
||||
}
|
||||
|
||||
interface WritableTransactionCategoricalAnalysisData {
|
||||
totalAmount: number;
|
||||
totalNonNegativeAmount: number;
|
||||
@@ -438,7 +447,7 @@ export const useStatisticsStore = defineStore('statistics', () => {
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const dataItem = items[i];
|
||||
const item: WritableTransactionStatisticResponseItemWithInfo = {
|
||||
const item: TransactionStatisticResponseItemWithInfo = {
|
||||
categoryId: dataItem.categoryId,
|
||||
accountId: dataItem.accountId,
|
||||
amount: dataItem.amount,
|
||||
|
||||
@@ -64,12 +64,12 @@ export const useTransactionCategoriesStore = defineStore('transactionCategories'
|
||||
const category = categories[i];
|
||||
allTransactionCategoriesMap.value[category.id] = category;
|
||||
|
||||
if (!category.secondaryCategories) {
|
||||
if (!category.subCategories) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (let j = 0; j < category.secondaryCategories.length; j++) {
|
||||
const subCategory = category.secondaryCategories[j];
|
||||
for (let j = 0; j < category.subCategories.length; j++) {
|
||||
const subCategory = category.subCategories[j];
|
||||
allTransactionCategoriesMap.value[subCategory.id] = subCategory;
|
||||
}
|
||||
}
|
||||
@@ -82,7 +82,7 @@ export const useTransactionCategoriesStore = defineStore('transactionCategories'
|
||||
if (!category.parentId || category.parentId === '0') {
|
||||
categoryList = allTransactionCategories.value[category.type];
|
||||
} else if (allTransactionCategoriesMap.value[category.parentId]) {
|
||||
categoryList = allTransactionCategoriesMap.value[category.parentId].secondaryCategories;
|
||||
categoryList = allTransactionCategoriesMap.value[category.parentId].subCategories;
|
||||
}
|
||||
|
||||
if (categoryList) {
|
||||
@@ -102,14 +102,14 @@ export const useTransactionCategoriesStore = defineStore('transactionCategories'
|
||||
if (!category.parentId || category.parentId === '0') {
|
||||
categoryList = allTransactionCategories.value[category.type];
|
||||
} else if (allTransactionCategoriesMap.value[category.parentId]) {
|
||||
categoryList = allTransactionCategoriesMap.value[category.parentId].secondaryCategories;
|
||||
categoryList = allTransactionCategoriesMap.value[category.parentId].subCategories;
|
||||
}
|
||||
|
||||
if (categoryList) {
|
||||
for (let i = 0; i < categoryList.length; i++) {
|
||||
if (categoryList[i].id === category.id) {
|
||||
if (!category.parentId || category.parentId === '0') {
|
||||
category.secondaryCategories = categoryList[i].secondaryCategories;
|
||||
category.subCategories = categoryList[i].subCategories;
|
||||
}
|
||||
|
||||
categoryList.splice(i, 1, category);
|
||||
@@ -128,7 +128,7 @@ export const useTransactionCategoriesStore = defineStore('transactionCategories'
|
||||
if (!category.parentId || category.parentId === '0') {
|
||||
categoryList = allTransactionCategories.value[category.type];
|
||||
} else if (allTransactionCategoriesMap.value[category.parentId]) {
|
||||
categoryList = allTransactionCategoriesMap.value[category.parentId].secondaryCategories;
|
||||
categoryList = allTransactionCategoriesMap.value[category.parentId].subCategories;
|
||||
}
|
||||
|
||||
if (categoryList) {
|
||||
@@ -148,7 +148,7 @@ export const useTransactionCategoriesStore = defineStore('transactionCategories'
|
||||
if (!category.parentId || category.parentId === '0') {
|
||||
categoryList = allTransactionCategories.value[category.type];
|
||||
} else if (allTransactionCategoriesMap.value[category.parentId]) {
|
||||
categoryList = allTransactionCategoriesMap.value[category.parentId].secondaryCategories;
|
||||
categoryList = allTransactionCategoriesMap.value[category.parentId].subCategories;
|
||||
}
|
||||
|
||||
if (categoryList) {
|
||||
@@ -160,8 +160,8 @@ export const useTransactionCategoriesStore = defineStore('transactionCategories'
|
||||
}
|
||||
}
|
||||
|
||||
if (allTransactionCategoriesMap.value[category.id] && allTransactionCategoriesMap.value[category.id].secondaryCategories) {
|
||||
const subCategoryList = allTransactionCategoriesMap.value[category.id].secondaryCategories;
|
||||
if (allTransactionCategoriesMap.value[category.id] && allTransactionCategoriesMap.value[category.id].subCategories) {
|
||||
const subCategoryList = allTransactionCategoriesMap.value[category.id].subCategories;
|
||||
|
||||
if (subCategoryList) {
|
||||
for (let i = 0; i < subCategoryList.length; i++) {
|
||||
@@ -377,7 +377,7 @@ export const useTransactionCategoriesStore = defineStore('transactionCategories'
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
const subCategoryList = allTransactionCategoriesMap.value[category.parentId].secondaryCategories;
|
||||
const subCategoryList = allTransactionCategoriesMap.value[category.parentId].subCategories;
|
||||
|
||||
if (!subCategoryList || !subCategoryList[to]) {
|
||||
reject({ message: 'Unable to move category' });
|
||||
@@ -403,7 +403,7 @@ export const useTransactionCategoriesStore = defineStore('transactionCategories'
|
||||
if (!parentId || parentId === '0') {
|
||||
categoryList = allTransactionCategories.value[type];
|
||||
} else if (allTransactionCategoriesMap.value[parentId]) {
|
||||
categoryList = allTransactionCategoriesMap.value[parentId].secondaryCategories;
|
||||
categoryList = allTransactionCategoriesMap.value[parentId].subCategories;
|
||||
}
|
||||
|
||||
if (categoryList) {
|
||||
|
||||
Reference in New Issue
Block a user