Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Feature/show category in rule settings dialog of X-ray (#5158)

Quan Huynh (John)9064b8bde2f3
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 45d3d5fc8c..eb0e90e99c 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
+### Added
+
+- Added the category title to the settings dialog to customize the rule thresholds of the _X-ray_ page (experimental)
+
### Changed
- Improved the label for asset profiles with `MANUAL` data source in the chart of the asset profile details dialog in the admin control panel
diff --git a/apps/api/src/app/portfolio/rules.service.ts b/apps/api/src/app/portfolio/rules.service.ts
index 48d1658aaa..7f6d964f50 100644
--- a/apps/api/src/app/portfolio/rules.service.ts
+++ b/apps/api/src/app/portfolio/rules.service.ts
@@ -22,6 +22,7 @@ export class RulesService {
return {
evaluation,
value,
+ categoryName: rule.getCategoryName(),
configuration: rule.getConfiguration(),
isActive: true,
key: rule.getKey(),
@@ -29,6 +30,7 @@ export class RulesService {
};
} else {
return {
+ categoryName: rule.getCategoryName(),
isActive: false,
key: rule.getKey(),
name: rule.getName()
diff --git a/apps/api/src/models/rule.ts b/apps/api/src/models/rule.ts
index 0870be03e3..52491a0b74 100644
--- a/apps/api/src/models/rule.ts
+++ b/apps/api/src/models/rule.ts
@@ -70,6 +70,8 @@ export abstract class Rule<T extends RuleSettings> implements RuleInterface<T> {
public abstract evaluate(aRuleSettings: T): EvaluationResult;
+ public abstract getCategoryName(): string;
+
public abstract getConfiguration(): Partial<
PortfolioReportRule['configuration']
>;
diff --git a/apps/api/src/models/rules/account-cluster-risk/current-investment.ts b/apps/api/src/models/rules/account-cluster-risk/current-investment.ts
index 501c9b803e..06b2c5a8ef 100644
--- a/apps/api/src/models/rules/account-cluster-risk/current-investment.ts
+++ b/apps/api/src/models/rules/account-cluster-risk/current-investment.ts
@@ -85,6 +85,13 @@ export class AccountClusterRiskCurrentInvestment extends Rule<Settings> {
};
}
+ public getCategoryName() {
+ return this.i18nService.getTranslation({
+ id: 'rule.accountClusterRisk.category',
+ languageCode: this.getLanguageCode()
+ });
+ }
+
public getConfiguration() {
return {
threshold: {
diff --git a/apps/api/src/models/rules/account-cluster-risk/single-account.ts b/apps/api/src/models/rules/account-cluster-risk/single-account.ts
index c35cabd9a7..ea48f35383 100644
--- a/apps/api/src/models/rules/account-cluster-risk/single-account.ts
+++ b/apps/api/src/models/rules/account-cluster-risk/single-account.ts
@@ -46,6 +46,13 @@ export class AccountClusterRiskSingleAccount extends Rule<RuleSettings> {
};
}
+ public getCategoryName() {
+ return this.i18nService.getTranslation({
+ id: 'rule.accountClusterRisk.category',
+ languageCode: this.getLanguageCode()
+ });
+ }
+
public getConfiguration() {
return undefined;
}
@@ -55,7 +62,6 @@ export class AccountClusterRiskSingleAccount extends Rule<RuleSettings> {
id: 'rule.accountClusterRiskSingleAccount',
languageCode: this.getLanguageCode()
});
- return 'Single Account';
}
public getSettings({ xRayRules }: UserSettings): RuleSettings {
diff --git a/apps/api/src/models/rules/asset-class-cluster-risk/equity.ts b/apps/api/src/models/rules/asset-class-cluster-risk/equity.ts
index 704cfdb852..5cef0333c6 100644
--- a/apps/api/src/models/rules/asset-class-cluster-risk/equity.ts
+++ b/apps/api/src/models/rules/asset-class-cluster-risk/equity.ts
@@ -81,6 +81,13 @@ export class AssetClassClusterRiskEquity extends Rule<Settings> {
};
}
+ public getCategoryName() {
+ return this.i18nService.getTranslation({
+ id: 'rule.assetClassClusterRisk.category',
+ languageCode: this.getLanguageCode()
+ });
+ }
+
public getConfiguration() {
return {
threshold: {
diff --git a/apps/api/src/models/rules/asset-class-cluster-risk/fixed-income.ts b/apps/api/src/models/rules/asset-class-cluster-risk/fixed-income.ts
index e0ca923115..ec20892e24 100644
--- a/apps/api/src/models/rules/asset-class-cluster-risk/fixed-income.ts
+++ b/apps/api/src/models/rules/asset-class-cluster-risk/fixed-income.ts
@@ -81,6 +81,13 @@ export class AssetClassClusterRiskFixedIncome extends Rule<Settings> {
};
}
+ public getCategoryName() {
+ return this.i18nService.getTranslation({
+ id: 'rule.assetClassClusterRisk.category',
+ languageCode: this.getLanguageCode()
+ });
+ }
+
public getConfiguration() {
return {
threshold: {
diff --git a/apps/api/src/models/rules/currency-cluster-risk/base-currency-current-investment.ts b/apps/api/src/models/rules/currency-cluster-risk/base-currency-current-investment.ts
index 0bf93e9b9e..c427a842ed 100644
--- a/apps/api/src/models/rules/currency-cluster-risk/base-currency-current-investment.ts
+++ b/apps/api/src/models/rules/currency-cluster-risk/base-currency-current-investment.ts
@@ -79,6 +79,13 @@ export class CurrencyClusterRiskBaseCurrencyCurrentInvestment extends Rule<Setti
};
}
+ public getCategoryName() {
+ return this.i18nService.getTranslation({
+ id: 'rule.currencyClusterRisk.category',
+ languageCode: this.getLanguageCode()
+ });
+ }
+
public getConfiguration() {
return undefined;
}
diff --git a/apps/api/src/models/rules/currency-cluster-risk/current-investment.ts b/apps/api/src/models/rules/currency-cluster-risk/current-investment.ts
index 7d7b29e784..ace38100fa 100644
--- a/apps/api/src/models/rules/currency-cluster-risk/current-investment.ts
+++ b/apps/api/src/models/rules/currency-cluster-risk/current-investment.ts
@@ -72,6 +72,13 @@ export class CurrencyClusterRiskCurrentInvestment extends Rule<Settings> {
};
}
+ public getCategoryName() {
+ return this.i18nService.getTranslation({
+ id: 'rule.currencyClusterRisk.category',
+ languageCode: this.getLanguageCode()
+ });
+ }
+
public getConfiguration() {
return {
threshold: {
diff --git a/apps/api/src/models/rules/economic-market-cluster-risk/developed-markets.ts b/apps/api/src/models/rules/economic-market-cluster-risk/developed-markets.ts
index 8f3ef0d650..d2c8fdae92 100644
--- a/apps/api/src/models/rules/economic-market-cluster-risk/developed-markets.ts
+++ b/apps/api/src/models/rules/economic-market-cluster-risk/developed-markets.ts
@@ -53,6 +53,10 @@ export class EconomicMarketClusterRiskDevelopedMarkets extends Rule<Settings> {
};
}
+ public getCategoryName() {
+ return 'Economic Market Cluster Risk'; // TODO: Replace hardcoded text with i18n translation
+ }
+
public getConfiguration() {
return {
threshold: {
diff --git a/apps/api/src/models/rules/economic-market-cluster-risk/emerging-markets.ts b/apps/api/src/models/rules/economic-market-cluster-risk/emerging-markets.ts
index 48eff22cfc..fd3c0ab67c 100644
--- a/apps/api/src/models/rules/economic-market-cluster-risk/emerging-markets.ts
+++ b/apps/api/src/models/rules/economic-market-cluster-risk/emerging-markets.ts
@@ -53,6 +53,10 @@ export class EconomicMarketClusterRiskEmergingMarkets extends Rule<Settings> {
};
}
+ public getCategoryName() {
+ return 'Economic Market Cluster Risk'; // TODO: Replace hardcoded text with i18n translation
+ }
+
public getConfiguration() {
return {
threshold: {
diff --git a/apps/api/src/models/rules/emergency-fund/emergency-fund-setup.ts b/apps/api/src/models/rules/emergency-fund/emergency-fund-setup.ts
index 67c0f297e6..1de51d0e76 100644
--- a/apps/api/src/models/rules/emergency-fund/emergency-fund-setup.ts
+++ b/apps/api/src/models/rules/emergency-fund/emergency-fund-setup.ts
@@ -41,6 +41,13 @@ export class EmergencyFundSetup extends Rule<Settings> {
};
}
+ public getCategoryName() {
+ return this.i18nService.getTranslation({
+ id: 'rule.emergencyFund.category',
+ languageCode: this.getLanguageCode()
+ });
+ }
+
public getConfiguration() {
return undefined;
}
diff --git a/apps/api/src/models/rules/fees/fee-ratio-initial-investment.ts b/apps/api/src/models/rules/fees/fee-ratio-initial-investment.ts
index 89fe32dbf6..805b86fd42 100644
--- a/apps/api/src/models/rules/fees/fee-ratio-initial-investment.ts
+++ b/apps/api/src/models/rules/fees/fee-ratio-initial-investment.ts
@@ -56,6 +56,13 @@ export class FeeRatioInitialInvestment extends Rule<Settings> {
};
}
+ public getCategoryName() {
+ return this.i18nService.getTranslation({
+ id: 'rule.fees.category',
+ languageCode: this.getLanguageCode()
+ });
+ }
+
public getConfiguration() {
return {
threshold: {
diff --git a/apps/api/src/models/rules/regional-market-cluster-risk/asia-pacific.ts b/apps/api/src/models/rules/regional-market-cluster-risk/asia-pacific.ts
index 823da9e27f..cadb2f9cd4 100644
--- a/apps/api/src/models/rules/regional-market-cluster-risk/asia-pacific.ts
+++ b/apps/api/src/models/rules/regional-market-cluster-risk/asia-pacific.ts
@@ -52,6 +52,10 @@ export class RegionalMarketClusterRiskAsiaPacific extends Rule<Settings> {
};
}
+ public getCategoryName() {
+ return 'Regional Market Cluster Risk'; // TODO: Replace hardcoded text with i18n translation
+ }
+
public getConfiguration() {
return {
threshold: {
diff --git a/apps/api/src/models/rules/regional-market-cluster-risk/emerging-markets.ts b/apps/api/src/models/rules/regional-market-cluster-risk/emerging-markets.ts
index b1ab74e1ff..5c582834c9 100644
--- a/apps/api/src/models/rules/regional-market-cluster-risk/emerging-markets.ts
+++ b/apps/api/src/models/rules/regional-market-cluster-risk/emerging-markets.ts
@@ -54,6 +54,10 @@ export class RegionalMarketClusterRiskEmergingMarkets extends Rule<Settings> {
};
}
+ public getCategoryName() {
+ return 'Regional Market Cluster Risk'; // TODO: Replace hardcoded text with i18n translation
+ }
+
public getConfiguration() {
return {
threshold: {
diff --git a/apps/api/src/models/rules/regional-market-cluster-risk/europe.ts b/apps/api/src/models/rules/regional-market-cluster-risk/europe.ts
index 3b069cf573..da17817860 100644
--- a/apps/api/src/models/rules/regional-market-cluster-risk/europe.ts
+++ b/apps/api/src/models/rules/regional-market-cluster-risk/europe.ts
@@ -52,6 +52,10 @@ export class RegionalMarketClusterRiskEurope extends Rule<Settings> {
};
}
+ public getCategoryName() {
+ return 'Regional Market Cluster Risk'; // TODO: Replace hardcoded text with i18n translation
+ }
+
public getConfiguration() {
return {
threshold: {
diff --git a/apps/api/src/models/rules/regional-market-cluster-risk/japan.ts b/apps/api/src/models/rules/regional-market-cluster-risk/japan.ts
index 511393cfbb..915f3995ba 100644
--- a/apps/api/src/models/rules/regional-market-cluster-risk/japan.ts
+++ b/apps/api/src/models/rules/regional-market-cluster-risk/japan.ts
@@ -52,6 +52,10 @@ export class RegionalMarketClusterRiskJapan extends Rule<Settings> {
};
}
+ public getCategoryName() {
+ return 'Regional Market Cluster Risk'; // TODO: Replace hardcoded text with i18n translation
+ }
+
public getConfiguration() {
return {
threshold: {
diff --git a/apps/api/src/models/rules/regional-market-cluster-risk/north-america.ts b/apps/api/src/models/rules/regional-market-cluster-risk/north-america.ts
index 5bea57db1d..6322708d5d 100644
--- a/apps/api/src/models/rules/regional-market-cluster-risk/north-america.ts
+++ b/apps/api/src/models/rules/regional-market-cluster-risk/north-america.ts
@@ -52,6 +52,10 @@ export class RegionalMarketClusterRiskNorthAmerica extends Rule<Settings> {
};
}
+ public getCategoryName() {
+ return 'Regional Market Cluster Risk'; // TODO: Replace hardcoded text with i18n translation
+ }
+
public getConfiguration() {
return {
threshold: {
diff --git a/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.html b/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.html
index 97854ad7dd..f5903e6d5d 100644
--- a/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.html
+++ b/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.html
@@ -1,4 +1,4 @@
-<div mat-dialog-title>{{ data.rule.name }}</div>
+<div mat-dialog-title>{{ data.rule.categoryName }} › {{ data.rule.name }}</div>
<div class="py-3" mat-dialog-content>
@if (
diff --git a/apps/client/src/app/pages/i18n/i18n-page.html b/apps/client/src/app/pages/i18n/i18n-page.html
index 4bb8c990d9..d19b8bb982 100644
--- a/apps/client/src/app/pages/i18n/i18n-page.html
+++ b/apps/client/src/app/pages/i18n/i18n-page.html
@@ -11,6 +11,7 @@
performance, portfolio, software, stock, trading, wealth, web3
</li>
<li i18n="@@myAccount">My Account</li>
+ <li i18n="@@rule.accountClusterRisk.category">Account Cluster Risk</li>
<li i18n="@@rule.accountClusterRiskCurrentInvestment">Investment</li>
<li i18n="@@rule.accountClusterRiskCurrentInvestment.false">
Over $&#123;thresholdMax&#125;% of your current investment is at
@@ -28,6 +29,9 @@
<li i18n="@@rule.accountClusterRiskSingleAccount.true">
Your net worth is managed by $&#123;accountsLength&#125; accounts
</li>
+ <li i18n="@@rule.assetClassClusterRisk.category">
+ Asset Class Cluster Risk
+ </li>
<li i18n="@@rule.assetClassClusterRiskEquity">Equity</li>
<li i18n="@@rule.assetClassClusterRiskEquity.false.max">
The equity contribution of your current investment
@@ -57,6 +61,7 @@
($&#123;fixedIncomeValueRatio&#125;%) is within the range of
$&#123;thresholdMin&#125;% and $&#123;thresholdMax&#125;%
</li>
+ <li i18n="@@rule.currencyClusterRisk.category">Currency Cluster Risk</li>
<li i18n="@@rule.currencyClusterRiskBaseCurrencyCurrentInvestment">
Investment: Base Currency
</li>
@@ -78,6 +83,10 @@
($&#123;maxValueRatio&#125;%) and does not exceed
$&#123;thresholdMax&#125;%
</li>
+ <li i18n="@@rule.economicMarketClusterRisk.category">
+ Economic Market Cluster Risk
+ </li>
+ <li i18n="@@rule.emergencyFund.category">Emergency Fund</li>
<li i18n="@@rule.emergencyFundSetup">Set up</li>
<li i18n="@@rule.emergencyFundSetup.false">
No emergency fund has been set up
@@ -94,6 +103,10 @@
The fees do not exceed $&#123;thresholdMax&#125;% of your initial
investment ($&#123;feeRatio&#125;%)
</li>
+ <li i18n="@@rule.fees.category">Fees</li>
+ <li i18n="@@rule.regionalMarketClusterRisk.category">
+ Regional Market Cluster Risk
+ </li>
<li i18n="@@slogan">Open Source Wealth Management Software</li>
</ul>
</div>
diff --git a/libs/common/src/lib/interfaces/portfolio-report-rule.interface.ts b/libs/common/src/lib/interfaces/portfolio-report-rule.interface.ts
index 0296606b87..4df7a8eac2 100644
--- a/libs/common/src/lib/interfaces/portfolio-report-rule.interface.ts
+++ b/libs/common/src/lib/interfaces/portfolio-report-rule.interface.ts
@@ -1,4 +1,5 @@
export interface PortfolioReportRule {
+ categoryName: string;
configuration?: {
threshold?: {
max: number;