|
|
|
@ -895,12 +895,36 @@ export class PortfolioService { |
|
|
|
const user = await this.userService.user({ id: userId }); |
|
|
|
const userCurrency = this.getUserCurrency(user); |
|
|
|
|
|
|
|
const { activities } = |
|
|
|
const holdingFilters: Filter[] = [ |
|
|
|
{ id: dataSource, type: 'DATA_SOURCE' }, |
|
|
|
{ id: symbol, type: 'SYMBOL' } |
|
|
|
]; |
|
|
|
|
|
|
|
const { activities: allActivitiesOfHolding } = |
|
|
|
await this.activitiesService.getActivitiesForPortfolioCalculator({ |
|
|
|
userCurrency, |
|
|
|
userId |
|
|
|
userId, |
|
|
|
filters: holdingFilters, |
|
|
|
withExcludedAccountsAndActivities: true |
|
|
|
}); |
|
|
|
|
|
|
|
if (allActivitiesOfHolding.length === 0) { |
|
|
|
return undefined; |
|
|
|
} |
|
|
|
|
|
|
|
const hasExcludedActivities = allActivitiesOfHolding.some((activity) => { |
|
|
|
return this.isExcludedFromAnalysis(activity); |
|
|
|
}); |
|
|
|
|
|
|
|
const activities = hasExcludedActivities |
|
|
|
? allActivitiesOfHolding |
|
|
|
: ( |
|
|
|
await this.activitiesService.getActivitiesForPortfolioCalculator({ |
|
|
|
userCurrency, |
|
|
|
userId |
|
|
|
}) |
|
|
|
).activities; |
|
|
|
|
|
|
|
if (activities.length === 0) { |
|
|
|
return undefined; |
|
|
|
} |
|
|
|
@ -927,7 +951,9 @@ export class PortfolioService { |
|
|
|
activities, |
|
|
|
userId, |
|
|
|
calculationType: this.getUserPerformanceCalculationType(user), |
|
|
|
currency: userCurrency |
|
|
|
currency: userCurrency, |
|
|
|
filters: hasExcludedActivities ? holdingFilters : undefined, |
|
|
|
usePortfolioSnapshotCache: !hasExcludedActivities |
|
|
|
}); |
|
|
|
|
|
|
|
const transactionPoints = portfolioCalculator.getTransactionPoints(); |
|
|
|
@ -2033,12 +2059,7 @@ export class PortfolioService { |
|
|
|
const nonExcludedActivities: Activity[] = []; |
|
|
|
|
|
|
|
for (const activity of activities) { |
|
|
|
if ( |
|
|
|
(activity.account && isAccountExcluded(activity.account)) || |
|
|
|
activity.tags?.some(({ id }) => { |
|
|
|
return id === TAG_ID_EXCLUDE_FROM_ANALYSIS; |
|
|
|
}) |
|
|
|
) { |
|
|
|
if (this.isExcludedFromAnalysis(activity)) { |
|
|
|
excludedActivities.push(activity); |
|
|
|
} else { |
|
|
|
nonExcludedActivities.push(activity); |
|
|
|
@ -2204,6 +2225,15 @@ export class PortfolioService { |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
private isExcludedFromAnalysis(activity: Activity) { |
|
|
|
return ( |
|
|
|
isAccountExcluded(activity.account) || |
|
|
|
activity.tags?.some(({ id }) => { |
|
|
|
return id === TAG_ID_EXCLUDE_FROM_ANALYSIS; |
|
|
|
}) === true |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
private getSumOfActivityType({ |
|
|
|
activities, |
|
|
|
activityType, |
|
|
|
|