diff --git a/src/lib/account.ts b/src/lib/account.ts index ee818022..2c68dacd 100644 --- a/src/lib/account.ts +++ b/src/lib/account.ts @@ -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, allAccou } export function isAccountOrSubAccountsAllChecked(account: Account, filterAccountIds: Record): 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): 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 { diff --git a/src/lib/category.ts b/src/lib/category.ts index 4e260506..c0206a86 100644 --- a/src/lib/category.ts +++ b/src/lib/category.ts @@ -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, 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, allTran } export function isCategoryOrSubCategoriesAllChecked(category: TransactionCategory, filterCategoryIds: Record): 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): 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): 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; } diff --git a/src/models/account.ts b/src/models/account.ts index d372be08..47d76f81 100644 --- a/src/models/account.ts +++ b/src/models/account.ts @@ -21,9 +21,9 @@ export class Account implements AccountInfoResponse { public isAsset?: boolean; public isLiability?: boolean; public visible: boolean; - public childrenAccounts?: Account[]; + public subAccounts?: Account[]; - protected constructor(id: string, name: string, parentId: string, category: number, type: number, icon: string, color: string, currency: string, balance: number, comment: string, displayOrder: number, visible: boolean, balanceTime?: number, creditCardStatementDate?: number, isAsset?: boolean, isLiability?: boolean, childrenAccounts?: Account[]) { + protected constructor(id: string, name: string, parentId: string, category: number, type: number, icon: string, color: string, currency: string, balance: number, comment: string, displayOrder: number, visible: boolean, balanceTime?: number, creditCardStatementDate?: number, isAsset?: boolean, isLiability?: boolean, subAccounts?: Account[]) { this.id = id; this.name = name; this.parentId = parentId; @@ -41,10 +41,10 @@ export class Account implements AccountInfoResponse { this.isAsset = isAsset; this.isLiability = isLiability; - if (typeof(childrenAccounts) !== 'undefined') { - this.childrenAccounts = childrenAccounts; + if (typeof(subAccounts) !== 'undefined') { + this.subAccounts = subAccounts; } else { - this.childrenAccounts = undefined; + this.subAccounts = undefined; } } @@ -52,22 +52,6 @@ export class Account implements AccountInfoResponse { return !this.visible; } - public get subAccounts(): AccountInfoResponse[] | undefined { - if (typeof(this.childrenAccounts) === 'undefined') { - return undefined; - } - - const ret: AccountInfoResponse[] = []; - - if (this.childrenAccounts) { - for (const subCategory of this.childrenAccounts) { - ret.push(subCategory); - } - } - - return ret; - } - public from(other: Account): void { this.id = other.id; this.category = other.category; @@ -83,19 +67,19 @@ export class Account implements AccountInfoResponse { this.visible = other.visible; } - public toCreateRequest(clientSessionId: string, childrenAccounts?: Account[], parentAccount?: Account): AccountCreateRequest { - let subAccounts: AccountCreateRequest[] | undefined = undefined; + public toCreateRequest(clientSessionId: string, subAccounts?: Account[], parentAccount?: Account): AccountCreateRequest { + let subAccountCreateRequests: AccountCreateRequest[] | undefined = undefined; if (this.type === AccountType.MultiSubAccounts.type) { - subAccounts = []; + subAccountCreateRequests = []; - if (!childrenAccounts) { - childrenAccounts = this.childrenAccounts; + if (!subAccounts) { + subAccounts = this.subAccounts; } - if (childrenAccounts) { - for (const subAccount of childrenAccounts) { - subAccounts.push(subAccount.toCreateRequest(clientSessionId, undefined, this)); + if (subAccounts) { + for (const subAccount of subAccounts) { + subAccountCreateRequests.push(subAccount.toCreateRequest(clientSessionId, undefined, this)); } } } @@ -111,24 +95,24 @@ export class Account implements AccountInfoResponse { balanceTime: (parentAccount || this.type === AccountType.SingleAccount.type) && this.balanceTime ? this.balanceTime : 0, comment: this.comment, creditCardStatementDate: !parentAccount && this.category === AccountCategory.CreditCard.type ? this.creditCardStatementDate : undefined, - subAccounts: !parentAccount ? subAccounts : undefined, + subAccounts: !parentAccount ? subAccountCreateRequests : undefined, clientSessionId: !parentAccount ? clientSessionId : undefined }; } - public toModifyRequest(childrenAccounts?: Account[], parentAccount?: Account): AccountModifyRequest { - let subAccounts: AccountModifyRequest[] | undefined = undefined; + public toModifyRequest(subAccounts?: Account[], parentAccount?: Account): AccountModifyRequest { + let subAccountModifyRequests: AccountModifyRequest[] | undefined = undefined; if (this.type === AccountType.MultiSubAccounts.type) { - subAccounts = []; + subAccountModifyRequests = []; - if (!childrenAccounts) { - childrenAccounts = this.childrenAccounts; + if (!subAccounts) { + subAccounts = this.subAccounts; } - if (childrenAccounts) { - for (const subAccount of childrenAccounts) { - subAccounts.push(subAccount.toModifyRequest(undefined, this)); + if (subAccounts) { + for (const subAccount of subAccounts) { + subAccountModifyRequests.push(subAccount.toModifyRequest(undefined, this)); } } } @@ -142,7 +126,7 @@ export class Account implements AccountInfoResponse { comment: this.comment, creditCardStatementDate: !parentAccount && this.category === AccountCategory.CreditCard.type ? this.creditCardStatementDate : undefined, hidden: !this.visible, - subAccounts: !parentAccount ? subAccounts : undefined, + subAccounts: !parentAccount ? subAccountModifyRequests : undefined, }; } @@ -152,12 +136,12 @@ export class Account implements AccountInfoResponse { } else if (this.type === AccountType.MultiSubAccounts.type && !subAccountId) { return this.id; } else if (this.type === AccountType.MultiSubAccounts.type && subAccountId) { - if (!this.childrenAccounts || !this.childrenAccounts.length) { + if (!this.subAccounts || !this.subAccounts.length) { return null; } - for (let i = 0; i < this.childrenAccounts.length; i++) { - const subAccount = this.childrenAccounts[i]; + for (let i = 0; i < this.subAccounts.length; i++) { + const subAccount = this.subAccounts[i]; if (subAccountId && subAccountId === subAccount.id) { return subAccount.id; @@ -176,12 +160,12 @@ export class Account implements AccountInfoResponse { } else if (this.type === AccountType.MultiSubAccounts.type && !subAccountId) { return this.comment; } else if (this.type === AccountType.MultiSubAccounts.type && subAccountId) { - if (!this.childrenAccounts || !this.childrenAccounts.length) { + if (!this.subAccounts || !this.subAccounts.length) { return null; } - for (let i = 0; i < this.childrenAccounts.length; i++) { - const subAccount = this.childrenAccounts[i]; + for (let i = 0; i < this.subAccounts.length; i++) { + const subAccount = this.subAccounts[i]; if (subAccountId && subAccountId === subAccount.id) { return subAccount.comment; @@ -195,15 +179,15 @@ export class Account implements AccountInfoResponse { } public getSubAccountCurrencies(showHidden: boolean, subAccountId: string): string[] { - if (!this.childrenAccounts || !this.childrenAccounts.length) { + if (!this.subAccounts || !this.subAccounts.length) { return []; } const subAccountCurrenciesMap: Record = {}; const subAccountCurrencies: string[] = []; - for (let i = 0; i < this.childrenAccounts.length; i++) { - const subAccount = this.childrenAccounts[i]; + for (let i = 0; i < this.subAccounts.length; i++) { + const subAccount = this.subAccounts[i]; if (!showHidden && subAccount.hidden) { continue; @@ -324,7 +308,7 @@ export class AccountWithDisplayBalance extends Account { Account.creditCardStatementDate, Account.isAsset, Account.isLiability, - Account.childrenAccounts + Account.subAccounts ); this.displayBalance = displayBalance; diff --git a/src/models/transaction.ts b/src/models/transaction.ts index 447dd3a6..d8ec3419 100644 --- a/src/models/transaction.ts +++ b/src/models/transaction.ts @@ -675,32 +675,12 @@ export interface TransactionStatisticResponseItem { readonly amount: number; } -export interface TransactionStatisticResponseWithInfo { - readonly startTime: number; - readonly endTime: number; - readonly items: TransactionStatisticResponseItemWithInfo[]; -} - -export interface TransactionStatisticResponseItemWithInfo extends TransactionStatisticResponseItem { - readonly account?: AccountInfoResponse; - readonly primaryAccount?: AccountInfoResponse; - readonly category?: TransactionCategoryInfoResponse; - readonly primaryCategory?: TransactionCategoryInfoResponse; - readonly amountInDefaultCurrency: number | null; -} - export interface TransactionStatisticTrendsResponseItem { readonly year: number; readonly month: number; readonly items: TransactionStatisticResponseItem[]; } -export interface TransactionStatisticTrendsResponseItemWithInfo { - readonly year: number; - readonly month: number; - readonly items: TransactionStatisticResponseItemWithInfo[]; -} - export interface YearMonthDataItem extends YearMonth, Record {} export interface YearMonthItems extends Record { diff --git a/src/models/transaction_category.ts b/src/models/transaction_category.ts index 869a148b..78eef8e3 100644 --- a/src/models/transaction_category.ts +++ b/src/models/transaction_category.ts @@ -13,9 +13,9 @@ export class TransactionCategory implements TransactionCategoryInfoResponse { public comment: string; public displayOrder: number; public visible: boolean; - public secondaryCategories?: TransactionCategory[]; + public subCategories?: TransactionCategory[]; - private constructor(id: string, name: string, parentId: string, type: CategoryType, icon: string, color: ColorValue, comment: string, displayOrder: number, visible: boolean, secondaryCategories?: TransactionCategory[]) { + private constructor(id: string, name: string, parentId: string, type: CategoryType, icon: string, color: ColorValue, comment: string, displayOrder: number, visible: boolean, subCategories?: TransactionCategory[]) { this.id = id; this.name = name; this.parentId = parentId; @@ -26,10 +26,10 @@ export class TransactionCategory implements TransactionCategoryInfoResponse { this.displayOrder = displayOrder; this.visible = visible; - if (secondaryCategories) { - this.secondaryCategories = secondaryCategories; - } else if (!secondaryCategories && (!parentId || parentId === '0')) { - this.secondaryCategories = []; + if (subCategories) { + this.subCategories = subCategories; + } else if (!subCategories && (!parentId || parentId === '0')) { + this.subCategories = []; } } @@ -37,22 +37,6 @@ export class TransactionCategory implements TransactionCategoryInfoResponse { return !this.visible; } - public get subCategories(): TransactionCategoryInfoResponse[] | undefined { - if (typeof(this.secondaryCategories) === 'undefined') { - return undefined; - } - - const ret: TransactionCategoryInfoResponse[] = []; - - if (this.secondaryCategories) { - for (const subCategory of this.secondaryCategories) { - ret.push(subCategory); - } - } - - return ret; - } - public from(other: TransactionCategory): void { this.id = other.id; this.name = other.name; diff --git a/src/stores/account.ts b/src/stores/account.ts index c5005891..1c1b7486 100644 --- a/src/stores/account.ts +++ b/src/stores/account.ts @@ -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; } } diff --git a/src/stores/statistics.ts b/src/stores/statistics.ts index f308002b..55db63a8 100644 --- a/src/stores/statistics.ts +++ b/src/stores/statistics.ts @@ -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, diff --git a/src/stores/transactionCategory.ts b/src/stores/transactionCategory.ts index 373d3056..5f86ab71 100644 --- a/src/stores/transactionCategory.ts +++ b/src/stores/transactionCategory.ts @@ -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) { diff --git a/src/views/base/accounts/AccountEditPageBase.ts b/src/views/base/accounts/AccountEditPageBase.ts index ea11f62b..9ed09781 100644 --- a/src/views/base/accounts/AccountEditPageBase.ts +++ b/src/views/base/accounts/AccountEditPageBase.ts @@ -144,10 +144,10 @@ export function useAccountEditPageBaseBase() { account.value.from(newAccount); subAccounts.value = []; - if (newAccount.childrenAccounts && newAccount.childrenAccounts.length > 0) { - for (let i = 0; i < newAccount.childrenAccounts.length; i++) { + if (newAccount.subAccounts && newAccount.subAccounts.length > 0) { + for (let i = 0; i < newAccount.subAccounts.length; i++) { const subAccount = account.value.createNewSubAccount(userStore.currentUserDefaultCurrency, getCurrentUnixTime()); - subAccount.from(newAccount.childrenAccounts[i]); + subAccount.from(newAccount.subAccounts[i]); subAccounts.value.push(subAccount); } diff --git a/src/views/base/settings/CategoryFilterSettingPageBase.ts b/src/views/base/settings/CategoryFilterSettingPageBase.ts index ce762ccb..5303cf4f 100644 --- a/src/views/base/settings/CategoryFilterSettingPageBase.ts +++ b/src/views/base/settings/CategoryFilterSettingPageBase.ts @@ -109,7 +109,7 @@ export function useCategoryFilterSettingPageBase(type?: string, allowCategoryTyp const category = transactionCategoriesStore.allTransactionCategoriesMap[categoryId]; - if (category && (!category.secondaryCategories || !category.secondaryCategories.length)) { + if (category && (!category.subCategories || !category.subCategories.length)) { allCategoryIds[category.id] = false; } else if (category) { selectAllSubCategories(allCategoryIds, category, false); diff --git a/src/views/desktop/accounts/ListPage.vue b/src/views/desktop/accounts/ListPage.vue index e4f4f0df..6ae10811 100644 --- a/src/views/desktop/accounts/ListPage.vue +++ b/src/views/desktop/accounts/ListPage.vue @@ -184,7 +184,7 @@ {{ tt('All') }} diff --git a/src/views/desktop/categories/ListPage.vue b/src/views/desktop/categories/ListPage.vue index 6e480ae2..23dd564b 100644 --- a/src/views/desktop/categories/ListPage.vue +++ b/src/views/desktop/categories/ListPage.vue @@ -267,7 +267,7 @@ const secondaryCategories = computed(() => { return []; } - return transactionCategoriesStore.allTransactionCategoriesMap[primaryCategoryId.value].secondaryCategories || []; + return transactionCategoriesStore.allTransactionCategoriesMap[primaryCategoryId.value].subCategories || []; }); const hasSubCategories = computed(() => { diff --git a/src/views/desktop/transactions/ListPage.vue b/src/views/desktop/transactions/ListPage.vue index bade8a7d..edd89e4d 100644 --- a/src/views/desktop/transactions/ListPage.vue +++ b/src/views/desktop/transactions/ListPage.vue @@ -234,7 +234,7 @@