Browse Source
Feature/restructure portfolio report response (#5260)
* Restructure response of portfolio report endpoint
* Update changelog
pull/5240/head
Thomas Kaul
2 weeks ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with
25 additions and
14 deletions
-
CHANGELOG.md
-
apps/api/src/app/portfolio/portfolio.controller.ts
-
apps/api/src/app/portfolio/portfolio.service.ts
-
apps/client/src/app/pages/portfolio/x-ray/x-ray-page.component.ts
-
libs/common/src/lib/interfaces/responses/portfolio-report.interface.ts
|
|
@ -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 |
|
|
|
|
|
@ -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 |
|
|
|
}; |
|
|
|
|
|
@ -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) => { |
|
|
|
|
|
@ -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<void>(); |
|
|
@ -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[] = []; |
|
|
|
|
|
|
|
|
|
@ -1,9 +1,11 @@ |
|
|
|
import { PortfolioReportRule } from '../portfolio-report-rule.interface'; |
|
|
|
|
|
|
|
export interface PortfolioReportResponse { |
|
|
|
'x-ray': { |
|
|
|
rules: { [group: string]: PortfolioReportRule[] }; |
|
|
|
statistics: { |
|
|
|
rulesActiveCount: number; |
|
|
|
rulesFulfilledCount: number; |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|