Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Relax check for duplicates in activities import (#2704)
Marcin Szymański77b13b88f035
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 2a5a5dc5ba..5c46a0f8b9 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Changed+- Relaxed the check for duplicates in the preview step of the activities import (allow same day)- Respected the `withExcludedAccounts` flag in the account balance time series### Fixed@@ -170,7 +171,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Changed-- Improved the check for duplicates in the preview step of the activities import (allow different accounts)+- Relaxed the check for duplicates in the preview step of the activities import (allow different accounts)- Improved the usability and validation in the cash balance transfer from one to another account- Changed the checkboxes to slide toggles in the overview of the admin control panel- Switched from the deprecated (`PUT`) to the new endpoint (`POST`) to manage historical market data in the asset profile details dialog of the admin control paneldiff --git a/apps/api/src/app/import/import.service.ts b/apps/api/src/app/import/import.service.tsindex eb556421d6..f89c577702 100644--- a/apps/api/src/app/import/import.service.ts+++ b/apps/api/src/app/import/import.service.ts@@ -26,7 +26,7 @@ import {import { Injectable } from '@nestjs/common';import { DataSource, Prisma, SymbolProfile } from '@prisma/client';import Big from 'big.js';-import { endOfToday, format, isAfter, isSameDay, parseISO } from 'date-fns';+import { endOfToday, format, isAfter, isSameSecond, parseISO } from 'date-fns';import { uniqBy } from 'lodash';import { v4 as uuidv4 } from 'uuid';@@ -83,12 +83,13 @@ export class ImportService {const value = new Big(quantity).mul(marketPrice).toNumber();+ const date = parseDate(dateString);const isDuplicate = orders.some((activity) => {return (activity.accountId === Account?.id &&activity.SymbolProfile.currency === assetProfile.currency &&activity.SymbolProfile.dataSource === assetProfile.dataSource &&- isSameDay(activity.date, parseDate(dateString)) &&+ isSameSecond(activity.date, date) &&activity.quantity === quantity &&activity.SymbolProfile.symbol === assetProfile.symbol &&activity.type === 'DIVIDEND' &&@@ -102,6 +103,7 @@ export class ImportService {return {Account,+ date,error,quantity,value,@@ -109,7 +111,6 @@ export class ImportService {accountUserId: undefined,comment: undefined,createdAt: undefined,- date: parseDate(dateString),fee: 0,feeInBaseCurrency: 0,id: assetProfile.id,@@ -482,13 +483,13 @@ export class ImportService {type,unitPrice}) => {- const date = parseISO(<string>(<unknown>dateString));+ const date = parseISO(dateString);const isDuplicate = existingActivities.some((activity) => {return (activity.accountId === accountId &&activity.SymbolProfile.currency === currency &&activity.SymbolProfile.dataSource === dataSource &&- isSameDay(activity.date, date) &&+ isSameSecond(activity.date, date) &&activity.fee === fee &&activity.quantity === quantity &&activity.SymbolProfile.symbol === symbol &&