Feature/improve exception handling of current investments in various rules (#3156)

* Improve exception handling

* Update changelog
This commit is contained in:
Thomas Kaul 2024-03-16 12:29:21 +01:00 committed by GitHub
parent 82c78cad6b
commit 38c2baf943
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 6 additions and 5 deletions

View File

@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Improved the usability of the platform management in the admin control panel - Improved the usability of the platform management in the admin control panel
- Improved the usability of the tag management in the admin control panel - Improved the usability of the tag management in the admin control panel
- Improved the exception handling of various rules in the _X-ray_ section
### Fixed ### Fixed

View File

@ -35,7 +35,7 @@ export class AccountClusterRiskCurrentInvestment extends Rule<Settings> {
}; };
} }
let maxItem; let maxItem: (typeof accounts)[0];
let totalInvestment = 0; let totalInvestment = 0;
for (const account of Object.values(accounts)) { for (const account of Object.values(accounts)) {
@ -52,7 +52,7 @@ export class AccountClusterRiskCurrentInvestment extends Rule<Settings> {
} }
} }
const maxInvestmentRatio = maxItem.investment / totalInvestment; const maxInvestmentRatio = maxItem?.investment / totalInvestment || 0;
if (maxInvestmentRatio > ruleSettings.threshold) { if (maxInvestmentRatio > ruleSettings.threshold) {
return { return {

View File

@ -43,7 +43,7 @@ export class CurrencyClusterRiskBaseCurrencyCurrentInvestment extends Rule<Setti
const baseCurrencyValueRatio = baseCurrencyItem?.value / totalValue || 0; const baseCurrencyValueRatio = baseCurrencyItem?.value / totalValue || 0;
if (maxItem.groupKey !== ruleSettings.baseCurrency) { if (maxItem?.groupKey !== ruleSettings.baseCurrency) {
return { return {
evaluation: `The major part of your current investment is not in your base currency (${( evaluation: `The major part of your current investment is not in your base currency (${(
baseCurrencyValueRatio * 100 baseCurrencyValueRatio * 100

View File

@ -37,7 +37,7 @@ export class CurrencyClusterRiskCurrentInvestment extends Rule<Settings> {
} }
}); });
const maxValueRatio = maxItem.value / totalValue; const maxValueRatio = maxItem?.value / totalValue || 0;
if (maxValueRatio > ruleSettings.threshold) { if (maxValueRatio > ruleSettings.threshold) {
return { return {
@ -52,7 +52,7 @@ export class CurrencyClusterRiskCurrentInvestment extends Rule<Settings> {
return { return {
evaluation: `The major part of your current investment is in ${ evaluation: `The major part of your current investment is in ${
maxItem.groupKey maxItem?.groupKey ?? ruleSettings.baseCurrency
} (${(maxValueRatio * 100).toPrecision(3)}%) and does not exceed ${ } (${(maxValueRatio * 100).toPrecision(3)}%) and does not exceed ${
ruleSettings.threshold * 100 ruleSettings.threshold * 100
}%`, }%`,