From 7b42a0ca35111fd85e7365794521af601cdc0965 Mon Sep 17 00:00:00 2001 From: Thomas <4159106+dtslvr@users.noreply.github.com> Date: Sun, 12 Dec 2021 21:47:51 +0100 Subject: [PATCH] Check currency in import validation Avoid importing transactions in wrong currency --- apps/api/src/app/import/import.service.ts | 6 ++++++ test/import/invalid-currency.csv | 2 ++ 2 files changed, 8 insertions(+) create mode 100644 test/import/invalid-currency.csv diff --git a/apps/api/src/app/import/import.service.ts b/apps/api/src/app/import/import.service.ts index cf9f6f705..b17404ae9 100644 --- a/apps/api/src/app/import/import.service.ts +++ b/apps/api/src/app/import/import.service.ts @@ -104,6 +104,12 @@ export class ImportService { `orders.${index}.symbol ("${symbol}") is not valid for the specified data source ("${dataSource}")` ); } + + if (result[symbol].currency !== currency) { + throw new Error( + `orders.${index}.currency ("${currency}") does not match with "${result[symbol].currency}"` + ); + } } } } diff --git a/test/import/invalid-currency.csv b/test/import/invalid-currency.csv new file mode 100644 index 000000000..e04db317b --- /dev/null +++ b/test/import/invalid-currency.csv @@ -0,0 +1,2 @@ +Date,Code,Currency,Price,Quantity,Action,Fee +12/12/2021,BTC,EUR,44558.42,1,buy,0