diff --git a/.config/prisma.ts b/.config/prisma.ts new file mode 100644 index 000000000..64691136c --- /dev/null +++ b/.config/prisma.ts @@ -0,0 +1,14 @@ +import { defineConfig } from '@prisma/config'; +import { config } from 'dotenv'; +import { expand } from 'dotenv-expand'; +import { join } from 'node:path'; + +expand(config({ quiet: true })); + +export default defineConfig({ + migrations: { + path: join(__dirname, '..', 'prisma', 'migrations'), + seed: `node ${join(__dirname, '..', 'prisma', 'seed.mts')}` + }, + schema: join(__dirname, '..', 'prisma', 'schema.prisma') +}); diff --git a/CHANGELOG.md b/CHANGELOG.md index b59cb9207..ed96828e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased + - Refactor Activities interface to ActivitiesResponse interface +### Added + +- Extended the export functionality by the user account’s performance calculation typ + ### Changed +- Localized the number formatting in the static portfolio analysis rule: _Liquidity_ (Buying Power) +- Moved the _Prisma Configuration File_ from `prisma.config.ts` to `.config/prisma.ts` - Upgraded `prisma` from version `6.17.1` to `6.18.0` ## 2.210.1 - 2025-10-22 diff --git a/Dockerfile b/Dockerfile index be1bb53ea..5beaf6e03 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,11 +13,11 @@ RUN apt-get update && apt-get install -y --no-install-suggests \ # Only add basic files without the application itself to avoid rebuilding # layers when files (package.json etc.) have not changed +COPY ./.config .config/ COPY ./CHANGELOG.md CHANGELOG.md COPY ./LICENSE LICENSE COPY ./package.json package.json COPY ./package-lock.json package-lock.json -COPY ./prisma.config.ts prisma.config.ts COPY ./prisma/schema.prisma prisma/ RUN npm install @@ -44,7 +44,7 @@ WORKDIR /ghostfolio/dist/apps/api COPY ./package-lock.json /ghostfolio/dist/apps/api/ RUN npm install -COPY prisma.config.ts /ghostfolio/dist/apps/api/ +COPY .config /ghostfolio/dist/apps/api/.config/ COPY prisma /ghostfolio/dist/apps/api/prisma/ # Overwrite the generated package.json with the original one to ensure having diff --git a/apps/api/src/app/export/export.controller.ts b/apps/api/src/app/export/export.controller.ts index 0b4a2c6e0..5446f8789 100644 --- a/apps/api/src/app/export/export.controller.ts +++ b/apps/api/src/app/export/export.controller.ts @@ -48,8 +48,8 @@ export class ExportController { return this.exportService.export({ activityIds, filters, - userCurrency: this.request.user.settings.settings.baseCurrency, - userId: this.request.user.id + userId: this.request.user.id, + userSettings: this.request.user.settings.settings }); } } diff --git a/apps/api/src/app/export/export.service.ts b/apps/api/src/app/export/export.service.ts index 2001fd3e2..d07b199be 100644 --- a/apps/api/src/app/export/export.service.ts +++ b/apps/api/src/app/export/export.service.ts @@ -3,7 +3,11 @@ import { OrderService } from '@ghostfolio/api/app/order/order.service'; import { environment } from '@ghostfolio/api/environments/environment'; import { MarketDataService } from '@ghostfolio/api/services/market-data/market-data.service'; import { TagService } from '@ghostfolio/api/services/tag/tag.service'; -import { ExportResponse, Filter } from '@ghostfolio/common/interfaces'; +import { + ExportResponse, + Filter, + UserSettings +} from '@ghostfolio/common/interfaces'; import { Injectable } from '@nestjs/common'; import { Platform, Prisma } from '@prisma/client'; @@ -21,13 +25,13 @@ export class ExportService { public async export({ activityIds, filters, - userCurrency, - userId + userId, + userSettings }: { activityIds?: string[]; filters?: Filter[]; - userCurrency: string; userId: string; + userSettings: UserSettings; }): Promise { const { ACCOUNT: filtersByAccount } = groupBy(filters, ({ type }) => { return type; @@ -36,11 +40,11 @@ export class ExportService { let { activities } = await this.orderService.getOrders({ filters, - userCurrency, userId, includeDrafts: true, sortColumn: 'date', sortDirection: 'asc', + userCurrency: userSettings?.baseCurrency, withExcludedAccountsAndActivities: true }); @@ -244,7 +248,10 @@ export class ExportService { } ), user: { - settings: { currency: userCurrency } + settings: { + currency: userSettings?.baseCurrency, + performanceCalculationType: userSettings?.performanceCalculationType + } } }; } diff --git a/apps/api/src/dependencies.ts b/apps/api/src/dependencies.ts index cd5409fd4..acb7af382 100644 --- a/apps/api/src/dependencies.ts +++ b/apps/api/src/dependencies.ts @@ -1,3 +1,3 @@ -// Dependencies required by prisma.config.ts in Docker container +// Dependencies required by .config/prisma.ts in Docker container import 'dotenv'; import 'dotenv-expand'; diff --git a/apps/api/src/models/rules/liquidity/buying-power.ts b/apps/api/src/models/rules/liquidity/buying-power.ts index 70393278d..2cd4d6fee 100644 --- a/apps/api/src/models/rules/liquidity/buying-power.ts +++ b/apps/api/src/models/rules/liquidity/buying-power.ts @@ -40,7 +40,9 @@ export class BuyingPower extends Rule { languageCode: this.getLanguageCode(), placeholders: { baseCurrency: ruleSettings.baseCurrency, - thresholdMin: ruleSettings.thresholdMin + thresholdMin: ruleSettings.thresholdMin.toLocaleString( + ruleSettings.locale + ) } }), value: false @@ -53,7 +55,9 @@ export class BuyingPower extends Rule { languageCode: this.getLanguageCode(), placeholders: { baseCurrency: ruleSettings.baseCurrency, - thresholdMin: ruleSettings.thresholdMin + thresholdMin: ruleSettings.thresholdMin.toLocaleString( + ruleSettings.locale + ) } }), value: true diff --git a/libs/common/src/lib/interfaces/responses/export-response.interface.ts b/libs/common/src/lib/interfaces/responses/export-response.interface.ts index a5416e886..8b1697ca4 100644 --- a/libs/common/src/lib/interfaces/responses/export-response.interface.ts +++ b/libs/common/src/lib/interfaces/responses/export-response.interface.ts @@ -9,6 +9,7 @@ import { import { AccountBalance } from '../account-balance.interface'; import { MarketData } from '../market-data.interface'; +import { UserSettings } from '../user-settings.interface'; export interface ExportResponse { accounts: (Omit & { @@ -36,5 +37,10 @@ export interface ExportResponse { }; platforms: Platform[]; tags: Omit[]; - user: { settings: { currency: string } }; + user: { + settings: { + currency: UserSettings['baseCurrency']; + performanceCalculationType: UserSettings['performanceCalculationType']; + }; + }; } diff --git a/prisma.config.ts b/prisma.config.ts deleted file mode 100644 index 60597cbf1..000000000 --- a/prisma.config.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { config } from 'dotenv'; -import { expand } from 'dotenv-expand'; -import { join } from 'node:path'; -import { defineConfig } from 'prisma/config'; - -expand(config({ quiet: true })); - -export default defineConfig({ - migrations: { - path: join('prisma', 'migrations'), - seed: `node ${join('prisma', 'seed.mts')}` - }, - schema: join('prisma', 'schema.prisma') -});