|
@ -573,7 +573,6 @@ export class PortfolioService { |
|
|
const cashPositions = await this.getCashPositions({ |
|
|
const cashPositions = await this.getCashPositions({ |
|
|
cashDetails, |
|
|
cashDetails, |
|
|
userCurrency, |
|
|
userCurrency, |
|
|
investment: totalInvestmentInBaseCurrency, |
|
|
|
|
|
value: filteredValueInBaseCurrency |
|
|
value: filteredValueInBaseCurrency |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -599,7 +598,6 @@ export class PortfolioService { |
|
|
const cashPositions = await this.getCashPositions({ |
|
|
const cashPositions = await this.getCashPositions({ |
|
|
cashDetails, |
|
|
cashDetails, |
|
|
userCurrency, |
|
|
userCurrency, |
|
|
investment: totalInvestmentInBaseCurrency, |
|
|
|
|
|
value: filteredValueInBaseCurrency |
|
|
value: filteredValueInBaseCurrency |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -1209,12 +1207,10 @@ export class PortfolioService { |
|
|
|
|
|
|
|
|
private async getCashPositions({ |
|
|
private async getCashPositions({ |
|
|
cashDetails, |
|
|
cashDetails, |
|
|
investment, |
|
|
|
|
|
userCurrency, |
|
|
userCurrency, |
|
|
value |
|
|
value |
|
|
}: { |
|
|
}: { |
|
|
cashDetails: CashDetails; |
|
|
cashDetails: CashDetails; |
|
|
investment: Big; |
|
|
|
|
|
userCurrency: string; |
|
|
userCurrency: string; |
|
|
value: Big; |
|
|
value: Big; |
|
|
}) { |
|
|
}) { |
|
@ -1692,6 +1688,14 @@ export class PortfolioService { |
|
|
userId: string; |
|
|
userId: string; |
|
|
withExcludedAccounts?: boolean; |
|
|
withExcludedAccounts?: boolean; |
|
|
}) { |
|
|
}) { |
|
|
|
|
|
const ordersOfTypeItem = await this.orderService.getOrders({ |
|
|
|
|
|
filters, |
|
|
|
|
|
userCurrency, |
|
|
|
|
|
userId, |
|
|
|
|
|
withExcludedAccounts, |
|
|
|
|
|
types: ['ITEM'] |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
const accounts: PortfolioDetails['accounts'] = {}; |
|
|
const accounts: PortfolioDetails['accounts'] = {}; |
|
|
|
|
|
|
|
|
let currentAccounts: (Account & { |
|
|
let currentAccounts: (Account & { |
|
@ -1722,10 +1726,18 @@ export class PortfolioService { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
for (const account of currentAccounts) { |
|
|
for (const account of currentAccounts) { |
|
|
const ordersByAccount = orders.filter(({ accountId }) => { |
|
|
let ordersByAccount = orders.filter(({ accountId }) => { |
|
|
return accountId === account.id; |
|
|
return accountId === account.id; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const ordersOfTypeItemByAccount = ordersOfTypeItem.filter( |
|
|
|
|
|
({ accountId }) => { |
|
|
|
|
|
return accountId === account.id; |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
ordersByAccount = ordersByAccount.concat(ordersOfTypeItemByAccount); |
|
|
|
|
|
|
|
|
accounts[account.id] = { |
|
|
accounts[account.id] = { |
|
|
balance: account.balance, |
|
|
balance: account.balance, |
|
|
currency: account.currency, |
|
|
currency: account.currency, |
|
@ -1745,7 +1757,9 @@ export class PortfolioService { |
|
|
for (const order of ordersByAccount) { |
|
|
for (const order of ordersByAccount) { |
|
|
let currentValueOfSymbolInBaseCurrency = |
|
|
let currentValueOfSymbolInBaseCurrency = |
|
|
order.quantity * |
|
|
order.quantity * |
|
|
portfolioItemsNow[order.SymbolProfile.symbol]?.marketPrice ?? 0; |
|
|
(portfolioItemsNow[order.SymbolProfile.symbol]?.marketPrice ?? |
|
|
|
|
|
order.unitPrice ?? |
|
|
|
|
|
0); |
|
|
let originalValueOfSymbolInBaseCurrency = |
|
|
let originalValueOfSymbolInBaseCurrency = |
|
|
this.exchangeRateDataService.toCurrency( |
|
|
this.exchangeRateDataService.toCurrency( |
|
|
order.quantity * order.unitPrice, |
|
|
order.quantity * order.unitPrice, |
|
|