Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

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

Thomas Kaulee397c8047b4
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 297c488d16..b517252730 100644
--- a/CHANGELOG.md
+++ b/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/),
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
### Added
- Added a warning to the log if the data gathering fails
-### Changed
-
-- Upgraded `prisma` from version `3.6.0` to `3.7.0`
-
### Fixed
- Filtered potential `null` currencies
diff --git a/apps/client/src/app/pages/portfolio/transactions/transactions-page.component.ts b/apps/client/src/app/pages/portfolio/transactions/transactions-page.component.ts
index 1827e156ec..1178c8aea1 100644
--- a/apps/client/src/app/pages/portfolio/transactions/transactions-page.component.ts
+++ b/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;
try {
- if (file.type === 'application/json') {
+ if (file.name.endsWith('.json')) {
const content = JSON.parse(fileContent);
if (!isArray(content.orders)) {
@@ -203,11 +203,12 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {
this.handleImportSuccess();
} catch (error) {
+ console.error(error);
this.handleImportError({ error, orders: content.orders });
}
return;
- } else if (file.type === 'text/csv') {
+ } else if (file.name.endsWith('.csv')) {
try {
await this.importTransactionsService.importCsv({
fileContent,
@@ -217,6 +218,7 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {
this.handleImportSuccess();
} catch (error) {
+ console.error(error);
this.handleImportError({
error: {
error: { message: error?.error?.message ?? [error?.message] }
@@ -230,6 +232,7 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {
throw new Error();
} catch (error) {
+ console.error(error);
this.handleImportError({
error: { error: { message: ['Unexpected format'] } },
orders: []