Browse Source

Bugfix/fix liability issue in allocations (#3133)

* Remove liabilities from allocations calculation

* Update changelog
pull/3130/head^2
Thomas Kaul 11 months ago
committed by GitHub
parent
commit
7a364472c8
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 7
      apps/api/src/app/portfolio/portfolio.controller.ts
  3. 4
      apps/api/src/app/portfolio/portfolio.service.ts
  4. 2
      apps/client/src/app/components/home-summary/home-summary.component.ts
  5. 12
      apps/client/src/app/services/data.service.ts

1
CHANGELOG.md

@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- Fixed an issue in the performance calculation caused by multiple `SELL` activities on the same day - Fixed an issue in the performance calculation caused by multiple `SELL` activities on the same day
- Fixed an issue in the calculation on the allocations page caused by liabilities
## 2.62.0 - 2024-03-09 ## 2.62.0 - 2024-03-09

7
apps/api/src/app/portfolio/portfolio.controller.ts

@ -76,8 +76,11 @@ export class PortfolioController {
@Query('accounts') filterByAccounts?: string, @Query('accounts') filterByAccounts?: string,
@Query('assetClasses') filterByAssetClasses?: string, @Query('assetClasses') filterByAssetClasses?: string,
@Query('range') dateRange: DateRange = 'max', @Query('range') dateRange: DateRange = 'max',
@Query('tags') filterByTags?: string @Query('tags') filterByTags?: string,
@Query('withLiabilities') withLiabilitiesParam = 'false'
): Promise<PortfolioDetails & { hasError: boolean }> { ): Promise<PortfolioDetails & { hasError: boolean }> {
const withLiabilities = withLiabilitiesParam === 'true';
let hasDetails = true; let hasDetails = true;
let hasError = false; let hasError = false;
const hasReadRestrictedAccessPermission = const hasReadRestrictedAccessPermission =
@ -101,8 +104,8 @@ export class PortfolioController {
dateRange, dateRange,
filters, filters,
impersonationId, impersonationId,
withLiabilities,
userId: this.request.user.id, userId: this.request.user.id,
withLiabilities: true,
withSummary: true withSummary: true
}); });

4
apps/api/src/app/portfolio/portfolio.service.ts

@ -146,8 +146,7 @@ export class PortfolioService {
filters, filters,
withExcludedAccounts, withExcludedAccounts,
impersonationId: userId, impersonationId: userId,
userId: this.request.user.id, userId: this.request.user.id
withLiabilities: true
}) })
]); ]);
@ -393,6 +392,7 @@ export class PortfolioService {
}); });
const holdings: PortfolioDetails['holdings'] = {}; const holdings: PortfolioDetails['holdings'] = {};
const totalValueInBaseCurrency = const totalValueInBaseCurrency =
currentPositions.currentValueInBaseCurrency.plus( currentPositions.currentValueInBaseCurrency.plus(
cashDetails.balanceInBaseCurrency cashDetails.balanceInBaseCurrency

2
apps/client/src/app/components/home-summary/home-summary.component.ts

@ -102,7 +102,7 @@ export class HomeSummaryComponent implements OnDestroy, OnInit {
this.isLoading = true; this.isLoading = true;
this.dataService this.dataService
.fetchPortfolioDetails() .fetchPortfolioDetails({ withLiabilities: true })
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))
.subscribe(({ summary }) => { .subscribe(({ summary }) => {
this.summary = summary; this.summary = summary;

12
apps/client/src/app/services/data.service.ts

@ -390,13 +390,21 @@ export class DataService {
} }
public fetchPortfolioDetails({ public fetchPortfolioDetails({
filters filters,
withLiabilities = false
}: { }: {
filters?: Filter[]; filters?: Filter[];
withLiabilities?: boolean;
} = {}): Observable<PortfolioDetails> { } = {}): Observable<PortfolioDetails> {
let params = this.buildFiltersAsQueryParams({ filters });
if (withLiabilities) {
params = params.append('withLiabilities', withLiabilities);
}
return this.http return this.http
.get<any>('/api/v1/portfolio/details', { .get<any>('/api/v1/portfolio/details', {
params: this.buildFiltersAsQueryParams({ filters }) params
}) })
.pipe( .pipe(
map((response) => { map((response) => {

Loading…
Cancel
Save