|
|
@ -122,11 +122,11 @@ export class ImportService { |
|
|
const isDuplicate = activities.some((activity) => { |
|
|
const isDuplicate = activities.some((activity) => { |
|
|
return ( |
|
|
return ( |
|
|
activity.accountId === account?.id && |
|
|
activity.accountId === account?.id && |
|
|
activity.SymbolProfile.currency === assetProfile.currency && |
|
|
activity.assetProfile.currency === assetProfile.currency && |
|
|
activity.SymbolProfile.dataSource === assetProfile.dataSource && |
|
|
activity.assetProfile.dataSource === assetProfile.dataSource && |
|
|
isSameSecond(activity.date, date) && |
|
|
isSameSecond(activity.date, date) && |
|
|
activity.quantity === quantity && |
|
|
activity.quantity === quantity && |
|
|
activity.SymbolProfile.symbol === assetProfile.symbol && |
|
|
activity.assetProfile.symbol === assetProfile.symbol && |
|
|
activity.type === 'DIVIDEND' && |
|
|
activity.type === 'DIVIDEND' && |
|
|
activity.unitPrice === marketPrice |
|
|
activity.unitPrice === marketPrice |
|
|
); |
|
|
); |
|
|
@ -138,6 +138,7 @@ export class ImportService { |
|
|
|
|
|
|
|
|
return { |
|
|
return { |
|
|
account, |
|
|
account, |
|
|
|
|
|
assetProfile, |
|
|
date, |
|
|
date, |
|
|
error, |
|
|
error, |
|
|
quantity, |
|
|
quantity, |
|
|
@ -463,19 +464,18 @@ export class ImportService { |
|
|
const error = activity.error; |
|
|
const error = activity.error; |
|
|
const fee = activity.fee; |
|
|
const fee = activity.fee; |
|
|
const quantity = activity.quantity; |
|
|
const quantity = activity.quantity; |
|
|
const SymbolProfile = activity.SymbolProfile; |
|
|
|
|
|
const tagIds = activity.tagIds ?? []; |
|
|
const tagIds = activity.tagIds ?? []; |
|
|
const type = activity.type; |
|
|
const type = activity.type; |
|
|
const unitPrice = activity.unitPrice; |
|
|
const unitPrice = activity.unitPrice; |
|
|
|
|
|
|
|
|
const assetProfile = assetProfiles[ |
|
|
const assetProfile = assetProfiles[ |
|
|
getAssetProfileIdentifier({ |
|
|
getAssetProfileIdentifier({ |
|
|
dataSource: SymbolProfile.dataSource, |
|
|
dataSource: activity.assetProfile.dataSource, |
|
|
symbol: SymbolProfile.symbol |
|
|
symbol: activity.assetProfile.symbol |
|
|
}) |
|
|
}) |
|
|
] ?? { |
|
|
] ?? { |
|
|
dataSource: SymbolProfile.dataSource, |
|
|
dataSource: activity.assetProfile.dataSource, |
|
|
symbol: SymbolProfile.symbol |
|
|
symbol: activity.assetProfile.symbol |
|
|
}; |
|
|
}; |
|
|
const { |
|
|
const { |
|
|
assetClass, |
|
|
assetClass, |
|
|
@ -619,6 +619,8 @@ export class ImportService { |
|
|
|
|
|
|
|
|
activities.push({ |
|
|
activities.push({ |
|
|
...order, |
|
|
...order, |
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
|
assetProfile, |
|
|
error, |
|
|
error, |
|
|
value, |
|
|
value, |
|
|
valueInBaseCurrency, |
|
|
valueInBaseCurrency, |
|
|
@ -633,19 +635,19 @@ export class ImportService { |
|
|
|
|
|
|
|
|
if (!isDryRun) { |
|
|
if (!isDryRun) { |
|
|
// Gather symbol data in the background, if not dry run
|
|
|
// Gather symbol data in the background, if not dry run
|
|
|
const uniqueActivities = uniqBy(activities, ({ SymbolProfile }) => { |
|
|
const uniqueActivities = uniqBy(activities, ({ assetProfile }) => { |
|
|
return getAssetProfileIdentifier({ |
|
|
return getAssetProfileIdentifier({ |
|
|
dataSource: SymbolProfile.dataSource, |
|
|
dataSource: assetProfile.dataSource, |
|
|
symbol: SymbolProfile.symbol |
|
|
symbol: assetProfile.symbol |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
this.dataGatheringService.gatherSymbols({ |
|
|
this.dataGatheringService.gatherSymbols({ |
|
|
dataGatheringItems: uniqueActivities.map(({ date, SymbolProfile }) => { |
|
|
dataGatheringItems: uniqueActivities.map(({ assetProfile, date }) => { |
|
|
return { |
|
|
return { |
|
|
date, |
|
|
date, |
|
|
dataSource: SymbolProfile.dataSource, |
|
|
dataSource: assetProfile.dataSource, |
|
|
symbol: SymbolProfile.symbol |
|
|
symbol: assetProfile.symbol |
|
|
}; |
|
|
}; |
|
|
}), |
|
|
}), |
|
|
priority: DATA_GATHERING_QUEUE_PRIORITY_HIGH |
|
|
priority: DATA_GATHERING_QUEUE_PRIORITY_HIGH |
|
|
@ -692,12 +694,12 @@ export class ImportService { |
|
|
activity.accountId === accountId && |
|
|
activity.accountId === accountId && |
|
|
activity.comment === comment && |
|
|
activity.comment === comment && |
|
|
(activity.currency === currency || |
|
|
(activity.currency === currency || |
|
|
activity.SymbolProfile.currency === currency) && |
|
|
activity.assetProfile.currency === currency) && |
|
|
activity.SymbolProfile.dataSource === dataSource && |
|
|
activity.assetProfile.dataSource === dataSource && |
|
|
isSameSecond(activity.date, date) && |
|
|
isSameSecond(activity.date, date) && |
|
|
activity.fee === fee && |
|
|
activity.fee === fee && |
|
|
activity.quantity === quantity && |
|
|
activity.quantity === quantity && |
|
|
activity.SymbolProfile.symbol === symbol && |
|
|
activity.assetProfile.symbol === symbol && |
|
|
activity.type === type && |
|
|
activity.type === type && |
|
|
activity.unitPrice === unitPrice |
|
|
activity.unitPrice === unitPrice |
|
|
); |
|
|
); |
|
|
@ -717,7 +719,7 @@ export class ImportService { |
|
|
quantity, |
|
|
quantity, |
|
|
type, |
|
|
type, |
|
|
unitPrice, |
|
|
unitPrice, |
|
|
SymbolProfile: { |
|
|
assetProfile: { |
|
|
dataSource, |
|
|
dataSource, |
|
|
symbol, |
|
|
symbol, |
|
|
activitiesCount: undefined, |
|
|
activitiesCount: undefined, |
|
|
|