diff --git a/CHANGELOG.md b/CHANGELOG.md index 083fd2d88..acd55e571 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Changed + +- Restructured the response of the portfolio report endpoint (_X-ray_) + ### Fixed - Excluded the holdings originated of `FEE`, `INTEREST` and `LIABILITY` activities from the closed holdings on the portfolio holdings page diff --git a/apps/api/src/app/portfolio/portfolio.controller.ts b/apps/api/src/app/portfolio/portfolio.controller.ts index 2c71a4668..17cf41702 100644 --- a/apps/api/src/app/portfolio/portfolio.controller.ts +++ b/apps/api/src/app/portfolio/portfolio.controller.ts @@ -655,11 +655,11 @@ export class PortfolioController { this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION') && this.request.user.subscription.type === 'Basic' ) { - for (const rule in report.rules) { - report.rules[rule] = null; + for (const rule in report['x-ray'].rules) { + report['x-ray'].rules[rule] = null; } - report.statistics = { + report['x-ray'].statistics = { rulesActiveCount: 0, rulesFulfilledCount: 0 }; diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index 88d6e7d60..c5b9c2148 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -1156,7 +1156,7 @@ export class PortfolioService { }) ).toNumber(); - const rules: PortfolioReportResponse['rules'] = { + const rules: PortfolioReportResponse['x-ray']['rules'] = { accountClusterRisk: summary.activityCount > 0 ? await this.rulesService.evaluate( @@ -1311,7 +1311,12 @@ export class PortfolioService { : undefined }; - return { rules, statistics: this.getReportStatistics(rules) }; + return { + 'x-ray': { + rules, + statistics: this.getReportStatistics(rules) + } + }; } public async updateTags({ @@ -1731,8 +1736,8 @@ export class PortfolioService { } private getReportStatistics( - evaluatedRules: PortfolioReportResponse['rules'] - ): PortfolioReportResponse['statistics'] { + evaluatedRules: PortfolioReportResponse['x-ray']['rules'] + ): PortfolioReportResponse['x-ray']['statistics'] { const rulesActiveCount = Object.values(evaluatedRules) .flat() .filter((rule) => { diff --git a/apps/client/src/app/pages/portfolio/x-ray/x-ray-page.component.ts b/apps/client/src/app/pages/portfolio/x-ray/x-ray-page.component.ts index 5aabfc749..cad7d41e9 100644 --- a/apps/client/src/app/pages/portfolio/x-ray/x-ray-page.component.ts +++ b/apps/client/src/app/pages/portfolio/x-ray/x-ray-page.component.ts @@ -47,7 +47,7 @@ export class GfXRayPageComponent { public inactiveRules: PortfolioReportRule[]; public isLoading = false; public regionalMarketClusterRiskRules: PortfolioReportRule[]; - public statistics: PortfolioReportResponse['statistics']; + public statistics: PortfolioReportResponse['x-ray']['statistics']; public user: User; private unsubscribeSubject = new Subject(); @@ -115,7 +115,7 @@ export class GfXRayPageComponent { this.dataService .fetchPortfolioReport() .pipe(takeUntil(this.unsubscribeSubject)) - .subscribe(({ rules, statistics }) => { + .subscribe(({ 'x-ray': { rules, statistics } }) => { this.inactiveRules = this.mergeInactiveRules(rules); this.statistics = statistics; @@ -161,7 +161,7 @@ export class GfXRayPageComponent { } private mergeInactiveRules( - rules: PortfolioReportResponse['rules'] + rules: PortfolioReportResponse['x-ray']['rules'] ): PortfolioReportRule[] { let inactiveRules: PortfolioReportRule[] = []; diff --git a/libs/common/src/lib/interfaces/responses/portfolio-report.interface.ts b/libs/common/src/lib/interfaces/responses/portfolio-report.interface.ts index 35ff033eb..7ede7a5ed 100644 --- a/libs/common/src/lib/interfaces/responses/portfolio-report.interface.ts +++ b/libs/common/src/lib/interfaces/responses/portfolio-report.interface.ts @@ -1,9 +1,11 @@ import { PortfolioReportRule } from '../portfolio-report-rule.interface'; export interface PortfolioReportResponse { - rules: { [group: string]: PortfolioReportRule[] }; - statistics: { - rulesActiveCount: number; - rulesFulfilledCount: number; + 'x-ray': { + rules: { [group: string]: PortfolioReportRule[] }; + statistics: { + rulesActiveCount: number; + rulesFulfilledCount: number; + }; }; }