|
@ -26,14 +26,7 @@ import { |
|
|
import { Injectable } from '@nestjs/common'; |
|
|
import { Injectable } from '@nestjs/common'; |
|
|
import { DataSource, Prisma, SymbolProfile } from '@prisma/client'; |
|
|
import { DataSource, Prisma, SymbolProfile } from '@prisma/client'; |
|
|
import Big from 'big.js'; |
|
|
import Big from 'big.js'; |
|
|
import { |
|
|
import { endOfToday, format, isAfter, isSameSecond, parseISO } from 'date-fns'; |
|
|
endOfToday, |
|
|
|
|
|
format, |
|
|
|
|
|
isAfter, |
|
|
|
|
|
isSameDay, |
|
|
|
|
|
isSameSecond, |
|
|
|
|
|
parseISO |
|
|
|
|
|
} from 'date-fns'; |
|
|
|
|
|
import { uniqBy } from 'lodash'; |
|
|
import { uniqBy } from 'lodash'; |
|
|
import { v4 as uuidv4 } from 'uuid'; |
|
|
import { v4 as uuidv4 } from 'uuid'; |
|
|
|
|
|
|
|
@ -90,12 +83,13 @@ export class ImportService { |
|
|
|
|
|
|
|
|
const value = new Big(quantity).mul(marketPrice).toNumber(); |
|
|
const value = new Big(quantity).mul(marketPrice).toNumber(); |
|
|
|
|
|
|
|
|
|
|
|
const date = parseDate(dateString); |
|
|
const isDuplicate = orders.some((activity) => { |
|
|
const isDuplicate = orders.some((activity) => { |
|
|
return ( |
|
|
return ( |
|
|
activity.accountId === Account?.id && |
|
|
activity.accountId === Account?.id && |
|
|
activity.SymbolProfile.currency === assetProfile.currency && |
|
|
activity.SymbolProfile.currency === assetProfile.currency && |
|
|
activity.SymbolProfile.dataSource === assetProfile.dataSource && |
|
|
activity.SymbolProfile.dataSource === assetProfile.dataSource && |
|
|
isSameDay(activity.date, parseDate(dateString)) && |
|
|
isSameSecond(activity.date, date) && |
|
|
activity.quantity === quantity && |
|
|
activity.quantity === quantity && |
|
|
activity.SymbolProfile.symbol === assetProfile.symbol && |
|
|
activity.SymbolProfile.symbol === assetProfile.symbol && |
|
|
activity.type === 'DIVIDEND' && |
|
|
activity.type === 'DIVIDEND' && |
|
@ -109,6 +103,7 @@ export class ImportService { |
|
|
|
|
|
|
|
|
return { |
|
|
return { |
|
|
Account, |
|
|
Account, |
|
|
|
|
|
date, |
|
|
error, |
|
|
error, |
|
|
quantity, |
|
|
quantity, |
|
|
value, |
|
|
value, |
|
@ -116,7 +111,6 @@ export class ImportService { |
|
|
accountUserId: undefined, |
|
|
accountUserId: undefined, |
|
|
comment: undefined, |
|
|
comment: undefined, |
|
|
createdAt: undefined, |
|
|
createdAt: undefined, |
|
|
date: parseDate(dateString), |
|
|
|
|
|
fee: 0, |
|
|
fee: 0, |
|
|
feeInBaseCurrency: 0, |
|
|
feeInBaseCurrency: 0, |
|
|
id: assetProfile.id, |
|
|
id: assetProfile.id, |
|
@ -489,7 +483,7 @@ export class ImportService { |
|
|
type, |
|
|
type, |
|
|
unitPrice |
|
|
unitPrice |
|
|
}) => { |
|
|
}) => { |
|
|
const date = parseISO(<string>(<unknown>dateString)); |
|
|
const date = parseISO(dateString); |
|
|
const isDuplicate = existingActivities.some((activity) => { |
|
|
const isDuplicate = existingActivities.some((activity) => { |
|
|
return ( |
|
|
return ( |
|
|
activity.accountId === accountId && |
|
|
activity.accountId === accountId && |
|
|