Skip to content

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

Bugfix/fix filtering by asset class in get holdings endpoint (#6151)

Thomas Kaulfeb25c9266a0
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cf81cb29e9..4e66bb4ecc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Moved the data service to `@ghostfolio/ui/services`
- Refactored the dividend import
+### Fixed
+
+- Fixed the filtering by asset class in the endpoint `GET api/v1/portfolio/holdings`
+
## 2.228.0 - 2026-01-03
### Added
diff --git a/apps/api/src/app/order/order.service.ts b/apps/api/src/app/order/order.service.ts
index 57fe5d3b69..a939cb4761 100644
--- a/apps/api/src/app/order/order.service.ts
+++ b/apps/api/src/app/order/order.service.ts
@@ -329,19 +329,39 @@ export class OrderService {
* performance tracking based on exchange rate fluctuations.
*
* @param cashDetails - The cash balance details.
+ * @param filters - Optional filters to apply.
* @param userCurrency - The base currency of the user.
* @param userId - The ID of the user.
* @returns A response containing the list of synthetic cash activities.
*/
public async getCashOrders({
cashDetails,
+ filters = [],
userCurrency,
userId
}: {
cashDetails: CashDetails;
+ filters?: Filter[];
userCurrency: string;
userId: string;
}): Promise<ActivitiesResponse> {
+ const filtersByAssetClass = filters.filter(({ type }) => {
+ return type === 'ASSET_CLASS';
+ });
+
+ if (
+ filtersByAssetClass.length > 0 &&
+ !filtersByAssetClass.find(({ id }) => {
+ return id === AssetClass.LIQUIDITY;
+ })
+ ) {
+ // If asset class filters are present and none of them is liquidity, return an empty response
+ return {
+ activities: [],
+ count: 0
+ };
+ }
+
const activities: Activity[] = [];
for (const account of cashDetails.accounts) {
@@ -755,6 +775,7 @@ export class OrderService {
const cashOrders = await this.getCashOrders({
cashDetails,
+ filters,
userCurrency,
userId
});