diff --git a/apps/api/src/models/rule.ts b/apps/api/src/models/rule.ts index 187527fbb..c3c3eac79 100644 --- a/apps/api/src/models/rule.ts +++ b/apps/api/src/models/rule.ts @@ -1,5 +1,6 @@ import { RuleSettings } from '@ghostfolio/api/models/interfaces/rule-settings.interface'; import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.service'; +import { I18nService } from '@ghostfolio/api/services/i18n/i18n.service'; import { groupBy } from '@ghostfolio/common/helper'; import { PortfolioPosition, @@ -13,6 +14,7 @@ import { EvaluationResult } from './interfaces/evaluation-result.interface'; import { RuleInterface } from './interfaces/rule.interface'; export abstract class Rule implements RuleInterface { + protected i18nService = new I18nService(); private key: string; private name: string; @@ -56,7 +58,7 @@ export abstract class Rule implements RuleInterface { previousValue + this.exchangeRateDataService.toCurrency( new Big(currentValue.quantity) - .mul(currentValue.marketPrice) + .mul(currentValue.marketPrice ?? 0) .toNumber(), currentValue.currency, baseCurrency 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 fa9d7e7bc..b6c4c6781 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 @@ -1,6 +1,7 @@ import { RuleSettings } from '@ghostfolio/api/models/interfaces/rule-settings.interface'; import { Rule } from '@ghostfolio/api/models/rule'; import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.service'; +import { DEFAULT_LANGUAGE_CODE } from '@ghostfolio/common/config'; import { UserSettings } from '@ghostfolio/common/interfaces'; export class FeeRatioInitialInvestment extends Rule { @@ -27,18 +28,30 @@ export class FeeRatioInitialInvestment extends Rule { : 0; if (feeRatio > ruleSettings.thresholdMax) { + const evaluation = this.i18nService + .getTranslation({ + id: 'rule.fee-ratio-initial-investment.exceed', + languageCode: DEFAULT_LANGUAGE_CODE + }) + .replace('{thresholdMax}', (ruleSettings.thresholdMax * 100).toFixed(2)) + .replace('{feeRatio}', (feeRatio * 100).toPrecision(3)); + return { - evaluation: `The fees do exceed ${ - ruleSettings.thresholdMax * 100 - }% of your initial investment (${(feeRatio * 100).toPrecision(3)}%)`, + evaluation, value: false }; } + const evaluation = this.i18nService + .getTranslation({ + id: 'rule.fee-ratio-initial-investment.not-exceed', + languageCode: DEFAULT_LANGUAGE_CODE + }) + .replace('{thresholdMax}', (ruleSettings.thresholdMax * 100).toFixed(2)) + .replace('{feeRatio}', (feeRatio * 100).toPrecision(3)); + return { - evaluation: `The fees do not exceed ${ - ruleSettings.thresholdMax * 100 - }% of your initial investment (${(feeRatio * 100).toPrecision(3)}%)`, + evaluation, 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 b23129c45..6b9867c95 100644 --- a/apps/client/src/app/pages/i18n/i18n-page.html +++ b/apps/client/src/app/pages/i18n/i18n-page.html @@ -11,6 +11,10 @@ performance, portfolio, software, stock, trading, wealth, web3
  • My Account
  • +
  • Open Source Wealth Management Software