Skip to content

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

Bugfix/fix activities import with account balances (#4446)

Thomas Kaul4db8c007f003
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 080a65cf1c..841ad6ac9d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Improved the symbol validation in the _Yahoo Finance_ service (get asset profiles)
- Refreshed the cryptocurrencies list
+### Fixed
+
+- Fixed an issue in the activities import functionality related to the account balances
+
## 2.146.0 - 2025-03-15
### Changed
diff --git a/apps/api/src/app/import/create-account-with-balances.dto.ts b/apps/api/src/app/import/create-account-with-balances.dto.ts
new file mode 100644
index 0000000000..fd4b8df488
--- /dev/null
+++ b/apps/api/src/app/import/create-account-with-balances.dto.ts
@@ -0,0 +1,10 @@
+import { CreateAccountDto } from '@ghostfolio/api/app/account/create-account.dto';
+import { AccountBalance } from '@ghostfolio/common/interfaces';
+
+import { IsArray, IsOptional } from 'class-validator';
+
+export class CreateAccountWithBalancesDto extends CreateAccountDto {
+ @IsArray()
+ @IsOptional()
+ balances?: AccountBalance;
+}
diff --git a/apps/api/src/app/import/import-data.dto.ts b/apps/api/src/app/import/import-data.dto.ts
index 715766821e..207c8152b3 100644
--- a/apps/api/src/app/import/import-data.dto.ts
+++ b/apps/api/src/app/import/import-data.dto.ts
@@ -1,15 +1,16 @@
-import { CreateAccountDto } from '@ghostfolio/api/app/account/create-account.dto';
import { CreateOrderDto } from '@ghostfolio/api/app/order/create-order.dto';
import { Type } from 'class-transformer';
import { IsArray, IsOptional, ValidateNested } from 'class-validator';
+import { CreateAccountWithBalancesDto } from './create-account-with-balances.dto';
+
export class ImportDataDto {
@IsOptional()
@IsArray()
- @Type(() => CreateAccountDto)
+ @Type(() => CreateAccountWithBalancesDto)
@ValidateNested({ each: true })
- accounts: CreateAccountDto[];
+ accounts: CreateAccountWithBalancesDto[];
@IsArray()
@Type(() => CreateOrderDto)
diff --git a/libs/common/src/lib/interfaces/account-balance.interface.ts b/libs/common/src/lib/interfaces/account-balance.interface.ts
new file mode 100644
index 0000000000..00fcf1e536
--- /dev/null
+++ b/libs/common/src/lib/interfaces/account-balance.interface.ts
@@ -0,0 +1,4 @@
+export interface AccountBalance {
+ date: string;
+ value: number;
+}
diff --git a/libs/common/src/lib/interfaces/export.interface.ts b/libs/common/src/lib/interfaces/export.interface.ts
index 0772159e6a..24e4787791 100644
--- a/libs/common/src/lib/interfaces/export.interface.ts
+++ b/libs/common/src/lib/interfaces/export.interface.ts
@@ -1,8 +1,10 @@
import { Account, Order, Platform, Tag } from '@prisma/client';
+import { AccountBalance } from './account-balance.interface';
+
export interface Export {
accounts: (Omit<Account, 'createdAt' | 'updatedAt' | 'userId'> & {
- balances: { date: string; value: number }[];
+ balances: AccountBalance[];
})[];
activities: (Omit<
Order,
diff --git a/libs/common/src/lib/interfaces/index.ts b/libs/common/src/lib/interfaces/index.ts
index 3dcbbb32a9..5f8b8b5b14 100644
--- a/libs/common/src/lib/interfaces/index.ts
+++ b/libs/common/src/lib/interfaces/index.ts
@@ -1,4 +1,5 @@
import type { Access } from './access.interface';
+import type { AccountBalance } from './account-balance.interface';
import type { Accounts } from './accounts.interface';
import type { AdminData } from './admin-data.interface';
import type { AdminJobs } from './admin-jobs.interface';
@@ -68,6 +69,7 @@ import type { XRayRulesSettings } from './x-ray-rules-settings.interface';
export {
Access,
+ AccountBalance,
AccountBalancesResponse,
Accounts,
AdminData,