Browse Source

feat: holdings api now supports pastInvestments true/false

pull/3146/head
gerardPolloRebozado 1 year ago
parent
commit
62573e5410
  1. 2
      apps/api/src/app/portfolio/portfolio.controller.ts
  2. 8
      apps/api/src/app/portfolio/portfolio.service.ts

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

@ -285,6 +285,7 @@ export class PortfolioController {
@Query('accounts') filterByAccounts?: string,
@Query('assetClasses') filterByAssetClasses?: string,
@Query('query') filterBySearchQuery?: string,
@Query('pastInvestments') pastInvestments: boolean = false,
@Query('tags') filterByTags?: string
): Promise<PortfolioHoldingsResponse> {
const filters = this.apiService.buildFiltersFromQueryParams({
@ -297,6 +298,7 @@ export class PortfolioController {
const { holdings } = await this.portfolioService.getDetails({
filters,
impersonationId,
pastInvestments,
userId: this.request.user.id
});

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

@ -336,6 +336,7 @@ export class PortfolioService {
dateRange = 'max',
filters,
impersonationId,
pastInvestments,
userId,
withExcludedAccounts = false,
withLiabilities = false,
@ -344,6 +345,7 @@ export class PortfolioService {
dateRange?: DateRange;
filters?: Filter[];
impersonationId: string;
pastInvestments?: boolean;
userId: string;
withExcludedAccounts?: boolean;
withLiabilities?: boolean;
@ -463,8 +465,10 @@ export class PortfolioService {
transactionCount,
valueInBaseCurrency
} of currentPositions.positions) {
if (quantity.eq(0)) {
// Ignore positions without any quantity
if (quantity.eq(0) && pastInvestments === false) {
// Ignore positions without any quantity if past investments are not requested
continue;
} else if (!quantity.eq(0) && pastInvestments === true) {
continue;
}

Loading…
Cancel
Save