Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Feature/remove account type from user interface (#2335)

Thomas Kaulab691bb27a85
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a6e4e5b8f6..ce4af8b180 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: <symbol> (<dataSource>)
- 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 c700e7fa94..eb24d959ab 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 d8c62aff78..a91914482e 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 abeaf389d4..fb7e09d41e 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 06e4cebf65..3a4746b6bc 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 126c33ac53..46a5ee7b08 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 @@
>
</div>
<div class="col-6 mb-3">
- <gf-value i18n size="medium" [value]="accountType"
- >Account Type</gf-value
+ <gf-value i18n size="medium" [value]="transactionCount"
+ >Activities</gf-value
>
</div>
<div class="col-6 mb-3">
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 0b859321fb..d3ece8977d 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 @@
<ng-container matColumnDef="transactions">
<th
*matHeaderCellDef
- class="px-1 text-right"
+ class="justify-content-end px-1"
mat-header-cell
mat-sort-header="transactionCount"
>
@@ -93,9 +93,7 @@
<span class="d-none d-sm-block" i18n>Activities</span>
</th>
<td *matCellDef="let element" class="px-1 text-right" mat-cell>
- <ng-container *ngIf="element.accountType === 'SECURITIES'">{{
- element.transactionCount
- }}</ng-container>
+ {{ element.transactionCount }}
</td>
<td *matFooterCellDef class="px-1 text-right" mat-footer-cell>
{{ 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 96bd06816c..ab03340dfe 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 7c1768f1ae..7b6f399a04 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 @@
<input matInput name="name" required [(ngModel)]="data.account.name" />
</mat-form-field>
</div>
- <div>
- <mat-form-field appearance="outline" class="w-100">
- <mat-label i18n>Type</mat-label>
- <mat-select name="type" required [(value)]="data.account.accountType">
- <mat-option i18n value="CASH">Cash</mat-option>
- <mat-option i18n value="SECURITIES">Securities</mat-option>
- </mat-select>
- </mat-form-field>
- </div>
<div>
<mat-form-field appearance="outline" class="w-100">
<mat-label i18n>Currency</mat-label>
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 baa68f7951..c89b6c490f 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 844f04d9cf..ec7a070818 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 a9ab22454f..1fb25f44f4 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 c4201a6ca0..6d27b70f7f 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 b142cb2f80..60fdd93e09 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<Account, 'createdAt' | 'isDefault' | 'updatedAt' | 'userId'>[];
+ 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 fc622c0744..49c4e7b6ec 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 0000000000..7156105425
--- /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 b8e6064a2e..81646012a0 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 9fe1aa8c85..f2aeab113a 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 335d2cd8aa..999006e72d 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",