From f91c78d531288415bb41f5e339807e4847a430e4 Mon Sep 17 00:00:00 2001 From: Erwan Guyader Date: Wed, 5 Apr 2023 09:41:04 +0200 Subject: [PATCH] fix: Import accounts with a normalized number (#2645) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the import service, we need to index accounts (imported and existing) so we can associate them with transactions. We used the account number as key but saved accounts numbers are normalized by `cozy-doctype`'s `BankAccount.reconciliate()` function and are not necessarily equal to the originally imported number. To prevent these differences and make sure accounts are found in the index, we'll use the normalized form from the very beginning. ``` ### 🐛 Bug Fixes * Import accounts with a normalized number ``` --- src/ducks/import/services.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ducks/import/services.js b/src/ducks/import/services.js index 2dc9dc7a87..17a5516946 100644 --- a/src/ducks/import/services.js +++ b/src/ducks/import/services.js @@ -45,9 +45,11 @@ const buildAccount = ( vendorAccountId } ) => { + const number = BankAccount.normalizeAccountNumber(accountNumber, accountIban) + const id = accountId({ institutionLabel, - number: accountNumber, + number, label: accountName, type: accountType }) @@ -58,7 +60,7 @@ const buildAccount = ( institutionLabel, label: accountName, shortLabel: accountCustomName, - number: accountNumber, + number, originalNumber: accountOriginalNumber, type: accountType, currency,