From 5b4a1785ae26b9e10d7cf88a45c62eedfc74b9c7 Mon Sep 17 00:00:00 2001 From: Valentin Zickner <3200232+vzickner@users.noreply.github.com> Date: Sun, 1 Aug 2021 10:26:25 -0400 Subject: [PATCH] fix investment values for portfolio.service.ts (#243) * fix investment values for portfolio.service.ts * Update changelog Co-authored-by: Valentin Zickner Co-authored-by: Thomas <4159106+dtslvr@users.noreply.github.com> --- CHANGELOG.md | 9 ++++++++- apps/api/src/app/portfolio/portfolio.service.ts | 11 +++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60727af7b..fc8b3cb49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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/), 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 ### Added @@ -13,7 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### 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 diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index bb6f403cb..47c69bda0 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -641,6 +641,7 @@ export class PortfolioService { return { transactionPoints: [], orders: [] }; } + const userCurrency = this.request.user.Settings.currency; const portfolioOrders: PortfolioOrder[] = orders.map((order) => ({ currency: order.currency, date: format(order.date, DATE_FORMAT), @@ -648,12 +649,18 @@ export class PortfolioService { quantity: new Big(order.quantity), symbol: order.symbol, type: order.type, - unitPrice: new Big(order.unitPrice) + unitPrice: new Big( + this.exchangeRateDataService.toCurrency( + order.unitPrice, + order.currency, + userCurrency + ) + ) })); const portfolioCalculator = new PortfolioCalculator( this.currentRateService, - this.request.user.Settings.currency + userCurrency ); portfolioCalculator.computeTransactionPoints(portfolioOrders); return {