Browse Source

Feature/remove is default flag from account database schema (#3041)

* Remove isDefault flag from Account database schema

* Update changelog
pull/3039/head^2
Thomas Kaul 11 months ago
committed by GitHub
parent
commit
6be38a1c19
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      CHANGELOG.md
  2. 2
      apps/api/src/app/account/account.controller.ts
  3. 10
      apps/api/src/app/user/user.service.ts
  4. 9
      apps/client/src/app/components/accounts-table/accounts-table.component.html
  5. 1
      apps/client/src/app/pages/i18n/i18n-page.html
  6. 7
      apps/client/src/app/pages/portfolio/activities/activities-page.component.ts
  7. 4362
      apps/client/src/locales/messages.de.xlf
  8. 4362
      apps/client/src/locales/messages.es.xlf
  9. 4362
      apps/client/src/locales/messages.fr.xlf
  10. 4360
      apps/client/src/locales/messages.it.xlf
  11. 4360
      apps/client/src/locales/messages.nl.xlf
  12. 4276
      apps/client/src/locales/messages.pl.xlf
  13. 4362
      apps/client/src/locales/messages.pt.xlf
  14. 4360
      apps/client/src/locales/messages.tr.xlf
  15. 4262
      apps/client/src/locales/messages.xlf
  16. 2
      libs/common/src/lib/interfaces/export.interface.ts
  17. 2
      prisma/migrations/20240224102024_removed_is_default_from_account/migration.sql
  18. 1
      prisma/schema.prisma

2
CHANGELOG.md

@ -9,7 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Removed the `isDefault` flag from the `Account` database schema
- Exposed the database index of _Redis_ as an environment variable (`REDIS_DB`)
- Improved the language localization for German (`de`)
- Upgraded `prisma` from version `5.9.1` to `5.10.2`
## 2.55.0 - 2024-02-22

2
apps/api/src/app/account/account.controller.ts

@ -63,7 +63,7 @@ export class AccountController {
{ Order: true }
);
if (account?.isDefault || account?.Order.length > 0) {
if (!account || account?.Order.length > 0) {
throw new HttpException(
getReasonPhrase(StatusCodes.FORBIDDEN),
StatusCodes.FORBIDDEN

10
apps/api/src/app/user/user.service.ts

@ -1,11 +1,13 @@
import { SubscriptionService } from '@ghostfolio/api/app/subscription/subscription.service';
import { environment } from '@ghostfolio/api/environments/environment';
import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service';
import { I18nService } from '@ghostfolio/api/services/i18n/i18n.service';
import { PrismaService } from '@ghostfolio/api/services/prisma/prisma.service';
import { PropertyService } from '@ghostfolio/api/services/property/property.service';
import { TagService } from '@ghostfolio/api/services/tag/tag.service';
import {
DEFAULT_CURRENCY,
DEFAULT_LANGUAGE_CODE,
PROPERTY_IS_READ_ONLY_MODE,
PROPERTY_SYSTEM_MESSAGE,
locale
@ -31,6 +33,8 @@ const crypto = require('crypto');
@Injectable()
export class UserService {
private i18nService = new I18nService();
public constructor(
private readonly configurationService: ConfigurationService,
private readonly prismaService: PrismaService,
@ -325,8 +329,10 @@ export class UserService {
Account: {
create: {
currency: DEFAULT_CURRENCY,
isDefault: true,
name: 'Default Account'
name: this.i18nService.getTranslation({
id: 'myAccount',
languageCode: DEFAULT_LANGUAGE_CODE // TODO
})
}
},
Settings: {

9
apps/client/src/app/components/accounts-table/accounts-table.component.html

@ -40,12 +40,7 @@
[tooltip]="element.Platform?.name"
[url]="element.Platform?.url"
/>
<span>{{ element.name }} </span>
<span
*ngIf="element.isDefault"
class="d-lg-inline-block d-none text-muted"
>(Default)</span
>
<span>{{ element.name }}</span>
</td>
<td *matFooterCellDef class="px-1" i18n mat-footer-cell>Total</td>
</ng-container>
@ -261,7 +256,7 @@
</button>
<button
mat-menu-item
[disabled]="element.isDefault || element.transactionCount > 0"
[disabled]="element.transactionCount > 0"
(click)="onDeleteAccount(element.id)"
>
<span class="align-items-center d-flex">

1
apps/client/src/app/pages/i18n/i18n-page.html

@ -10,6 +10,7 @@
app, asset, cryptocurrency, dashboard, etf, finance, management,
performance, portfolio, software, stock, trading, wealth, web3
</li>
<li i18n="@@myAccount">My Account</li>
<li i18n="@@slogan">Open Source Wealth Management Software</li>
</ul>
</div>

7
apps/client/src/app/pages/portfolio/activities/activities-page.component.ts

@ -36,7 +36,6 @@ import { ImportActivitiesDialogParams } from './import-activities-dialog/interfa
export class ActivitiesPageComponent implements OnDestroy, OnInit {
public activities: Activity[];
public dataSource: MatTableDataSource<Activity>;
public defaultAccountId: string;
public deviceType: string;
public hasImpersonationId: boolean;
public hasPermissionToCreateActivity: boolean;
@ -323,7 +322,7 @@ export class ActivitiesPageComponent implements OnDestroy, OnInit {
accounts: this.user?.accounts,
activity: {
...aActivity,
accountId: aActivity?.accountId ?? this.defaultAccountId,
accountId: aActivity?.accountId,
date: new Date(),
id: null,
fee: 0,
@ -399,10 +398,6 @@ export class ActivitiesPageComponent implements OnDestroy, OnInit {
private updateUser(aUser: User) {
this.user = aUser;
this.defaultAccountId = this.user?.accounts.find((account) => {
return account.isDefault;
})?.id;
this.hasPermissionToCreateActivity =
!this.hasImpersonationId &&
hasPermission(this.user.permissions, permissions.createOrder);

4362
apps/client/src/locales/messages.de.xlf

File diff suppressed because it is too large

4362
apps/client/src/locales/messages.es.xlf

File diff suppressed because it is too large

4362
apps/client/src/locales/messages.fr.xlf

File diff suppressed because it is too large

4360
apps/client/src/locales/messages.it.xlf

File diff suppressed because it is too large

4360
apps/client/src/locales/messages.nl.xlf

File diff suppressed because it is too large

4276
apps/client/src/locales/messages.pl.xlf

File diff suppressed because it is too large

4362
apps/client/src/locales/messages.pt.xlf

File diff suppressed because it is too large

4360
apps/client/src/locales/messages.tr.xlf

File diff suppressed because it is too large

4262
apps/client/src/locales/messages.xlf

File diff suppressed because it is too large

2
libs/common/src/lib/interfaces/export.interface.ts

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

2
prisma/migrations/20240224102024_removed_is_default_from_account/migration.sql

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Account" DROP COLUMN "isDefault";

1
prisma/schema.prisma

@ -32,7 +32,6 @@ model Account {
createdAt DateTime @default(now())
currency String?
id String @default(uuid())
isDefault Boolean @default(false)
isExcluded Boolean @default(false)
name String?
platformId String?

Loading…
Cancel
Save