|
|
@ -1049,6 +1049,9 @@ export class ImportService { |
|
|
withExcludedAccountsAndActivities: true |
|
|
withExcludedAccountsAndActivities: true |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const processedActivities: (Partial<Activity> & |
|
|
|
|
|
Pick<Activity, 'assetProfile'>)[] = []; |
|
|
|
|
|
|
|
|
return activitiesDto.map( |
|
|
return activitiesDto.map( |
|
|
({ |
|
|
({ |
|
|
accountId, |
|
|
accountId, |
|
|
@ -1065,10 +1068,12 @@ export class ImportService { |
|
|
}) => { |
|
|
}) => { |
|
|
const date = parseISO(dateString); |
|
|
const date = parseISO(dateString); |
|
|
|
|
|
|
|
|
const isDuplicate = existingActivities.some((activity) => { |
|
|
const isDuplicate = |
|
|
|
|
|
existingActivities.some((activity) => { |
|
|
return ( |
|
|
return ( |
|
|
|
|
|
(!accountId || activity.accountId === accountId) && |
|
|
(activity.comment || null) === (comment || null) && |
|
|
(activity.comment || null) === (comment || null) && |
|
|
(activity.currency === currency || |
|
|
((activity.currency || null) === (currency || null) || |
|
|
activity.assetProfile.currency === currency) && |
|
|
activity.assetProfile.currency === currency) && |
|
|
activity.assetProfile.dataSource === dataSource && |
|
|
activity.assetProfile.dataSource === dataSource && |
|
|
isSameSecond(activity.date, date) && |
|
|
isSameSecond(activity.date, date) && |
|
|
@ -1078,13 +1083,27 @@ export class ImportService { |
|
|
activity.type === type && |
|
|
activity.type === type && |
|
|
activity.unitPrice === unitPrice |
|
|
activity.unitPrice === unitPrice |
|
|
); |
|
|
); |
|
|
|
|
|
}) || |
|
|
|
|
|
processedActivities.some((activity) => { |
|
|
|
|
|
return ( |
|
|
|
|
|
(!accountId || activity.accountId === accountId) && |
|
|
|
|
|
(activity.comment || null) === (comment || null) && |
|
|
|
|
|
(activity.currency || null) === (currency || null) && |
|
|
|
|
|
activity.assetProfile.dataSource === dataSource && |
|
|
|
|
|
isSameSecond(activity.date, date) && |
|
|
|
|
|
activity.fee === fee && |
|
|
|
|
|
activity.quantity === quantity && |
|
|
|
|
|
activity.assetProfile.symbol === symbol && |
|
|
|
|
|
activity.type === type && |
|
|
|
|
|
activity.unitPrice === unitPrice |
|
|
|
|
|
); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const error: ActivityError = isDuplicate |
|
|
const error: ActivityError = isDuplicate |
|
|
? { code: 'IS_DUPLICATE' } |
|
|
? { code: 'IS_DUPLICATE' } |
|
|
: undefined; |
|
|
: undefined; |
|
|
|
|
|
|
|
|
return { |
|
|
const activityExtended = { |
|
|
accountId, |
|
|
accountId, |
|
|
comment, |
|
|
comment, |
|
|
currency, |
|
|
currency, |
|
|
@ -1111,6 +1130,12 @@ export class ImportService { |
|
|
}, |
|
|
}, |
|
|
tagIds: tags |
|
|
tagIds: tags |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if (!error) { |
|
|
|
|
|
processedActivities.push(activityExtended); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return activityExtended; |
|
|
} |
|
|
} |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|