Feature/refactor ordersCount to activityCount (#4688)

* Refactor ordersCount to activityCount
This commit is contained in:
Thomas Kaul 2025-05-19 23:27:52 +02:00 committed by GitHub
parent 57c43e5815
commit a0f377e8eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 14 deletions

View File

@ -1249,7 +1249,7 @@ export class PortfolioService {
const rules: PortfolioReportResponse['rules'] = {
accountClusterRisk:
summary.ordersCount > 0
summary.activityCount > 0
? await this.rulesService.evaluate(
[
new AccountClusterRiskCurrentInvestment(
@ -1265,7 +1265,7 @@ export class PortfolioService {
)
: undefined,
assetClassClusterRisk:
summary.ordersCount > 0
summary.activityCount > 0
? await this.rulesService.evaluate(
[
new AssetClassClusterRiskEquity(
@ -1281,7 +1281,7 @@ export class PortfolioService {
)
: undefined,
currencyClusterRisk:
summary.ordersCount > 0
summary.activityCount > 0
? await this.rulesService.evaluate(
[
new CurrencyClusterRiskBaseCurrencyCurrentInvestment(
@ -1297,7 +1297,7 @@ export class PortfolioService {
)
: undefined,
economicMarketClusterRisk:
summary.ordersCount > 0
summary.activityCount > 0
? await this.rulesService.evaluate(
[
new EconomicMarketClusterRiskDevelopedMarkets(
@ -1338,7 +1338,7 @@ export class PortfolioService {
userSettings
),
regionalMarketClusterRisk:
summary.ordersCount > 0
summary.activityCount > 0
? await this.rulesService.evaluate(
[
new RegionalMarketClusterRiskAsiaPacific(
@ -1981,6 +1981,9 @@ export class PortfolioService {
netPerformanceWithCurrencyEffect,
totalBuy,
totalSell,
activityCount: activities.filter(({ type }) => {
return ['BUY', 'SELL'].includes(type);
}).length,
committedFunds: committedFunds.toNumber(),
currentValueInBaseCurrency: currentValueInBaseCurrency.toNumber(),
dividendInBaseCurrency: dividendInBaseCurrency.toNumber(),
@ -2008,9 +2011,6 @@ export class PortfolioService {
interest: interest.toNumber(),
items: valuables.toNumber(),
liabilities: liabilities.toNumber(),
ordersCount: activities.filter(({ type }) => {
return ['BUY', 'SELL'].includes(type);
}).length,
totalInvestment: totalInvestment.toNumber(),
totalValueInBaseCurrency: netWorth
};

View File

@ -1515,6 +1515,7 @@ describe('redactAttributes', () => {
}
},
summary: {
activityCount: 29,
annualizedPerformancePercent: 0.16690880197786,
annualizedPerformancePercentWithCurrencyEffect: 0.1694019484552876,
cash: null,
@ -1538,7 +1539,6 @@ describe('redactAttributes', () => {
interest: null,
items: null,
liabilities: null,
ordersCount: 29,
totalInvestment: null,
totalValueInBaseCurrency: null,
currentNetWorth: null
@ -3018,6 +3018,7 @@ describe('redactAttributes', () => {
}
},
summary: {
activityCount: 29,
annualizedPerformancePercent: 0.16690880197786,
annualizedPerformancePercentWithCurrencyEffect: 0.1694019484552876,
cash: null,
@ -3041,7 +3042,6 @@ describe('redactAttributes', () => {
interest: null,
items: null,
liabilities: null,
ordersCount: 29,
totalInvestment: null,
totalValueInBaseCurrency: null,
currentNetWorth: null

View File

@ -7,11 +7,11 @@
</div>
<div
class="flex-nowrap px-3 py-1 row"
[hidden]="summary?.ordersCount === null"
[hidden]="summary?.activityCount === null"
>
<div class="d-flex flex-grow-1 ml-3 text-truncate">
{{ summary?.ordersCount }}
<ng-container i18n>{summary?.ordersCount, plural,
{{ summary?.activityCount }}
<ng-container i18n>{summary?.activityCount, plural,
=1 {activity}
other {activities}
}</ng-container>

View File

@ -1,6 +1,7 @@
import { PortfolioPerformance } from './portfolio-performance.interface';
export interface PortfolioSummary extends PortfolioPerformance {
activityCount: number;
annualizedPerformancePercent: number;
annualizedPerformancePercentWithCurrencyEffect: number;
cash: number;
@ -21,7 +22,6 @@ export interface PortfolioSummary extends PortfolioPerformance {
interest: number;
items: number;
liabilities: number;
ordersCount: number;
totalBuy: number;
totalSell: number;
totalValueInBaseCurrency?: number;