Skip to content

A local-first personal finance app

3211: Fix broken transaction import on new accounts (#3251)

Eirik Rekstenee0156d35d35
diff --git a/packages/desktop-client/src/components/modals/ImportTransactions.jsx b/packages/desktop-client/src/components/modals/ImportTransactions.jsx
index 8f93405e6c..4307792645 100644
--- a/packages/desktop-client/src/components/modals/ImportTransactions.jsx
+++ b/packages/desktop-client/src/components/modals/ImportTransactions.jsx
@@ -186,14 +186,20 @@ function getInitialMappings(transactions) {
return entry ? entry[0] : null;
}
+ function isString(value) {
+ return typeof value === 'string' || value instanceof String;
+ }
+
const dateField = key(
fields.find(([name]) => name.toLowerCase().includes('date')) ||
- fields.find(([, value]) => value.match(/^\d+[-/]\d+[-/]\d+$/)),
+ fields.find(
+ ([, value]) => isString(value) && value.match(/^\d+[-/]\d+[-/]\d+$/),
+ ),
);
const amountField = key(
fields.find(([name]) => name.toLowerCase().includes('amount')) ||
- fields.find(([, value]) => value.match(/^-?[.,\d]+$/)),
+ fields.find(([, value]) => isString(value) && value.match(/^-?[.,\d]+$/)),
);
const categoryField = key(
diff --git a/upcoming-release-notes/3251.md b/upcoming-release-notes/3251.md
new file mode 100644
index 0000000000..3799716329
--- /dev/null
+++ b/upcoming-release-notes/3251.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [eireksten]
+---
+
+Fix issue with importing transactions failing on new accounts (issue #3211).