|
@ -225,7 +225,7 @@ export class PortfolioService { |
|
|
}): Promise<InvestmentItem[]> { |
|
|
}): Promise<InvestmentItem[]> { |
|
|
const userId = await this.getUserId(impersonationId, this.request.user.id); |
|
|
const userId = await this.getUserId(impersonationId, this.request.user.id); |
|
|
|
|
|
|
|
|
const activities = await this.orderService.getOrders({ |
|
|
const { activities } = await this.orderService.getOrders({ |
|
|
filters, |
|
|
filters, |
|
|
userId, |
|
|
userId, |
|
|
types: ['DIVIDEND'], |
|
|
types: ['DIVIDEND'], |
|
@ -679,13 +679,13 @@ export class PortfolioService { |
|
|
const user = await this.userService.user({ id: userId }); |
|
|
const user = await this.userService.user({ id: userId }); |
|
|
const userCurrency = this.getUserCurrency(user); |
|
|
const userCurrency = this.getUserCurrency(user); |
|
|
|
|
|
|
|
|
const orders = ( |
|
|
const { activities } = await this.orderService.getOrders({ |
|
|
await this.orderService.getOrders({ |
|
|
userCurrency, |
|
|
userCurrency, |
|
|
userId, |
|
|
userId, |
|
|
withExcludedAccounts: true |
|
|
withExcludedAccounts: true |
|
|
}); |
|
|
}) |
|
|
|
|
|
).filter(({ SymbolProfile }) => { |
|
|
const orders = activities.filter(({ SymbolProfile }) => { |
|
|
return ( |
|
|
return ( |
|
|
SymbolProfile.dataSource === aDataSource && |
|
|
SymbolProfile.dataSource === aDataSource && |
|
|
SymbolProfile.symbol === aSymbol |
|
|
SymbolProfile.symbol === aSymbol |
|
@ -1639,18 +1639,18 @@ export class PortfolioService { |
|
|
userId |
|
|
userId |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const activities = await this.orderService.getOrders({ |
|
|
const { activities } = await this.orderService.getOrders({ |
|
|
userCurrency, |
|
|
userCurrency, |
|
|
userId |
|
|
userId |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const excludedActivities = ( |
|
|
let { activities: excludedActivities } = await this.orderService.getOrders({ |
|
|
await this.orderService.getOrders({ |
|
|
userCurrency, |
|
|
userCurrency, |
|
|
userId, |
|
|
userId, |
|
|
withExcludedAccounts: true |
|
|
withExcludedAccounts: true |
|
|
}); |
|
|
}) |
|
|
|
|
|
).filter(({ Account: account }) => { |
|
|
excludedActivities = excludedActivities.filter(({ Account: account }) => { |
|
|
return account?.isExcluded ?? false; |
|
|
return account?.isExcluded ?? false; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -1830,7 +1830,7 @@ export class PortfolioService { |
|
|
const userCurrency = |
|
|
const userCurrency = |
|
|
this.request.user?.Settings?.settings.baseCurrency ?? DEFAULT_CURRENCY; |
|
|
this.request.user?.Settings?.settings.baseCurrency ?? DEFAULT_CURRENCY; |
|
|
|
|
|
|
|
|
const orders = await this.orderService.getOrders({ |
|
|
const { activities, count } = await this.orderService.getOrders({ |
|
|
filters, |
|
|
filters, |
|
|
includeDrafts, |
|
|
includeDrafts, |
|
|
userCurrency, |
|
|
userCurrency, |
|
@ -1839,11 +1839,11 @@ export class PortfolioService { |
|
|
types: ['BUY', 'SELL'] |
|
|
types: ['BUY', 'SELL'] |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
if (orders.length <= 0) { |
|
|
if (count <= 0) { |
|
|
return { transactionPoints: [], orders: [], portfolioOrders: [] }; |
|
|
return { transactionPoints: [], orders: [], portfolioOrders: [] }; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const portfolioOrders: PortfolioOrder[] = orders.map((order) => ({ |
|
|
const portfolioOrders: PortfolioOrder[] = activities.map((order) => ({ |
|
|
currency: order.SymbolProfile.currency, |
|
|
currency: order.SymbolProfile.currency, |
|
|
dataSource: order.SymbolProfile.dataSource, |
|
|
dataSource: order.SymbolProfile.dataSource, |
|
|
date: format(order.date, DATE_FORMAT), |
|
|
date: format(order.date, DATE_FORMAT), |
|
@ -1877,8 +1877,8 @@ export class PortfolioService { |
|
|
portfolioCalculator.computeTransactionPoints(); |
|
|
portfolioCalculator.computeTransactionPoints(); |
|
|
|
|
|
|
|
|
return { |
|
|
return { |
|
|
orders, |
|
|
|
|
|
portfolioOrders, |
|
|
portfolioOrders, |
|
|
|
|
|
orders: activities, |
|
|
transactionPoints: portfolioCalculator.getTransactionPoints() |
|
|
transactionPoints: portfolioCalculator.getTransactionPoints() |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
@ -1913,13 +1913,14 @@ export class PortfolioService { |
|
|
userId: string; |
|
|
userId: string; |
|
|
withExcludedAccounts?: boolean; |
|
|
withExcludedAccounts?: boolean; |
|
|
}) { |
|
|
}) { |
|
|
const ordersOfTypeItemOrLiability = await this.orderService.getOrders({ |
|
|
const { activities: ordersOfTypeItemOrLiability } = |
|
|
filters, |
|
|
await this.orderService.getOrders({ |
|
|
userCurrency, |
|
|
filters, |
|
|
userId, |
|
|
userCurrency, |
|
|
withExcludedAccounts, |
|
|
userId, |
|
|
types: ['ITEM', 'LIABILITY'] |
|
|
withExcludedAccounts, |
|
|
}); |
|
|
types: ['ITEM', 'LIABILITY'] |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
const accounts: PortfolioDetails['accounts'] = {}; |
|
|
const accounts: PortfolioDetails['accounts'] = {}; |
|
|
const platforms: PortfolioDetails['platforms'] = {}; |
|
|
const platforms: PortfolioDetails['platforms'] = {}; |
|
|