Browse Source

Feature/add key to x ray rule (#3248)

* Add key

* Update changelog
pull/3252/head
Thomas Kaul 10 months ago
committed by GitHub
parent
commit
b51255a543
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 12
      apps/api/src/app/portfolio/rules.service.ts
  3. 8
      apps/api/src/models/rule.ts
  4. 1
      apps/api/src/models/rules/account-cluster-risk/current-investment.ts
  5. 1
      apps/api/src/models/rules/account-cluster-risk/single-account.ts
  6. 1
      apps/api/src/models/rules/currency-cluster-risk/base-currency-current-investment.ts
  7. 1
      apps/api/src/models/rules/currency-cluster-risk/current-investment.ts
  8. 1
      apps/api/src/models/rules/emergency-fund/emergency-fund-setup.ts
  9. 1
      apps/api/src/models/rules/fees/fee-ratio-initial-investment.ts

1
CHANGELOG.md

@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added support to override the url of an asset profile in the asset profile details dialog of the admin control
- Added the asset profile icon to the asset profile details dialog of the admin control
- Added the platform icon to the create or update platform dialog of the admin control
- Extended the rules in the _X-ray_ section by a `key`
- Extended the content of the _Self-Hosting_ section by the data providers on the Frequently Asked Questions (FAQ) page
### Changed

12
apps/api/src/app/portfolio/rules.service.ts

@ -17,8 +17,16 @@ export class RulesService {
return rule.getSettings(aUserSettings)?.isActive;
})
.map((rule) => {
const evaluationResult = rule.evaluate(rule.getSettings(aUserSettings));
return { ...evaluationResult, name: rule.getName() };
const { evaluation, value } = rule.evaluate(
rule.getSettings(aUserSettings)
);
return {
evaluation,
value,
key: rule.getKey(),
name: rule.getName()
};
});
}
}

8
apps/api/src/models/rule.ts

@ -7,19 +7,27 @@ import { EvaluationResult } from './interfaces/evaluation-result.interface';
import { RuleInterface } from './interfaces/rule.interface';
export abstract class Rule<T extends RuleSettings> implements RuleInterface<T> {
private key: string;
private name: string;
public constructor(
protected exchangeRateDataService: ExchangeRateDataService,
{
key,
name
}: {
key: string;
name: string;
}
) {
this.key = key;
this.name = name;
}
public getKey() {
return this.key;
}
public getName() {
return this.name;
}

1
apps/api/src/models/rules/account-cluster-risk/current-investment.ts

@ -15,6 +15,7 @@ export class AccountClusterRiskCurrentInvestment extends Rule<Settings> {
accounts: PortfolioDetails['accounts']
) {
super(exchangeRateDataService, {
key: AccountClusterRiskCurrentInvestment.name,
name: 'Investment'
});

1
apps/api/src/models/rules/account-cluster-risk/single-account.ts

@ -11,6 +11,7 @@ export class AccountClusterRiskSingleAccount extends Rule<RuleSettings> {
accounts: PortfolioDetails['accounts']
) {
super(exchangeRateDataService, {
key: AccountClusterRiskSingleAccount.name,
name: 'Single Account'
});

1
apps/api/src/models/rules/currency-cluster-risk/base-currency-current-investment.ts

@ -11,6 +11,7 @@ export class CurrencyClusterRiskBaseCurrencyCurrentInvestment extends Rule<Setti
positions: TimelinePosition[]
) {
super(exchangeRateDataService, {
key: CurrencyClusterRiskBaseCurrencyCurrentInvestment.name,
name: 'Investment: Base Currency'
});

1
apps/api/src/models/rules/currency-cluster-risk/current-investment.ts

@ -11,6 +11,7 @@ export class CurrencyClusterRiskCurrentInvestment extends Rule<Settings> {
positions: TimelinePosition[]
) {
super(exchangeRateDataService, {
key: CurrencyClusterRiskCurrentInvestment.name,
name: 'Investment'
});

1
apps/api/src/models/rules/emergency-fund/emergency-fund-setup.ts

@ -11,6 +11,7 @@ export class EmergencyFundSetup extends Rule<Settings> {
emergencyFund: number
) {
super(exchangeRateDataService, {
key: EmergencyFundSetup.name,
name: 'Emergency Fund: Set up'
});

1
apps/api/src/models/rules/fees/fee-ratio-initial-investment.ts

@ -13,6 +13,7 @@ export class FeeRatioInitialInvestment extends Rule<Settings> {
fees: number
) {
super(exchangeRateDataService, {
key: FeeRatioInitialInvestment.name,
name: 'Fee Ratio'
});

Loading…
Cancel
Save