Skip to content

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

Bugfix/fix account cluster risk rules for no accounts (#5202)

Thomas Kaula2d5264e5f64
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 97c6d00821..688cc854f2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -30,6 +30,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Fixed the horizontal ellipsis icon in the accounts table component
+- Fixed the static portfolio analysis rule for no accounts: _Account Cluster Risks_ (Current Investment)
+- Fixed the static portfolio analysis rule for no accounts: _Account Cluster Risks_ (Single Account)
## 2.182.0 - 2025-07-16
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 06b2c5a8ef..dbf3fee4d4 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
@@ -37,6 +37,16 @@ export class AccountClusterRiskCurrentInvestment extends Rule<Settings> {
};
}
+ if (Object.keys(accounts).length === 0) {
+ return {
+ evaluation: this.i18nService.getTranslation({
+ id: 'rule.accountClusterRiskCurrentInvestment.false.invalid',
+ languageCode: this.getLanguageCode()
+ }),
+ value: false
+ };
+ }
+
let maxAccount: (typeof accounts)[0];
let totalInvestment = 0;
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 ea48f35383..6045e58927 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
@@ -22,9 +22,17 @@ export class AccountClusterRiskSingleAccount extends Rule<RuleSettings> {
}
public evaluate() {
- const accounts: string[] = Object.keys(this.accounts);
+ const accountIds: string[] = Object.keys(this.accounts);
- if (accounts.length === 1) {
+ if (accountIds.length === 0) {
+ return {
+ evaluation: this.i18nService.getTranslation({
+ id: 'rule.accountClusterRiskSingleAccount.false.invalid',
+ languageCode: this.getLanguageCode()
+ }),
+ value: false
+ };
+ } else if (accountIds.length === 1) {
return {
evaluation: this.i18nService.getTranslation({
id: 'rule.accountClusterRiskSingleAccount.false',
@@ -39,7 +47,7 @@ export class AccountClusterRiskSingleAccount extends Rule<RuleSettings> {
id: 'rule.accountClusterRiskSingleAccount.true',
languageCode: this.getLanguageCode(),
placeholders: {
- accountsLength: accounts.length
+ accountsLength: accountIds.length
}
}),
value: true
diff --git a/apps/client/src/app/pages/i18n/i18n-page.html b/apps/client/src/app/pages/i18n/i18n-page.html
index bb5a00cc0d..26f0b8dbb4 100644
--- a/apps/client/src/app/pages/i18n/i18n-page.html
+++ b/apps/client/src/app/pages/i18n/i18n-page.html
@@ -17,6 +17,9 @@
Over $&#123;thresholdMax&#125;% of your current investment is at
$&#123;maxAccountName&#125; ($&#123;maxInvestmentRatio&#125;%)
</li>
+ <li i18n="@@rule.accountClusterRiskCurrentInvestment.false.invalid">
+ No accounts have been set up
+ </li>
<li i18n="@@rule.accountClusterRiskCurrentInvestment.true">
The major part of your current investment is at
$&#123;maxAccountName&#125; ($&#123;maxInvestmentRatio&#125;%) and does
@@ -26,6 +29,9 @@
<li i18n="@@rule.accountClusterRiskSingleAccount.false">
Your net worth is managed by a single account
</li>
+ <li i18n="@@rule.accountClusterRiskSingleAccount.false.invalid">
+ Your net worth is managed by 0 accounts
+ </li>
<li i18n="@@rule.accountClusterRiskSingleAccount.true">
Your net worth is managed by $&#123;accountsLength&#125; accounts
</li>