Browse Source

Display invalid activity in csv import (#2460)

* Display invalid activity in csv import

* Update changelog
pull/2522/head
Don L 1 year ago
committed by GitHub
parent
commit
ac0ad48a65
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 4
      apps/client/src/app/pages/portfolio/activities/import-activities-dialog/import-activities-dialog.component.ts
  3. 5
      test/import/invalid-multi-line.csv

1
CHANGELOG.md

@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Improved the error message in the activities import for `csv` files
- Allowed to edit today’s historical market data in the asset profile details dialog of the admin control panel
## 2.13.0 - 2023-10-20

4
apps/client/src/app/pages/portfolio/activities/import-activities-dialog/import-activities-dialog.component.ts

@ -267,6 +267,8 @@ export class ImportActivitiesDialog implements OnDestroy {
return;
} else if (file.name.endsWith('.csv')) {
const content = fileContent.split('\n').slice(1);
try {
const data = await this.importActivitiesService.importCsv({
fileContent,
@ -277,7 +279,7 @@ export class ImportActivitiesDialog implements OnDestroy {
} catch (error) {
console.error(error);
this.handleImportError({
activities: error?.activities ?? [],
activities: error?.activities ?? content,
error: {
error: { message: error?.error?.message ?? [error?.message] }
}

5
test/import/invalid-multi-line.csv

@ -0,0 +1,5 @@
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.00
01.01.2022,Penthouse Apartment,USD,500000.0,1,<invalid>,0.00
20500606,MSFT,USD,0.00,0,buy,0.00
Can't render this file because it has a wrong number of fields in line 3.
Loading…
Cancel
Save