Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript π€
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Add support for comment in csv import (#2416)
Arshad Jamal25112a450b1b
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 41fa38bc8c..d03655ff8b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Added+- Added support for notes in the activities import- Added the application version to the endpoint `GET api/v1/admin`### Fixeddiff --git a/apps/client/src/app/services/import-activities.service.ts b/apps/client/src/app/services/import-activities.service.tsindex 808081bead..0a58e3cdd6 100644--- a/apps/client/src/app/services/import-activities.service.ts+++ b/apps/client/src/app/services/import-activities.service.ts@@ -15,6 +15,7 @@ import { catchError } from 'rxjs/operators';})export class ImportActivitiesService {private static ACCOUNT_KEYS = ['account', 'accountid'];+ private static COMMENT_KEYS = ['comment', 'note'];private static CURRENCY_KEYS = ['ccy', 'currency', 'currencyprimary'];private static DATA_SOURCE_KEYS = ['datasource'];private static DATE_KEYS = ['date', 'tradedate'];@@ -52,6 +53,7 @@ export class ImportActivitiesService {for (const [index, item] of content.entries()) {activities.push({accountId: this.parseAccount({ item, userAccounts }),+ comment: this.parseComment({ item }),currency: this.parseCurrency({ content, index, item }),dataSource: this.parseDataSource({ item }),date: this.parseDate({ content, index, item }),@@ -122,6 +124,7 @@ export class ImportActivitiesService {private convertToCreateOrderDto({accountId,+ comment,date,fee,quantity,@@ -132,6 +135,7 @@ export class ImportActivitiesService {}: Activity): CreateOrderDto {return {accountId,+ comment,fee,quantity,type,@@ -174,6 +178,18 @@ export class ImportActivitiesService {return undefined;}+ private parseComment({ item }: { item: any }) {+ item = this.lowercaseKeys(item);++ for (const key of ImportActivitiesService.COMMENT_KEYS) {+ if (item[key]) {+ return item[key];+ }+ }++ return undefined;+ }+private parseCurrency({content,index,diff --git a/test/import/ok.csv b/test/import/ok.csvindex 732ab46991..9f1f1c768e 100644--- a/test/import/ok.csv+++ b/test/import/ok.csv@@ -1,5 +1,5 @@-Date,Code,Currency,Price,Quantity,Action,Fee-16-09-2021,MSFT,USD,298.580,5,buy,19.00+Date,Code,Currency,Price,Quantity,Action,Fee,Note+16-09-2021,MSFT,USD,298.580,5,buy,19.00,My first order π€17/11/2021,MSFT,USD,0.62,5,dividend,0.0001.01.2022,Penthouse Apartment,USD,500000.0,1,item,0.0020500606,MSFT,USD,0.00,0,buy,0.00