Browse Source

Handle no accounts

pull/5202/head
Thomas Kaul 3 days ago
parent
commit
4fd952a308
  1. 10
      apps/api/src/models/rules/account-cluster-risk/current-investment.ts
  2. 14
      apps/api/src/models/rules/account-cluster-risk/single-account.ts
  3. 6
      apps/client/src/app/pages/i18n/i18n-page.html

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 maxAccount: (typeof accounts)[0];
let totalInvestment = 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() { 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 { return {
evaluation: this.i18nService.getTranslation({ evaluation: this.i18nService.getTranslation({
id: 'rule.accountClusterRiskSingleAccount.false', id: 'rule.accountClusterRiskSingleAccount.false',
@ -39,7 +47,7 @@ export class AccountClusterRiskSingleAccount extends Rule<RuleSettings> {
id: 'rule.accountClusterRiskSingleAccount.true', id: 'rule.accountClusterRiskSingleAccount.true',
languageCode: this.getLanguageCode(), languageCode: this.getLanguageCode(),
placeholders: { placeholders: {
accountsLength: accounts.length accountsLength: accountIds.length
} }
}), }),
value: true 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 Over $&#123;thresholdMax&#125;% of your current investment is at
$&#123;maxAccountName&#125; ($&#123;maxInvestmentRatio&#125;%) $&#123;maxAccountName&#125; ($&#123;maxInvestmentRatio&#125;%)
</li> </li>
<li i18n="@@rule.accountClusterRiskCurrentInvestment.false.invalid">
No accounts have been set up
</li>
<li i18n="@@rule.accountClusterRiskCurrentInvestment.true"> <li i18n="@@rule.accountClusterRiskCurrentInvestment.true">
The major part of your current investment is at The major part of your current investment is at
$&#123;maxAccountName&#125; ($&#123;maxInvestmentRatio&#125;%) and does $&#123;maxAccountName&#125; ($&#123;maxInvestmentRatio&#125;%) and does
@ -26,6 +29,9 @@
<li i18n="@@rule.accountClusterRiskSingleAccount.false"> <li i18n="@@rule.accountClusterRiskSingleAccount.false">
Your net worth is managed by a single account Your net worth is managed by a single account
</li> </li>
<li i18n="@@rule.accountClusterRiskSingleAccount.false.invalid">
Your net worth is managed by 0 accounts
</li>
<li i18n="@@rule.accountClusterRiskSingleAccount.true"> <li i18n="@@rule.accountClusterRiskSingleAccount.true">
Your net worth is managed by $&#123;accountsLength&#125; accounts Your net worth is managed by $&#123;accountsLength&#125; accounts
</li> </li>

Loading…
Cancel
Save