Browse Source

Refactoring

pull/7148/head
Thomas Kaul 2 weeks ago
parent
commit
a451fba433
  1. 7
      apps/api/src/app/portfolio/calculator/portfolio-calculator.ts
  2. 8
      apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-cash.spec.ts

7
apps/api/src/app/portfolio/calculator/portfolio-calculator.ts

@ -392,10 +392,6 @@ export abstract class PortfolioCalculator {
const includeInTotalAssetValue =
item.assetSubClass !== AssetSubClass.CASH;
// Cash positions are included in the chart (value, net worth and
// performance) so that the home screen reflects the entire portfolio.
// They remain excluded from the overall performance aggregate (see
// includeInTotalAssetValue) which keeps the FIRE wealth asset-only.
valuesBySymbol[item.symbol] = {
currentValues,
currentValuesWithCurrencyEffect,
@ -612,9 +608,6 @@ export abstract class PortfolioCalculator {
netPerformance: totalNetPerformanceValue.toNumber(),
netPerformanceWithCurrencyEffect:
totalNetPerformanceValueWithCurrencyEffect.toNumber(),
// Cash is now reflected through the cash positions in
// totalCurrentValueWithCurrencyEffect, so the account balance must no
// longer be added here to avoid counting cash twice in the net worth.
netWorth: totalCurrentValueWithCurrencyEffect.toNumber(),
totalAccountBalance: totalAccountBalanceWithCurrencyEffect.toNumber(),
totalInvestment: totalInvestmentValue.toNumber(),

8
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-cash.spec.ts

@ -148,15 +148,15 @@ describe('PortfolioCalculator', () => {
balances: [
{
accountId,
id: randomUUID(),
date: parseDate('2023-12-31'),
id: randomUUID(),
value: 1000,
valueInBaseCurrency: 850
},
{
accountId,
id: randomUUID(),
date: parseDate('2024-12-31'),
id: randomUUID(),
value: 2000,
valueInBaseCurrency: 1800
}
@ -376,10 +376,10 @@ describe('PortfolioCalculator', () => {
// be excluded, which left the value at 0 for a cash-only portfolio).
expect(lastDataItem.valueWithCurrencyEffect).toBeGreaterThan(0);
// The account balance is still tracked
// The account balance is still tracked ...
expect(lastDataItem.totalAccountBalance).toBeGreaterThan(0);
// but it is no longer added on top of the cash position, so the net
// ... but it is no longer added on top of the cash position, so the net
// worth equals the portfolio value and cash is not counted twice.
expect(lastDataItem.netWorth).toBeCloseTo(
lastDataItem.valueWithCurrencyEffect

Loading…
Cancel
Save