Skip to content

Commit

Permalink
fix: Import accounts with a normalized number (#2645)
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
taratatach committed Apr 5, 2023
1 parent 15f54af commit f91c78d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/ducks/import/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ const buildAccount = (
vendorAccountId
}
) => {
const number = BankAccount.normalizeAccountNumber(accountNumber, accountIban)

const id = accountId({
institutionLabel,
number: accountNumber,
number,
label: accountName,
type: accountType
})
Expand All @@ -58,7 +60,7 @@ const buildAccount = (
institutionLabel,
label: accountName,
shortLabel: accountCustomName,
number: accountNumber,
number,
originalNumber: accountOriginalNumber,
type: accountType,
currency,
Expand Down

0 comments on commit f91c78d

Please sign in to comment.