Skip to content

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

Bugfix/fix chart for account excluded from analysis (#2534)

Thomas Kaulfa627f686fda
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d35e30c600..6d8584c53d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Upgraded `uuid` from version `9.0.0` to `9.0.1`
- Upgraded `yahoo-finance2` from version `2.8.0` to `2.8.1`
+### Fixed
+
+- Fixed the chart in the account detail dialog for accounts excluded from analysis
+
## 2.14.0 - 2023-10-21
### Added
diff --git a/apps/api/src/app/portfolio/portfolio.controller.ts b/apps/api/src/app/portfolio/portfolio.controller.ts
index 6e42b1304d..1c022ba174 100644
--- a/apps/api/src/app/portfolio/portfolio.controller.ts
+++ b/apps/api/src/app/portfolio/portfolio.controller.ts
@@ -323,7 +323,8 @@ export class PortfolioController {
@Query('accounts') filterByAccounts?: string,
@Query('assetClasses') filterByAssetClasses?: string,
@Query('range') dateRange: DateRange = 'max',
- @Query('tags') filterByTags?: string
+ @Query('tags') filterByTags?: string,
+ @Query('withExcludedAccounts') withExcludedAccounts = false
): Promise<PortfolioPerformanceResponse> {
const filters = this.apiService.buildFiltersFromQueryParams({
filterByAccounts,
@@ -335,6 +336,7 @@ export class PortfolioController {
dateRange,
filters,
impersonationId,
+ withExcludedAccounts,
userId: this.request.user.id
});
diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts
index fcd2cb13c6..b2538fb6a5 100644
--- a/apps/api/src/app/portfolio/portfolio.service.ts
+++ b/apps/api/src/app/portfolio/portfolio.service.ts
@@ -372,20 +372,23 @@ export class PortfolioService {
filters,
impersonationId,
userCurrency,
- userId
+ userId,
+ withExcludedAccounts = false
}: {
dateRange?: DateRange;
filters?: Filter[];
impersonationId: string;
userCurrency: string;
userId: string;
+ withExcludedAccounts?: boolean;
}): Promise<HistoricalDataContainer> {
userId = await this.getUserId(impersonationId, userId);
const { portfolioOrders, transactionPoints } =
await this.getTransactionPoints({
filters,
- userId
+ userId,
+ withExcludedAccounts
});
const portfolioCalculator = new PortfolioCalculator({
@@ -1110,12 +1113,14 @@ export class PortfolioService {
dateRange = 'max',
filters,
impersonationId,
- userId
+ userId,
+ withExcludedAccounts = false
}: {
dateRange?: DateRange;
filters?: Filter[];
impersonationId: string;
userId: string;
+ withExcludedAccounts?: boolean;
}): Promise<PortfolioPerformanceResponse> {
userId = await this.getUserId(impersonationId, userId);
const user = await this.userService.user({ id: userId });
@@ -1124,7 +1129,8 @@ export class PortfolioService {
const { portfolioOrders, transactionPoints } =
await this.getTransactionPoints({
filters,
- userId
+ userId,
+ withExcludedAccounts
});
const portfolioCalculator = new PortfolioCalculator({
@@ -1174,7 +1180,8 @@ export class PortfolioService {
filters,
impersonationId,
userCurrency,
- userId
+ userId,
+ withExcludedAccounts
});
const itemOfToday = historicalDataContainer.items.find((item) => {
@@ -1763,7 +1770,7 @@ export class PortfolioService {
filters,
includeDrafts = false,
userId,
- withExcludedAccounts
+ withExcludedAccounts = false
}: {
filters?: Filter[];
includeDrafts?: boolean;
@@ -1851,7 +1858,7 @@ export class PortfolioService {
portfolioItemsNow,
userCurrency,
userId,
- withExcludedAccounts
+ withExcludedAccounts = false
}: {
filters?: Filter[];
orders: OrderWithAccount[];
diff --git a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts
index 756df74cfc..d232cb3df0 100644
--- a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts
+++ b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts
@@ -116,7 +116,8 @@ export class AccountDetailDialog implements OnDestroy, OnInit {
type: 'ACCOUNT'
}
],
- range: 'max'
+ range: 'max',
+ withExcludedAccounts: true
})
.pipe(takeUntil(this.unsubscribeSubject))
.subscribe(({ chart }) => {
diff --git a/apps/client/src/app/services/data.service.ts b/apps/client/src/app/services/data.service.ts
index f5cafb57a7..a83c423feb 100644
--- a/apps/client/src/app/services/data.service.ts
+++ b/apps/client/src/app/services/data.service.ts
@@ -386,14 +386,20 @@ export class DataService {
public fetchPortfolioPerformance({
filters,
- range
+ range,
+ withExcludedAccounts = false
}: {
filters?: Filter[];
range: DateRange;
+ withExcludedAccounts?: boolean;
}): Observable<PortfolioPerformanceResponse> {
let params = this.buildFiltersAsQueryParams({ filters });
params = params.append('range', range);
+ if (withExcludedAccounts) {
+ params = params.append('withExcludedAccounts', withExcludedAccounts);
+ }
+
return this.http
.get<any>(`/api/v2/portfolio/performance`, {
params