fix investment values for portfolio.service.ts (#243)
* fix investment values for portfolio.service.ts * Update changelog Co-authored-by: Valentin Zickner <github@zickner.ch> Co-authored-by: Thomas <4159106+dtslvr@users.noreply.github.com>
This commit is contained in:
parent
56a5664c87
commit
5b4a1785ae
@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed an issue with the currency conversion in the portfolio calculations
|
||||||
|
|
||||||
## 1.31.0 - 01.08.2021
|
## 1.31.0 - 01.08.2021
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
@ -13,7 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Refactored the core engine for the calculations
|
- Refactored the core engine for the portfolio calculations
|
||||||
|
- Improved the performance of the portfolio calculations
|
||||||
|
|
||||||
## 1.30.0 - 31.07.2021
|
## 1.30.0 - 31.07.2021
|
||||||
|
|
||||||
|
@ -641,6 +641,7 @@ export class PortfolioService {
|
|||||||
return { transactionPoints: [], orders: [] };
|
return { transactionPoints: [], orders: [] };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const userCurrency = this.request.user.Settings.currency;
|
||||||
const portfolioOrders: PortfolioOrder[] = orders.map((order) => ({
|
const portfolioOrders: PortfolioOrder[] = orders.map((order) => ({
|
||||||
currency: order.currency,
|
currency: order.currency,
|
||||||
date: format(order.date, DATE_FORMAT),
|
date: format(order.date, DATE_FORMAT),
|
||||||
@ -648,12 +649,18 @@ export class PortfolioService {
|
|||||||
quantity: new Big(order.quantity),
|
quantity: new Big(order.quantity),
|
||||||
symbol: order.symbol,
|
symbol: order.symbol,
|
||||||
type: <OrderType>order.type,
|
type: <OrderType>order.type,
|
||||||
unitPrice: new Big(order.unitPrice)
|
unitPrice: new Big(
|
||||||
|
this.exchangeRateDataService.toCurrency(
|
||||||
|
order.unitPrice,
|
||||||
|
order.currency,
|
||||||
|
userCurrency
|
||||||
|
)
|
||||||
|
)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const portfolioCalculator = new PortfolioCalculator(
|
const portfolioCalculator = new PortfolioCalculator(
|
||||||
this.currentRateService,
|
this.currentRateService,
|
||||||
this.request.user.Settings.currency
|
userCurrency
|
||||||
);
|
);
|
||||||
portfolioCalculator.computeTransactionPoints(portfolioOrders);
|
portfolioCalculator.computeTransactionPoints(portfolioOrders);
|
||||||
return {
|
return {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user