Browse Source

Bugfix/fix file type detection for import (#587)

* Fix file type detection ("application/vnd.ms-excel" instead of "text/csv")

* Update changelog
pull/588/head
Thomas Kaul 3 years ago
committed by GitHub
parent
commit
ee397c8047
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      CHANGELOG.md
  2. 7
      apps/client/src/app/pages/portfolio/transactions/transactions-page.component.ts

14
CHANGELOG.md

@ -5,16 +5,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
### Changed
- Upgraded `prisma` from version `3.6.0` to `3.7.0`
### Fixed
- Fixed the file type detection in the import functionality for transactions
## 1.95.0 - 26.12.2021 ## 1.95.0 - 26.12.2021
### Added ### Added
- Added a warning to the log if the data gathering fails - Added a warning to the log if the data gathering fails
### Changed
- Upgraded `prisma` from version `3.6.0` to `3.7.0`
### Fixed ### Fixed
- Filtered potential `null` currencies - Filtered potential `null` currencies

7
apps/client/src/app/pages/portfolio/transactions/transactions-page.component.ts

@ -188,7 +188,7 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {
const fileContent = readerEvent.target.result as string; const fileContent = readerEvent.target.result as string;
try { try {
if (file.type === 'application/json') { if (file.name.endsWith('.json')) {
const content = JSON.parse(fileContent); const content = JSON.parse(fileContent);
if (!isArray(content.orders)) { if (!isArray(content.orders)) {
@ -203,11 +203,12 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {
this.handleImportSuccess(); this.handleImportSuccess();
} catch (error) { } catch (error) {
console.error(error);
this.handleImportError({ error, orders: content.orders }); this.handleImportError({ error, orders: content.orders });
} }
return; return;
} else if (file.type === 'text/csv') { } else if (file.name.endsWith('.csv')) {
try { try {
await this.importTransactionsService.importCsv({ await this.importTransactionsService.importCsv({
fileContent, fileContent,
@ -217,6 +218,7 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {
this.handleImportSuccess(); this.handleImportSuccess();
} catch (error) { } catch (error) {
console.error(error);
this.handleImportError({ this.handleImportError({
error: { error: {
error: { message: error?.error?.message ?? [error?.message] } error: { message: error?.error?.message ?? [error?.message] }
@ -230,6 +232,7 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {
throw new Error(); throw new Error();
} catch (error) { } catch (error) {
console.error(error);
this.handleImportError({ this.handleImportError({
error: { error: { message: ['Unexpected format'] } }, error: { error: { message: ['Unexpected format'] } },
orders: [] orders: []

Loading…
Cancel
Save