Browse Source

Merge pull request #68 from dandevaud/feature/Fix-Investment-value-and-Frontend

Fix investment value calculation and frontend
pull/5027/head
dandevaud 1 year ago
committed by GitHub
parent
commit
fbec611019
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 16
      apps/api/src/app/portfolio/portfolio-calculator.ts
  2. 2
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts

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

@ -25,7 +25,15 @@ import {
isSameDay,
subDays
} from 'date-fns';
import { cloneDeep, first, isNumber, last, sortBy, uniq } from 'lodash';
import {
cloneDeep,
first,
flowRight,
isNumber,
last,
sortBy,
uniq
} from 'lodash';
import { CurrentRateService } from './current-rate.service';
import { CurrentPositions } from './interfaces/current-positions.interface';
@ -2026,7 +2034,7 @@ export class PortfolioCalculator {
const totalInvestmentBeforeTransaction = { ...totalInvestment };
const valueOfInvestmentBeforeTransaction = {
Value: totalUnits.mul(order.unitPrice),
Value: totalUnits.mul(order.unitPriceInBaseCurrency),
WithCurrencyEffect: totalUnits.mul(
order.unitPriceInBaseCurrencyWithCurrencyEffect
)
@ -2101,7 +2109,7 @@ export class PortfolioCalculator {
);
const valueOfInvestment = {
Value: totalUnits.mul(order.unitPrice),
Value: totalUnits.mul(order.unitPriceInBaseCurrency),
WithCurrencyEffect: totalUnits.mul(
order.unitPriceInBaseCurrencyWithCurrencyEffect
)
@ -2331,7 +2339,7 @@ export class PortfolioCalculator {
.mul(
withCurrencyEffect
? order.unitPriceInBaseCurrencyWithCurrencyEffect
: order.unitPrice
: order.unitPriceInBaseCurrency
)
.mul(this.getFactor(order.type))
: totalUnits.gt(0)

2
apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts

@ -166,7 +166,7 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
assetClass: this.assetProfile.assetClass ?? null,
assetSubClass: this.assetProfile.assetSubClass ?? null,
comment: this.assetProfile?.comment ?? '',
tags: this.assetProfile?.tags,
tags: this.assetProfile?.tags ?? [],
countries: JSON.stringify(
this.assetProfile?.countries?.map(({ code, weight }) => {
return { code, weight };

Loading…
Cancel
Save