Browse Source

Merge branch 'main' of https://github.com/ghostfolio/ghostfolio

pull/8381/head
jbpcasoy 4 weeks ago
parent
commit
a8a889ac71
  1. 3
      CHANGELOG.md
  2. 11
      apps/api/src/app/endpoints/activities/activities.controller.ts
  3. 14
      apps/api/src/events/portfolio-changed.listener.ts
  4. 2
      apps/api/src/guards/access.guard.ts
  5. 10
      apps/api/src/helper/bearer-token.helper.ts
  6. 2
      apps/api/src/helper/country.helper.ts
  7. 6
      apps/api/src/helper/data-source.helper.spec.ts
  8. 4
      apps/api/src/helper/data-source.helper.ts
  9. 2
      apps/api/src/helper/markdown-table.helper.ts
  10. 4
      apps/api/src/helper/portfolio.helper.ts
  11. 2
      apps/api/src/helper/string.helper.ts
  12. 4
      apps/api/src/main.ts
  13. 2
      apps/api/src/middlewares/mcp-authorization.middleware.ts
  14. 182
      apps/api/src/services/activities/activities.service.spec.ts
  15. 33
      apps/api/src/services/activities/activities.service.ts
  16. 4
      package-lock.json
  17. 2
      package.json
  18. 5
      prisma/migrations/20261029000000_removed_redundant_currency_from_order/migration.sql

3
CHANGELOG.md

@ -5,12 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased ## 3.95.0 - 2026-10-31
### Changed ### Changed
- Localized the number formatting in the tooltip of the line chart, the investment chart and the benchmark comparator - Localized the number formatting in the tooltip of the line chart, the investment chart and the benchmark comparator
- Deprecated the `api/v1/symbol` endpoints in favor of the `api/v1/symbols` endpoints - Deprecated the `api/v1/symbol` endpoints in favor of the `api/v1/symbols` endpoints
- Removed the redundant currency from the activities in the currency of the asset profile
- Changed the _Redis_ image from `redis:alpine` to `redis:8-alpine` in the `docker-compose` file (`docker-compose.yml`) - Changed the _Redis_ image from `redis:alpine` to `redis:8-alpine` in the `docker-compose` file (`docker-compose.yml`)
- Upgraded `@internationalized/number` from version `3.6.8` to `3.6.9` - Upgraded `@internationalized/number` from version `3.6.8` to `3.6.9`
- Upgraded `countries-and-timezones` from version `3.10.0` to `3.11.0` - Upgraded `countries-and-timezones` from version `3.10.0` to `3.11.0`

11
apps/api/src/app/endpoints/activities/activities.controller.ts

@ -18,6 +18,7 @@ import {
} from '@ghostfolio/common/config'; } from '@ghostfolio/common/config';
import { CreateOrderDto, UpdateOrderDto } from '@ghostfolio/common/dtos'; import { CreateOrderDto, UpdateOrderDto } from '@ghostfolio/common/dtos';
import { SubscriptionType } from '@ghostfolio/common/enums'; import { SubscriptionType } from '@ghostfolio/common/enums';
import { getAssetProfileIdentifier } from '@ghostfolio/common/helper';
import { import {
ActivitiesResponse, ActivitiesResponse,
ActivityResponse, ActivityResponse,
@ -229,17 +230,21 @@ export class ActivitiesController {
userSubscription userSubscription
}: ImpersonationContext }: ImpersonationContext
): Promise<CreateActivityResponse> { ): Promise<CreateActivityResponse> {
await this.validateActivity({ const assetProfiles = await this.validateActivity({
authenticatedUserSubscription, authenticatedUserSubscription,
userId, userId,
userSubscription, userSubscription,
activityDto: data activityDto: data
}); });
const currency = data.currency;
const customCurrency = data.customCurrency; const customCurrency = data.customCurrency;
const dataSource = data.dataSource; const dataSource = data.dataSource;
const currency =
assetProfiles[
getAssetProfileIdentifier({ dataSource, symbol: data.symbol })
]?.currency ?? data.currency;
if (customCurrency) { if (customCurrency) {
data.currency = customCurrency; data.currency = customCurrency;
@ -449,7 +454,7 @@ export class ActivitiesController {
: authenticatedUserSubscription; : authenticatedUserSubscription;
try { try {
await this.dataProviderService.validateActivities({ return await this.dataProviderService.validateActivities({
subscription, subscription,
userId, userId,
activitiesDto: [{ currency, dataSource, symbol, type }], activitiesDto: [{ currency, dataSource, symbol, type }],

14
apps/api/src/events/portfolio-changed.listener.ts

@ -3,10 +3,12 @@ import { PortfolioSnapshotService } from '@ghostfolio/api/services/queues/portfo
import { RedisCacheService } from '@ghostfolio/api/services/redis-cache/redis-cache.service'; import { RedisCacheService } from '@ghostfolio/api/services/redis-cache/redis-cache.service';
import { UserService } from '@ghostfolio/api/services/user/user.service'; import { UserService } from '@ghostfolio/api/services/user/user.service';
import { import {
DEFAULT_CURRENCY,
PORTFOLIO_SNAPSHOT_COMPUTATION_QUEUE_PRIORITY_LOW, PORTFOLIO_SNAPSHOT_COMPUTATION_QUEUE_PRIORITY_LOW,
PORTFOLIO_SNAPSHOT_PROCESS_JOB_NAME, PORTFOLIO_SNAPSHOT_PROCESS_JOB_NAME,
PORTFOLIO_SNAPSHOT_PROCESS_JOB_OPTIONS PORTFOLIO_SNAPSHOT_PROCESS_JOB_OPTIONS
} from '@ghostfolio/common/config'; } from '@ghostfolio/common/config';
import { PerformanceCalculationType } from '@ghostfolio/common/types/performance-calculation-type.type';
import { Injectable, Logger } from '@nestjs/common'; import { Injectable, Logger } from '@nestjs/common';
import { OnEvent } from '@nestjs/event-emitter'; import { OnEvent } from '@nestjs/event-emitter';
@ -67,21 +69,25 @@ export class PortfolioChangedListener {
userSettings userSettings
}); });
const calculationType =
userSettings.performanceCalculationType ??
PerformanceCalculationType.ROAI;
// Recompute in the background to avoid a cold start on the next request // Recompute in the background to avoid a cold start on the next request
await this.portfolioSnapshotService.addJobToQueue({ await this.portfolioSnapshotService.addJobToQueue({
data: { data: {
calculationType,
filters, filters,
userId, userId,
calculationType: userSettings.performanceCalculationType, userCurrency: userSettings.baseCurrency ?? DEFAULT_CURRENCY
userCurrency: userSettings.baseCurrency
}, },
name: PORTFOLIO_SNAPSHOT_PROCESS_JOB_NAME, name: PORTFOLIO_SNAPSHOT_PROCESS_JOB_NAME,
opts: { opts: {
...PORTFOLIO_SNAPSHOT_PROCESS_JOB_OPTIONS, ...PORTFOLIO_SNAPSHOT_PROCESS_JOB_OPTIONS,
jobId: this.redisCacheService.getPortfolioSnapshotKey({ jobId: this.redisCacheService.getPortfolioSnapshotKey({
calculationType,
filters, filters,
userId, userId
calculationType: userSettings.performanceCalculationType
}), }),
priority: PORTFOLIO_SNAPSHOT_COMPUTATION_QUEUE_PRIORITY_LOW priority: PORTFOLIO_SNAPSHOT_COMPUTATION_QUEUE_PRIORITY_LOW
} }

2
apps/api/src/guards/access.guard.ts

@ -32,7 +32,7 @@ export class AccessGuard implements CanActivate {
const impersonationOfBearerToken = const impersonationOfBearerToken =
getActiveImpersonationOfBearerToken(request); getActiveImpersonationOfBearerToken(request);
if (!impersonationOfBearerToken) { if (!request || !impersonationOfBearerToken) {
throw new HttpException( throw new HttpException(
getReasonPhrase(StatusCodes.FORBIDDEN), getReasonPhrase(StatusCodes.FORBIDDEN),
StatusCodes.FORBIDDEN StatusCodes.FORBIDDEN

10
apps/api/src/helper/bearer-token.helper.ts

@ -40,8 +40,9 @@ export function getActiveImpersonationOfBearerToken(
* hence the transport lists only the tools which the access covers. * hence the transport lists only the tools which the access covers.
*/ */
export function getMcpUserOfBearerToken(request: unknown) { export function getMcpUserOfBearerToken(request: unknown) {
const impersonationOfBearerToken = const impersonationOfBearerToken = getActiveImpersonationOfBearerToken(
getActiveImpersonationOfBearerToken(request); request as Pick<RequestWithUser, 'impersonationOfBearerToken'>
);
return impersonationOfBearerToken return impersonationOfBearerToken
? { scopes: impersonationOfBearerToken.scopes } ? { scopes: impersonationOfBearerToken.scopes }
@ -54,8 +55,9 @@ export function getMcpUserOfBearerToken(request: unknown) {
* they apply only to an access which reads the monetary values. * they apply only to an access which reads the monetary values.
*/ */
export function hasLimitsOfBasicSubscriptionOfBearerToken(request: unknown) { export function hasLimitsOfBasicSubscriptionOfBearerToken(request: unknown) {
const impersonationOfBearerToken = const impersonationOfBearerToken = getActiveImpersonationOfBearerToken(
getActiveImpersonationOfBearerToken(request); request as Pick<RequestWithUser, 'impersonationOfBearerToken'>
);
return ( return (
impersonationOfBearerToken?.userSubscription?.type === impersonationOfBearerToken?.userSubscription?.type ===

2
apps/api/src/helper/country.helper.ts

@ -9,7 +9,7 @@ export function getCountryCodeByName({
aliases?: Record<string, string>; aliases?: Record<string, string>;
dataSource?: string; dataSource?: string;
name: string; name: string;
}): string { }): string | undefined {
if (aliases[name]) { if (aliases[name]) {
return aliases[name]; return aliases[name];
} }

6
apps/api/src/helper/data-source.helper.spec.ts

@ -29,9 +29,9 @@ function createConfigurationService({
describe('DataSourceHelper', () => { describe('DataSourceHelper', () => {
describe('isValidEncodedDataSource', () => { describe('isValidEncodedDataSource', () => {
it('Accepts an encoded data source', () => { it('Accepts an encoded data source', () => {
expect(isValidEncodedDataSource(encodeDataSource(DataSource.YAHOO))).toBe( expect(
true isValidEncodedDataSource(encodeDataSource(DataSource.YAHOO) ?? '')
); ).toBe(true);
}); });
it('Refuses a data source which is not encoded', () => { it('Refuses a data source which is not encoded', () => {

4
apps/api/src/helper/data-source.helper.ts

@ -64,7 +64,7 @@ function hashDataSource(dataSource: DataSource) {
return createHash('sha256').update(dataSource).digest('hex').slice(0, 8); return createHash('sha256').update(dataSource).digest('hex').slice(0, 8);
} }
export function decodeDataSource(encodedDataSource: string) { export function decodeDataSource(encodedDataSource?: string) {
if (!encodedDataSource) { if (!encodedDataSource) {
return undefined; return undefined;
} }
@ -128,7 +128,7 @@ export function transformDataSourceInRequest({
configurationService: ConfigurationService; configurationService: ConfigurationService;
dataSource?: string; dataSource?: string;
}) { }) {
if (Object.hasOwn(DataSource, dataSource)) { if (dataSource && Object.hasOwn(DataSource, dataSource)) {
return getUnmaskedGhostfolioDataSource({ return getUnmaskedGhostfolioDataSource({
dataSource: dataSource as DataSource, dataSource: dataSource as DataSource,
ghostfolioDataSources: getGhostfolioDataSources({ configurationService }) ghostfolioDataSources: getGhostfolioDataSources({ configurationService })

2
apps/api/src/helper/markdown-table.helper.ts

@ -17,7 +17,7 @@ export function getTableInput<T, C = void>({
rows: rows.map((row) => { rows: rows.map((row) => {
return columnDefinitions.reduce( return columnDefinitions.reduce(
(tableRow, { getValue, name }) => { (tableRow, { getValue, name }) => {
tableRow[name] = getValue(row, context); tableRow[name] = getValue(row, context as C);
return tableRow; return tableRow;
}, },

4
apps/api/src/helper/portfolio.helper.ts

@ -21,7 +21,7 @@ export function convertValuesToPercentages({
const totalValue = holdings const totalValue = holdings
.map(({ valueInBaseCurrency }) => { .map(({ valueInBaseCurrency }) => {
return valueInBaseCurrency; return valueInBaseCurrency ?? 0;
}) })
.reduce((a, b) => { .reduce((a, b) => {
return a + b; return a + b;
@ -32,7 +32,7 @@ export function convertValuesToPercentages({
? holding.investment / totalInvestment ? holding.investment / totalInvestment
: 0; : 0;
holding.valueInPercentage = totalValue holding.valueInPercentage = totalValue
? holding.valueInBaseCurrency / totalValue ? (holding.valueInBaseCurrency ?? 0) / totalValue
: 0; : 0;
} }

2
apps/api/src/helper/string.helper.ts

@ -3,7 +3,7 @@ import { randomBytes } from 'node:crypto';
export function getRandomString(length: number) { export function getRandomString(length: number) {
const bytes = randomBytes(length); const bytes = randomBytes(length);
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
const result = []; const result: string[] = [];
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
const randomByte = bytes[i]; const randomByte = bytes[i];

4
apps/api/src/main.ts

@ -53,7 +53,7 @@ async function bootstrap() {
try { try {
customLogLevels = JSON.parse( customLogLevels = JSON.parse(
configService.get<string>('LOG_LEVELS') configService.get<string>('LOG_LEVELS') ?? ''
) as LogLevel[]; ) as LogLevel[];
} catch {} } catch {}
@ -191,7 +191,7 @@ async function bootstrap() {
let address = app.getHttpServer().address(); let address = app.getHttpServer().address();
if (typeof address === 'object') { if (address && typeof address === 'object') {
const addressObject = address; const addressObject = address;
let host = addressObject.address; let host = addressObject.address;

2
apps/api/src/middlewares/mcp-authorization.middleware.ts

@ -92,7 +92,7 @@ function sendUnauthorizedResponse({
accessId, accessId,
response response
}: { }: {
accessId: string; accessId?: string;
response: Response; response: Response;
}) { }) {
const parameters = [`realm="${MCP_REALM}"`]; const parameters = [`realm="${MCP_REALM}"`];

182
apps/api/src/services/activities/activities.service.spec.ts

@ -109,7 +109,8 @@ describe('ActivitiesService', () => {
}, },
userId: 'user-id' userId: 'user-id'
}) })
} },
symbolProfile: { findUnique: jest.fn().mockResolvedValue(null) }
} as unknown as PrismaService, } as unknown as PrismaService,
null, null,
{ validateTagIds: jest.fn() } as unknown as TagService { validateTagIds: jest.fn() } as unknown as TagService
@ -153,6 +154,130 @@ describe('ActivitiesService', () => {
); );
}); });
it('does not store the currency if it is the currency of the existing asset profile', async () => {
const data = await getCreatedActivityData({
assetProfile: { currency: 'USD' },
currency: 'USD'
});
expect(data).not.toHaveProperty('currency');
});
it('stores the currency if it is not the currency of the existing asset profile', async () => {
const data = await getCreatedActivityData({
assetProfile: { currency: 'USD' },
currency: 'EUR'
});
expect(data.currency).toBe('EUR');
});
it('does not store the currency if it is the currency of a new custom asset profile', async () => {
const data = await getCreatedActivityData({
currency: 'USD',
dataSource: DataSource.MANUAL
});
expect(data).not.toHaveProperty('currency');
});
it('does not store the currency if it is the currency of the existing custom asset profile (clone)', async () => {
const data = await getCreatedActivityData({
assetProfile: { currency: 'EUR', id: 'asset-profile-id' },
currency: 'EUR',
dataSource: DataSource.MANUAL,
symbol: 'GF_COPX'
});
expect(data).not.toHaveProperty('currency');
});
it('does not store the currency if it is the currency of a new asset profile of a data provider', async () => {
const data = await getCreatedActivityData({ currency: 'USD' });
expect(data).not.toHaveProperty('currency');
});
it('stores the currency if it is not the currency of a new asset profile of a data provider', async () => {
const data = await getCreatedActivityData({ currency: 'EUR' });
expect(data.currency).toBe('EUR');
});
it('compares the currency with the asset profile which the activity connects to', async () => {
const data = await getCreatedActivityData({
currency: 'USD',
findUnique: jest.fn(({ where }: Prisma.SymbolProfileFindUniqueArgs) => {
return where.dataSource_symbol.dataSource === DataSource.MANUAL
? null
: { currency: 'EUR' };
}),
type: ActivityType.FEE
});
expect(data).not.toHaveProperty('currency');
});
async function getCreatedActivityData({
assetProfile,
currency,
dataSource = DataSource.YAHOO,
findUnique = jest.fn().mockResolvedValue(assetProfile ?? null),
symbol = 'VT',
type = ActivityType.BUY
}: {
assetProfile?: { currency: string; id?: string };
currency: string;
dataSource?: DataSource;
findUnique?: jest.Mock;
symbol?: string;
type?: ActivityType;
}) {
const create = jest.fn(({ data }: Prisma.OrderCreateArgs) => {
return {
...data,
SymbolProfile: data.SymbolProfile.connectOrCreate.create
};
});
const service = new ActivitiesService(
null,
null,
null,
null,
{ addJobToQueue: jest.fn() } as unknown as DataGatheringService,
null,
{ emit: jest.fn() } as unknown as EventEmitter2,
null,
null,
{
order: { create },
symbolProfile: { findUnique }
} as unknown as PrismaService,
null,
{ validateTagIds: jest.fn() } as unknown as TagService
);
await service.createActivity({
currency,
type,
date: parseDate('2026-10-01'),
fee: 0,
quantity: 1,
SymbolProfile: {
connectOrCreate: {
create: { dataSource, symbol, currency: 'USD' },
where: { dataSource_symbol: { dataSource, symbol } }
}
},
unitPrice: 100,
user: { connect: { id: 'user-id' } },
userId: 'user-id'
});
return create.mock.calls[0][0].data;
}
async function getCreatedAssetProfile({ async function getCreatedAssetProfile({
existingAssetProfile, existingAssetProfile,
symbol symbol
@ -688,12 +813,48 @@ describe('ActivitiesService', () => {
expect(data).not.toHaveProperty('SymbolProfile'); expect(data).not.toHaveProperty('SymbolProfile');
}); });
it.each([
{ currency: 'USD', dataSource: DataSource.MANUAL, symbol: 'GF_GOLD' },
{ currency: 'EUR', dataSource: DataSource.YAHOO, symbol: 'AAPL' }
])(
'removes the currency if it is the currency of the asset profile ($dataSource)',
async ({ currency, dataSource, symbol }) => {
const data = await getUpdatedActivityData({
currency,
dataSource,
symbol,
userId: 'user-id'
});
expect(data.currency).toBeNull();
}
);
it.each([
{ currency: 'EUR', dataSource: DataSource.MANUAL, symbol: 'GF_GOLD' },
{ currency: 'USD', dataSource: DataSource.YAHOO, symbol: 'AAPL' }
])(
'keeps the currency if it is not the currency of the asset profile ($dataSource)',
async ({ currency, dataSource, symbol }) => {
const data = await getUpdatedActivityData({
currency,
dataSource,
symbol,
userId: 'user-id'
});
expect(data.currency).toBe(currency);
}
);
async function getUpdatedActivityData({ async function getUpdatedActivityData({
currency,
dataSource = DataSource.MANUAL, dataSource = DataSource.MANUAL,
symbol = 'GF_GOLD', symbol = 'GF_GOLD',
type = ActivityType.BUY, type = ActivityType.BUY,
userId userId
}: { }: {
currency?: string;
dataSource?: DataSource; dataSource?: DataSource;
symbol?: string; symbol?: string;
type?: ActivityType; type?: ActivityType;
@ -706,7 +867,7 @@ describe('ActivitiesService', () => {
null, null,
null, null,
null, null,
null, { gatherSymbols: jest.fn() } as unknown as DataGatheringService,
null, null,
{ emit: jest.fn() } as unknown as EventEmitter2, { emit: jest.fn() } as unknown as EventEmitter2,
null, null,
@ -714,9 +875,19 @@ describe('ActivitiesService', () => {
{ {
order: { order: {
update, update,
findUnique: jest findUnique: jest.fn().mockResolvedValue({
.fn() SymbolProfile: { userId, currency: 'USD' }
.mockResolvedValue({ SymbolProfile: { userId } }) })
},
symbolProfile: {
findUnique: jest.fn(
({ where }: Prisma.SymbolProfileFindUniqueArgs) => {
return where.dataSource_symbol.dataSource ===
DataSource.YAHOO && where.dataSource_symbol.symbol === 'AAPL'
? { currency: 'EUR' }
: null;
}
)
} }
} as unknown as PrismaService, } as unknown as PrismaService,
null, null,
@ -725,6 +896,7 @@ describe('ActivitiesService', () => {
await service.updateActivity({ await service.updateActivity({
data: { data: {
currency,
type, type,
assetClass: AssetClass.COMMODITY, assetClass: AssetClass.COMMODITY,
assetSubClass: AssetSubClass.PRECIOUS_METAL, assetSubClass: AssetSubClass.PRECIOUS_METAL,

33
apps/api/src/services/activities/activities.service.ts

@ -174,7 +174,6 @@ export class ActivitiesService {
accountId?: string; accountId?: string;
assetClass?: AssetClass; assetClass?: AssetClass;
assetSubClass?: AssetSubClass; assetSubClass?: AssetSubClass;
currency?: string;
symbol?: string; symbol?: string;
tags?: { id: string }[]; tags?: { id: string }[];
updateAccountBalance?: boolean; updateAccountBalance?: boolean;
@ -286,6 +285,19 @@ export class ActivitiesService {
delete data.comment; delete data.comment;
} }
const assetProfile = await this.prismaService.symbolProfile.findUnique({
select: { currency: true },
where: data.SymbolProfile.connectOrCreate.where
});
const assetProfileCurrency =
assetProfile?.currency ??
data.SymbolProfile.connectOrCreate.create.currency;
if (data.currency === assetProfileCurrency) {
delete data.currency;
}
delete data.symbol; delete data.symbol;
delete data.tags; delete data.tags;
delete data.updateAccountBalance; delete data.updateAccountBalance;
@ -907,7 +919,6 @@ export class ActivitiesService {
data: Prisma.OrderUpdateInput & { data: Prisma.OrderUpdateInput & {
assetClass?: AssetClass; assetClass?: AssetClass;
assetSubClass?: AssetSubClass; assetSubClass?: AssetSubClass;
currency?: string;
symbol?: string; symbol?: string;
tags?: { id: string }[]; tags?: { id: string }[];
type?: ActivityType; type?: ActivityType;
@ -930,6 +941,8 @@ export class ActivitiesService {
data.comment = null; data.comment = null;
} }
let assetProfileCurrency: string;
if ( if (
NON_INVESTMENT_ACTIVITY_TYPES.includes(data.type) || NON_INVESTMENT_ACTIVITY_TYPES.includes(data.type) ||
(data.SymbolProfile.connect.dataSource_symbol.dataSource === 'MANUAL' && (data.SymbolProfile.connect.dataSource_symbol.dataSource === 'MANUAL' &&
@ -938,10 +951,12 @@ export class ActivitiesService {
delete data.SymbolProfile.connect; delete data.SymbolProfile.connect;
const activityToUpdate = await this.prismaService.order.findUnique({ const activityToUpdate = await this.prismaService.order.findUnique({
select: { SymbolProfile: { select: { userId: true } } }, select: { SymbolProfile: { select: { currency: true, userId: true } } },
where where
}); });
assetProfileCurrency = activityToUpdate?.SymbolProfile.currency;
if (activityToUpdate?.SymbolProfile.userId === userId) { if (activityToUpdate?.SymbolProfile.userId === userId) {
data.SymbolProfile.update = { data.SymbolProfile.update = {
data: { data: {
@ -956,6 +971,13 @@ export class ActivitiesService {
} else { } else {
delete data.SymbolProfile.update; delete data.SymbolProfile.update;
const assetProfile = await this.prismaService.symbolProfile.findUnique({
select: { currency: true },
where: data.SymbolProfile.connect
});
assetProfileCurrency = assetProfile?.currency;
if (!isActivityInFuture({ date: data.date as Date })) { if (!isActivityInFuture({ date: data.date as Date })) {
// Gather symbol data of order in the background, if the date is not in // Gather symbol data of order in the background, if the date is not in
// the future // the future
@ -975,6 +997,11 @@ export class ActivitiesService {
delete data.assetClass; delete data.assetClass;
delete data.assetSubClass; delete data.assetSubClass;
if (data.currency === assetProfileCurrency) {
data.currency = null;
}
delete data.symbol; delete data.symbol;
delete data.tags; delete data.tags;

4
package-lock.json

@ -1,12 +1,12 @@
{ {
"name": "ghostfolio", "name": "ghostfolio",
"version": "3.94.0", "version": "3.95.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "ghostfolio", "name": "ghostfolio",
"version": "3.94.0", "version": "3.95.0",
"hasInstallScript": true, "hasInstallScript": true,
"license": "AGPL-3.0", "license": "AGPL-3.0",
"dependencies": { "dependencies": {

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "ghostfolio", "name": "ghostfolio",
"version": "3.94.0", "version": "3.95.0",
"homepage": "https://ghostfol.io", "homepage": "https://ghostfol.io",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"repository": "https://github.com/ghostfolio/ghostfolio", "repository": "https://github.com/ghostfolio/ghostfolio",

5
prisma/migrations/20261029000000_removed_redundant_currency_from_order/migration.sql

@ -0,0 +1,5 @@
-- Remove redundant currency from the 'Order' table
UPDATE "Order"
SET "currency" = NULL
FROM "SymbolProfile"
WHERE "Order"."symbolProfileId" = "SymbolProfile"."id" AND "Order"."currency" = "SymbolProfile"."currency";
Loading…
Cancel
Save