Browse Source

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

* Handle no accounts

* Update changelog
pull/5205/head
Thomas Kaul 2 days ago
committed by GitHub
parent
commit
a2d5264e5f
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      CHANGELOG.md
  2. 10
      apps/api/src/models/rules/account-cluster-risk/current-investment.ts
  3. 14
      apps/api/src/models/rules/account-cluster-risk/single-account.ts
  4. 6
      apps/client/src/app/pages/i18n/i18n-page.html

2
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

10
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;

14
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

6
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>

Loading…
Cancel
Save