Skip to content

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

Bugfix/fix search for holding in assistant (#3569)

Thomas Kaul6c1317f97817
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d4650e9275..193fe9d122 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Fixed an issue in the portfolio summary with the currency conversion of fees
+- Fixed an issue in the the search for a holding
- Removed the show condition of the experimental features setting in the user settings
## 2.95.0 - 2024-07-12
diff --git a/apps/api/src/app/account/account.service.ts b/apps/api/src/app/account/account.service.ts
index 1564fa5b3d..37876dde06 100644
--- a/apps/api/src/app/account/account.service.ts
+++ b/apps/api/src/app/account/account.service.ts
@@ -174,8 +174,8 @@ export class AccountService {
ACCOUNT: filtersByAccount,
ASSET_CLASS: filtersByAssetClass,
TAG: filtersByTag
- } = groupBy(filters, (filter) => {
- return filter.type;
+ } = groupBy(filters, ({ type }) => {
+ return type;
});
if (filtersByAccount?.length > 0) {
diff --git a/apps/api/src/app/order/order.service.ts b/apps/api/src/app/order/order.service.ts
index 0255a50114..b743eb2b73 100644
--- a/apps/api/src/app/order/order.service.ts
+++ b/apps/api/src/app/order/order.service.ts
@@ -312,10 +312,14 @@ export class OrderService {
ACCOUNT: filtersByAccount,
ASSET_CLASS: filtersByAssetClass,
TAG: filtersByTag
- } = groupBy(filters, (filter) => {
- return filter.type;
+ } = groupBy(filters, ({ type }) => {
+ return type;
});
+ const searchQuery = filters?.find(({ type }) => {
+ return type === 'SEARCH_QUERY';
+ })?.id;
+
if (filtersByAccount?.length > 0) {
where.accountId = {
in: filtersByAccount.map(({ id }) => {
@@ -357,6 +361,30 @@ export class OrderService {
};
}
+ if (searchQuery) {
+ const searchQueryWhereInput: Prisma.SymbolProfileWhereInput[] = [
+ { id: { mode: 'insensitive', startsWith: searchQuery } },
+ { isin: { mode: 'insensitive', startsWith: searchQuery } },
+ { name: { mode: 'insensitive', startsWith: searchQuery } },
+ { symbol: { mode: 'insensitive', startsWith: searchQuery } }
+ ];
+
+ if (where.SymbolProfile) {
+ where.SymbolProfile = {
+ AND: [
+ where.SymbolProfile,
+ {
+ OR: searchQueryWhereInput
+ }
+ ]
+ };
+ } else {
+ where.SymbolProfile = {
+ OR: searchQueryWhereInput
+ };
+ }
+ }
+
if (filtersByTag?.length > 0) {
where.tags = {
some: {