From a5a1c81eaf69cfaafa3f30c99ab85fb8e0097148 Mon Sep 17 00:00:00 2001
From: Jakub Kuczys <me@jacken.men>
Date: Sun, 12 Mar 2023 22:07:26 +0100
Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20(nordigen)=20fallback=20to=20arr?=
 =?UTF-8?q?ay=20version=20of=20remittanceInformationUnstructured=20if=20ne?=
 =?UTF-8?q?cessary=20(#745)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Try falling back to `remittanceInformationUnstructuredArray.join(', ')`
when neither `debtor/creditorName` nor
`remittanceInformationUnstructured` fields are present.

Addresses a suggestion from
https://github.com/actualbudget/actual/issues/724#issuecomment-1464907064
---
 packages/loot-core/src/server/accounts/sync.js | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/packages/loot-core/src/server/accounts/sync.js b/packages/loot-core/src/server/accounts/sync.js
index 43fd7d1b2..1c1eb7782 100644
--- a/packages/loot-core/src/server/accounts/sync.js
+++ b/packages/loot-core/src/server/accounts/sync.js
@@ -319,7 +319,9 @@ async function normalizeNordigenTransactions(transactions, acctId) {
       const nameParts = [];
       nameParts.push(
         title(
-          trans.debtorName || trans.remittanceInformationUnstructured || '',
+          trans.debtorName ||
+            trans.remittanceInformationUnstructured ||
+            (trans.remittanceInformationUnstructuredArray || []).join(', '),
         ),
       );
       if (trans.debtorAccount && trans.debtorAccount.iban) {
@@ -336,7 +338,9 @@ async function normalizeNordigenTransactions(transactions, acctId) {
       const nameParts = [];
       nameParts.push(
         title(
-          trans.creditorName || trans.remittanceInformationUnstructured || '',
+          trans.creditorName ||
+            trans.remittanceInformationUnstructured ||
+            (trans.remittanceInformationUnstructuredArray || []).join(', '),
         ),
       );
       if (trans.creditorAccount && trans.creditorAccount.iban) {
@@ -369,7 +373,9 @@ async function normalizeNordigenTransactions(transactions, acctId) {
         payee: trans.payee,
         account: trans.account,
         date: trans.date,
-        notes: trans.remittanceInformationUnstructured,
+        notes:
+          trans.remittanceInformationUnstructured ||
+          (trans.remittanceInformationUnstructuredArray || []).join(', '),
         imported_id: trans.transactionId,
         imported_payee: trans.imported_payee,
       },
-- 
GitLab