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

* Remove account type from user interface and set it optional

* Update changelog
pull/2337/head
Thomas Kaul 9 months ago committed by GitHub
parent 8fc5676443
commit ab691bb27a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Harmonized the style of the user interface for granting and revoking public access to share the portfolio - 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 - Improved the logger output of the info service
- Harmonized the logger output: <symbol> (<dataSource>) - Harmonized the logger output: <symbol> (<dataSource>)
- Improved the language localization for Italian (`it`) - Improved the language localization for Italian (`it`)

@ -10,6 +10,7 @@ import {
import { isString } from 'lodash'; import { isString } from 'lodash';
export class CreateAccountDto { export class CreateAccountDto {
@IsOptional()
@IsString() @IsString()
accountType: AccountType; accountType: AccountType;

@ -10,6 +10,7 @@ import {
import { isString } from 'lodash'; import { isString } from 'lodash';
export class UpdateAccountDto { export class UpdateAccountDto {
@IsOptional()
@IsString() @IsString()
accountType: AccountType; accountType: AccountType;

@ -26,18 +26,8 @@ export class ExportService {
where: { userId } where: { userId }
}) })
).map( ).map(
({ ({ balance, comment, currency, id, isExcluded, name, platformId }) => {
accountType,
balance,
comment,
currency,
id,
isExcluded,
name,
platformId
}) => {
return { return {
accountType,
balance, balance,
comment, comment,
currency, currency,

@ -29,13 +29,13 @@ import { AccountDetailDialogParams } from './interfaces/interfaces';
styleUrls: ['./account-detail-dialog.component.scss'] styleUrls: ['./account-detail-dialog.component.scss']
}) })
export class AccountDetailDialog implements OnDestroy, OnInit { export class AccountDetailDialog implements OnDestroy, OnInit {
public accountType: string;
public balance: number; public balance: number;
public currency: string; public currency: string;
public equity: number; public equity: number;
public name: string; public name: string;
public orders: OrderWithAccount[]; public orders: OrderWithAccount[];
public platformName: string; public platformName: string;
public transactionCount: number;
public user: User; public user: User;
public valueInBaseCurrency: number; public valueInBaseCurrency: number;
@ -65,15 +65,14 @@ export class AccountDetailDialog implements OnDestroy, OnInit {
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))
.subscribe( .subscribe(
({ ({
accountType,
balance, balance,
currency, currency,
name, name,
Platform, Platform,
transactionCount,
value, value,
valueInBaseCurrency valueInBaseCurrency
}) => { }) => {
this.accountType = translate(accountType);
this.balance = balance; this.balance = balance;
this.currency = currency; this.currency = currency;
@ -85,6 +84,7 @@ export class AccountDetailDialog implements OnDestroy, OnInit {
this.name = name; this.name = name;
this.platformName = Platform?.name ?? '-'; this.platformName = Platform?.name ?? '-';
this.transactionCount = transactionCount;
this.valueInBaseCurrency = valueInBaseCurrency; this.valueInBaseCurrency = valueInBaseCurrency;
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();

@ -44,8 +44,8 @@
> >
</div> </div>
<div class="col-6 mb-3"> <div class="col-6 mb-3">
<gf-value i18n size="medium" [value]="accountType" <gf-value i18n size="medium" [value]="transactionCount"
>Account Type</gf-value >Activities</gf-value
> >
</div> </div>
<div class="col-6 mb-3"> <div class="col-6 mb-3">

@ -85,7 +85,7 @@
<ng-container matColumnDef="transactions"> <ng-container matColumnDef="transactions">
<th <th
*matHeaderCellDef *matHeaderCellDef
class="px-1 text-right" class="justify-content-end px-1"
mat-header-cell mat-header-cell
mat-sort-header="transactionCount" mat-sort-header="transactionCount"
> >
@ -93,9 +93,7 @@
<span class="d-none d-sm-block" i18n>Activities</span> <span class="d-none d-sm-block" i18n>Activities</span>
</th> </th>
<td *matCellDef="let element" class="px-1 text-right" mat-cell> <td *matCellDef="let element" class="px-1 text-right" mat-cell>
<ng-container *ngIf="element.accountType === 'SECURITIES'">{{ {{ element.transactionCount }}
element.transactionCount
}}</ng-container>
</td> </td>
<td *matFooterCellDef class="px-1 text-right" mat-footer-cell> <td *matFooterCellDef class="px-1 text-right" mat-footer-cell>
{{ transactionCount }} {{ transactionCount }}

@ -10,7 +10,7 @@ import { ImpersonationStorageService } from '@ghostfolio/client/services/imperso
import { UserService } from '@ghostfolio/client/services/user/user.service'; import { UserService } from '@ghostfolio/client/services/user/user.service';
import { User } from '@ghostfolio/common/interfaces'; import { User } from '@ghostfolio/common/interfaces';
import { hasPermission, permissions } from '@ghostfolio/common/permissions'; 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 { DeviceDetectorService } from 'ngx-device-detector';
import { Subject, Subscription } from 'rxjs'; import { Subject, Subscription } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
@ -151,7 +151,6 @@ export class AccountsPageComponent implements OnDestroy, OnInit {
} }
public openUpdateAccountDialog({ public openUpdateAccountDialog({
accountType,
balance, balance,
comment, comment,
currency, currency,
@ -163,7 +162,6 @@ export class AccountsPageComponent implements OnDestroy, OnInit {
const dialogRef = this.dialog.open(CreateOrUpdateAccountDialog, { const dialogRef = this.dialog.open(CreateOrUpdateAccountDialog, {
data: { data: {
account: { account: {
accountType,
balance, balance,
comment, comment,
currency, currency,
@ -232,7 +230,6 @@ export class AccountsPageComponent implements OnDestroy, OnInit {
const dialogRef = this.dialog.open(CreateOrUpdateAccountDialog, { const dialogRef = this.dialog.open(CreateOrUpdateAccountDialog, {
data: { data: {
account: { account: {
accountType: AccountType.SECURITIES,
balance: 0, balance: 0,
comment: null, comment: null,
currency: this.user?.settings?.baseCurrency, currency: this.user?.settings?.baseCurrency,

@ -8,15 +8,6 @@
<input matInput name="name" required [(ngModel)]="data.account.name" /> <input matInput name="name" required [(ngModel)]="data.account.name" />
</mat-form-field> </mat-form-field>
</div> </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> <div>
<mat-form-field appearance="outline" class="w-100"> <mat-form-field appearance="outline" class="w-100">
<mat-label i18n>Currency</mat-label> <mat-label i18n>Currency</mat-label>

@ -238,9 +238,7 @@ export class ActivitiesPageComponent implements OnDestroy, OnInit {
const dialogRef = this.dialog.open(CreateOrUpdateActivityDialog, { const dialogRef = this.dialog.open(CreateOrUpdateActivityDialog, {
data: { data: {
activity, activity,
accounts: this.user?.accounts?.filter((account) => { accounts: this.user?.accounts,
return account.accountType === 'SECURITIES';
}),
user: this.user user: this.user
}, },
height: this.deviceType === 'mobile' ? '97.5vh' : '80vh', height: this.deviceType === 'mobile' ? '97.5vh' : '80vh',
@ -282,9 +280,7 @@ export class ActivitiesPageComponent implements OnDestroy, OnInit {
const dialogRef = this.dialog.open(CreateOrUpdateActivityDialog, { const dialogRef = this.dialog.open(CreateOrUpdateActivityDialog, {
data: { data: {
accounts: this.user?.accounts?.filter((account) => { accounts: this.user?.accounts,
return account.accountType === 'SECURITIES';
}),
activity: { activity: {
...aActivity, ...aActivity,
accountId: aActivity?.accountId ?? this.defaultAccountId, accountId: aActivity?.accountId ?? this.defaultAccountId,

@ -173,17 +173,15 @@ export class AllocationsPageComponent implements OnDestroy, OnInit {
if (state?.user) { if (state?.user) {
this.user = state.user; this.user = state.user;
const accountFilters: Filter[] = this.user.accounts const accountFilters: Filter[] = this.user.accounts.map(
.filter(({ accountType }) => { ({ id, name }) => {
return accountType === 'SECURITIES';
})
.map(({ id, name }) => {
return { return {
id, id,
label: name, label: name,
type: 'ACCOUNT' type: 'ACCOUNT'
}; };
}); }
);
const assetClassFilters: Filter[] = []; const assetClassFilters: Filter[] = [];
for (const assetClass of Object.keys(AssetClass)) { for (const assetClass of Object.keys(AssetClass)) {

@ -139,17 +139,15 @@ export class AnalysisPageComponent implements OnDestroy, OnInit {
if (state?.user) { if (state?.user) {
this.user = state.user; this.user = state.user;
const accountFilters: Filter[] = this.user.accounts const accountFilters: Filter[] = this.user.accounts.map(
.filter(({ accountType }) => { ({ id, name }) => {
return accountType === 'SECURITIES';
})
.map(({ id, name }) => {
return { return {
id, id,
label: name, label: name,
type: 'ACCOUNT' type: 'ACCOUNT'
}; };
}); }
);
const assetClassFilters: Filter[] = []; const assetClassFilters: Filter[] = [];
for (const assetClass of Object.keys(AssetClass)) { for (const assetClass of Object.keys(AssetClass)) {

@ -114,17 +114,15 @@ export class HoldingsPageComponent implements OnDestroy, OnInit {
permissions.createOrder permissions.createOrder
); );
const accountFilters: Filter[] = this.user.accounts const accountFilters: Filter[] = this.user.accounts.map(
.filter(({ accountType }) => { ({ id, name }) => {
return accountType === 'SECURITIES';
})
.map(({ id, name }) => {
return { return {
id, id,
label: name, label: name,
type: 'ACCOUNT' type: 'ACCOUNT'
}; };
}); }
);
const assetClassFilters: Filter[] = []; const assetClassFilters: Filter[] = [];
for (const assetClass of Object.keys(AssetClass)) { for (const assetClass of Object.keys(AssetClass)) {

@ -5,7 +5,10 @@ export interface Export {
date: string; date: string;
version: string; version: string;
}; };
accounts: Omit<Account, 'createdAt' | 'isDefault' | 'updatedAt' | 'userId'>[]; accounts: Omit<
Account,
'accountType' | 'createdAt' | 'isDefault' | 'updatedAt' | 'userId'
>[];
activities: (Omit< activities: (Omit<
Order, Order,
| 'accountUserId' | 'accountUserId'

@ -21,7 +21,6 @@ const locales = {
PRESET_ID: $localize`Preset`, PRESET_ID: $localize`Preset`,
RETIREMENT_PROVISION: $localize`Retirement Provision`, RETIREMENT_PROVISION: $localize`Retirement Provision`,
SATELLITE: $localize`Satellite`, SATELLITE: $localize`Satellite`,
SECURITIES: $localize`Securities`,
SYMBOL: $localize`Symbol`, SYMBOL: $localize`Symbol`,
TAG: $localize`Tag`, TAG: $localize`Tag`,
YEAR: $localize`Year`, YEAR: $localize`Year`,

@ -0,0 +1,3 @@
-- AlterTable
ALTER TABLE "Account" ALTER COLUMN "accountType" DROP NOT NULL,
ALTER COLUMN "accountType" DROP DEFAULT;

@ -21,7 +21,7 @@ model Access {
} }
model Account { model Account {
accountType AccountType @default(SECURITIES) accountType AccountType?
balance Float @default(0) balance Float @default(0)
balances AccountBalance[] balances AccountBalance[]
comment String? comment String?

@ -5,7 +5,6 @@
}, },
"accounts": [ "accounts": [
{ {
"accountType": "SECURITIES",
"balance": 2000, "balance": 2000,
"currency": "USD", "currency": "USD",
"id": "b2d3fe1d-d6a8-41a3-be39-07ef5e9480f0", "id": "b2d3fe1d-d6a8-41a3-be39-07ef5e9480f0",
@ -6016,4 +6015,4 @@
"symbol": "AAPL" "symbol": "AAPL"
} }
] ]
} }

@ -5,7 +5,6 @@
}, },
"accounts": [ "accounts": [
{ {
"accountType": "SECURITIES",
"balance": 2000, "balance": 2000,
"currency": "USD", "currency": "USD",
"id": "b2d3fe1d-d6a8-41a3-be39-07ef5e9480f0", "id": "b2d3fe1d-d6a8-41a3-be39-07ef5e9480f0",

Loading…
Cancel
Save