Browse Source

Fix exception in value of account calculation caused by liabilities

pull/3109/head
Thomas Kaul 1 year ago
parent
commit
48ca184c72
  1. 17
      apps/api/src/app/portfolio/portfolio.service.ts

17
apps/api/src/app/portfolio/portfolio.service.ts

@ -1941,7 +1941,7 @@ export class PortfolioService {
private async getTransactionPoints({
filters,
includeDrafts = false,
types = ['BUY', 'ITEM', 'SELL'],
types = ['BUY', 'ITEM', 'LIABILITY', 'SELL'],
userId,
withExcludedAccounts = false
}: {
@ -2076,19 +2076,10 @@ export class PortfolioService {
});
for (const account of currentAccounts) {
let ordersByAccount = orders.filter(({ accountId }) => {
const ordersByAccount = orders.filter(({ accountId }) => {
return accountId === account.id;
});
const ordersOfTypeItemOrLiabilityByAccount =
ordersOfTypeItemOrLiability.filter(({ accountId }) => {
return accountId === account.id;
});
ordersByAccount = ordersByAccount.concat(
ordersOfTypeItemOrLiabilityByAccount
);
accounts[account.id] = {
balance: account.balance,
currency: account.currency,
@ -2128,8 +2119,8 @@ export class PortfolioService {
} of ordersByAccount) {
let currentValueOfSymbolInBaseCurrency =
quantity *
portfolioItemsNow[SymbolProfile.symbol]
?.marketPriceInBaseCurrency ?? 0;
(portfolioItemsNow[SymbolProfile.symbol]?.marketPriceInBaseCurrency ??
0);
if (['LIABILITY', 'SELL'].includes(type)) {
currentValueOfSymbolInBaseCurrency *= getFactor(type);

Loading…
Cancel
Save