diff --git a/CHANGELOG.md b/CHANGELOG.md index a6e4e5b8f..ce4af8b18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Harmonized the style of the user interface for granting and revoking public access to share the portfolio +- Removed the account type from the user interface as a preparation to remove it from the `Account` database schema - Improved the logger output of the info service - Harmonized the logger output: () - Improved the language localization for Italian (`it`) diff --git a/apps/api/src/app/account/create-account.dto.ts b/apps/api/src/app/account/create-account.dto.ts index c700e7fa9..eb24d959a 100644 --- a/apps/api/src/app/account/create-account.dto.ts +++ b/apps/api/src/app/account/create-account.dto.ts @@ -10,6 +10,7 @@ import { import { isString } from 'lodash'; export class CreateAccountDto { + @IsOptional() @IsString() accountType: AccountType; diff --git a/apps/api/src/app/account/update-account.dto.ts b/apps/api/src/app/account/update-account.dto.ts index d8c62aff7..a91914482 100644 --- a/apps/api/src/app/account/update-account.dto.ts +++ b/apps/api/src/app/account/update-account.dto.ts @@ -10,6 +10,7 @@ import { import { isString } from 'lodash'; export class UpdateAccountDto { + @IsOptional() @IsString() accountType: AccountType; diff --git a/apps/api/src/app/export/export.service.ts b/apps/api/src/app/export/export.service.ts index abeaf389d..fb7e09d41 100644 --- a/apps/api/src/app/export/export.service.ts +++ b/apps/api/src/app/export/export.service.ts @@ -26,18 +26,8 @@ export class ExportService { where: { userId } }) ).map( - ({ - accountType, - balance, - comment, - currency, - id, - isExcluded, - name, - platformId - }) => { + ({ balance, comment, currency, id, isExcluded, name, platformId }) => { return { - accountType, balance, comment, currency, diff --git a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts index 06e4cebf6..3a4746b6b 100644 --- a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts +++ b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts @@ -29,13 +29,13 @@ import { AccountDetailDialogParams } from './interfaces/interfaces'; styleUrls: ['./account-detail-dialog.component.scss'] }) export class AccountDetailDialog implements OnDestroy, OnInit { - public accountType: string; public balance: number; public currency: string; public equity: number; public name: string; public orders: OrderWithAccount[]; public platformName: string; + public transactionCount: number; public user: User; public valueInBaseCurrency: number; @@ -65,15 +65,14 @@ export class AccountDetailDialog implements OnDestroy, OnInit { .pipe(takeUntil(this.unsubscribeSubject)) .subscribe( ({ - accountType, balance, currency, name, Platform, + transactionCount, value, valueInBaseCurrency }) => { - this.accountType = translate(accountType); this.balance = balance; this.currency = currency; @@ -85,6 +84,7 @@ export class AccountDetailDialog implements OnDestroy, OnInit { this.name = name; this.platformName = Platform?.name ?? '-'; + this.transactionCount = transactionCount; this.valueInBaseCurrency = valueInBaseCurrency; this.changeDetectorRef.markForCheck(); diff --git a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html index 126c33ac5..46a5ee7b0 100644 --- a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html +++ b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html @@ -44,8 +44,8 @@ >
- Account TypeActivities
diff --git a/apps/client/src/app/components/accounts-table/accounts-table.component.html b/apps/client/src/app/components/accounts-table/accounts-table.component.html index 0b859321f..d3ece8977 100644 --- a/apps/client/src/app/components/accounts-table/accounts-table.component.html +++ b/apps/client/src/app/components/accounts-table/accounts-table.component.html @@ -85,7 +85,7 @@ @@ -93,9 +93,7 @@ Activities - {{ - element.transactionCount - }} + {{ element.transactionCount }} {{ transactionCount }} diff --git a/apps/client/src/app/pages/accounts/accounts-page.component.ts b/apps/client/src/app/pages/accounts/accounts-page.component.ts index 96bd06816..ab03340df 100644 --- a/apps/client/src/app/pages/accounts/accounts-page.component.ts +++ b/apps/client/src/app/pages/accounts/accounts-page.component.ts @@ -10,7 +10,7 @@ import { ImpersonationStorageService } from '@ghostfolio/client/services/imperso import { UserService } from '@ghostfolio/client/services/user/user.service'; import { User } from '@ghostfolio/common/interfaces'; import { hasPermission, permissions } from '@ghostfolio/common/permissions'; -import { Account as AccountModel, AccountType } from '@prisma/client'; +import { Account as AccountModel } from '@prisma/client'; import { DeviceDetectorService } from 'ngx-device-detector'; import { Subject, Subscription } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; @@ -151,7 +151,6 @@ export class AccountsPageComponent implements OnDestroy, OnInit { } public openUpdateAccountDialog({ - accountType, balance, comment, currency, @@ -163,7 +162,6 @@ export class AccountsPageComponent implements OnDestroy, OnInit { const dialogRef = this.dialog.open(CreateOrUpdateAccountDialog, { data: { account: { - accountType, balance, comment, currency, @@ -232,7 +230,6 @@ export class AccountsPageComponent implements OnDestroy, OnInit { const dialogRef = this.dialog.open(CreateOrUpdateAccountDialog, { data: { account: { - accountType: AccountType.SECURITIES, balance: 0, comment: null, currency: this.user?.settings?.baseCurrency, diff --git a/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.html b/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.html index 7c1768f1a..7b6f399a0 100644 --- a/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.html +++ b/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.html @@ -8,15 +8,6 @@
-
- - Type - - Cash - Securities - - -
Currency diff --git a/apps/client/src/app/pages/portfolio/activities/activities-page.component.ts b/apps/client/src/app/pages/portfolio/activities/activities-page.component.ts index baa68f795..c89b6c490 100644 --- a/apps/client/src/app/pages/portfolio/activities/activities-page.component.ts +++ b/apps/client/src/app/pages/portfolio/activities/activities-page.component.ts @@ -238,9 +238,7 @@ export class ActivitiesPageComponent implements OnDestroy, OnInit { const dialogRef = this.dialog.open(CreateOrUpdateActivityDialog, { data: { activity, - accounts: this.user?.accounts?.filter((account) => { - return account.accountType === 'SECURITIES'; - }), + accounts: this.user?.accounts, user: this.user }, height: this.deviceType === 'mobile' ? '97.5vh' : '80vh', @@ -282,9 +280,7 @@ export class ActivitiesPageComponent implements OnDestroy, OnInit { const dialogRef = this.dialog.open(CreateOrUpdateActivityDialog, { data: { - accounts: this.user?.accounts?.filter((account) => { - return account.accountType === 'SECURITIES'; - }), + accounts: this.user?.accounts, activity: { ...aActivity, accountId: aActivity?.accountId ?? this.defaultAccountId, diff --git a/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts b/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts index 844f04d9c..ec7a07081 100644 --- a/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts +++ b/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts @@ -173,17 +173,15 @@ export class AllocationsPageComponent implements OnDestroy, OnInit { if (state?.user) { this.user = state.user; - const accountFilters: Filter[] = this.user.accounts - .filter(({ accountType }) => { - return accountType === 'SECURITIES'; - }) - .map(({ id, name }) => { + const accountFilters: Filter[] = this.user.accounts.map( + ({ id, name }) => { return { id, label: name, type: 'ACCOUNT' }; - }); + } + ); const assetClassFilters: Filter[] = []; for (const assetClass of Object.keys(AssetClass)) { diff --git a/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts b/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts index a9ab22454..1fb25f44f 100644 --- a/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts +++ b/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts @@ -139,17 +139,15 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { if (state?.user) { this.user = state.user; - const accountFilters: Filter[] = this.user.accounts - .filter(({ accountType }) => { - return accountType === 'SECURITIES'; - }) - .map(({ id, name }) => { + const accountFilters: Filter[] = this.user.accounts.map( + ({ id, name }) => { return { id, label: name, type: 'ACCOUNT' }; - }); + } + ); const assetClassFilters: Filter[] = []; for (const assetClass of Object.keys(AssetClass)) { diff --git a/apps/client/src/app/pages/portfolio/holdings/holdings-page.component.ts b/apps/client/src/app/pages/portfolio/holdings/holdings-page.component.ts index c4201a6ca..6d27b70f7 100644 --- a/apps/client/src/app/pages/portfolio/holdings/holdings-page.component.ts +++ b/apps/client/src/app/pages/portfolio/holdings/holdings-page.component.ts @@ -114,17 +114,15 @@ export class HoldingsPageComponent implements OnDestroy, OnInit { permissions.createOrder ); - const accountFilters: Filter[] = this.user.accounts - .filter(({ accountType }) => { - return accountType === 'SECURITIES'; - }) - .map(({ id, name }) => { + const accountFilters: Filter[] = this.user.accounts.map( + ({ id, name }) => { return { id, label: name, type: 'ACCOUNT' }; - }); + } + ); const assetClassFilters: Filter[] = []; for (const assetClass of Object.keys(AssetClass)) { diff --git a/libs/common/src/lib/interfaces/export.interface.ts b/libs/common/src/lib/interfaces/export.interface.ts index b142cb2f8..60fdd93e0 100644 --- a/libs/common/src/lib/interfaces/export.interface.ts +++ b/libs/common/src/lib/interfaces/export.interface.ts @@ -5,7 +5,10 @@ export interface Export { date: string; version: string; }; - accounts: Omit[]; + accounts: Omit< + Account, + 'accountType' | 'createdAt' | 'isDefault' | 'updatedAt' | 'userId' + >[]; activities: (Omit< Order, | 'accountUserId' diff --git a/libs/ui/src/lib/i18n.ts b/libs/ui/src/lib/i18n.ts index fc622c074..49c4e7b6e 100644 --- a/libs/ui/src/lib/i18n.ts +++ b/libs/ui/src/lib/i18n.ts @@ -21,7 +21,6 @@ const locales = { PRESET_ID: $localize`Preset`, RETIREMENT_PROVISION: $localize`Retirement Provision`, SATELLITE: $localize`Satellite`, - SECURITIES: $localize`Securities`, SYMBOL: $localize`Symbol`, TAG: $localize`Tag`, YEAR: $localize`Year`, diff --git a/prisma/migrations/20230915141658_changed_account_type_to_optional_in_account/migration.sql b/prisma/migrations/20230915141658_changed_account_type_to_optional_in_account/migration.sql new file mode 100644 index 000000000..715610542 --- /dev/null +++ b/prisma/migrations/20230915141658_changed_account_type_to_optional_in_account/migration.sql @@ -0,0 +1,3 @@ +-- AlterTable +ALTER TABLE "Account" ALTER COLUMN "accountType" DROP NOT NULL, +ALTER COLUMN "accountType" DROP DEFAULT; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index b8e6064a2..81646012a 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -21,7 +21,7 @@ model Access { } model Account { - accountType AccountType @default(SECURITIES) + accountType AccountType? balance Float @default(0) balances AccountBalance[] comment String? diff --git a/test/import/ok-500-activities.json b/test/import/ok-500-activities.json index 9fe1aa8c8..f2aeab113 100644 --- a/test/import/ok-500-activities.json +++ b/test/import/ok-500-activities.json @@ -5,7 +5,6 @@ }, "accounts": [ { - "accountType": "SECURITIES", "balance": 2000, "currency": "USD", "id": "b2d3fe1d-d6a8-41a3-be39-07ef5e9480f0", @@ -6016,4 +6015,4 @@ "symbol": "AAPL" } ] -} \ No newline at end of file +} diff --git a/test/import/ok.json b/test/import/ok.json index 335d2cd8a..999006e72 100644 --- a/test/import/ok.json +++ b/test/import/ok.json @@ -5,7 +5,6 @@ }, "accounts": [ { - "accountType": "SECURITIES", "balance": 2000, "currency": "USD", "id": "b2d3fe1d-d6a8-41a3-be39-07ef5e9480f0",