From eada5d6b3e7fda45593a09abf36ba57c3e69e664 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sun, 4 Jan 2026 09:37:06 +0100 Subject: [PATCH] Refactoring --- apps/api/src/app/order/order.service.ts | 33 ++++++++++++++----------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/apps/api/src/app/order/order.service.ts b/apps/api/src/app/order/order.service.ts index 36f0a580e..a939cb476 100644 --- a/apps/api/src/app/order/order.service.ts +++ b/apps/api/src/app/order/order.service.ts @@ -329,7 +329,7 @@ export class OrderService { * performance tracking based on exchange rate fluctuations. * * @param cashDetails - The cash balance details. - * @param filters - Optional filters to apply to the orders. + * @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. @@ -345,7 +345,24 @@ export class OrderService { userCurrency: string; userId: string; }): Promise { - let activities: Activity[] = []; + 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) { const { balances } = await this.accountBalanceService.getAccountBalances({ @@ -425,18 +442,6 @@ export class OrderService { } } - activities = activities.filter(({ SymbolProfile }) => { - for (const { id, type } of filters) { - if (type === 'ASSET_CLASS') { - if (id !== SymbolProfile.assetClass) { - return false; - } - } - } - - return true; - }); - return { activities, count: activities.length