Skip to content

Commit

Permalink
Merge pull request #2639 from cozy/fix/imported-accounts-grouping
Browse files Browse the repository at this point in the history
Bank accounts imported via the import service do not have BI
connections and they're all created by the same app (i.e. Banks) so
they get grouped under the first institution in the
Settings > Accounts tab.

To make sure each institution gets its one line with its associated
bank accounts, we force the use of the institution label as a grouping
criteria for accounts imported in this way.

```
### 🐛 Bug Fixes

* Bank accounts imported via the import service are grouped by their institution label in the Settings > Accounts tab

### 🔧 Tech

* Services launched via the CLI use a `CozyClient` instance with  `appMetadata`
```
  • Loading branch information
taratatach authored Mar 29, 2023
2 parents e3768c7 + 1133e92 commit 7d96382
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/ducks/settings/AccountsListSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import { transformJobsToFakeAccounts } from './helpers/jobs'

const { utils } = models

const wasImportedByBanks = account =>
account?.metadata?.dateImport != null && account?.metadata?.vendor === 'cozy'

/**
* Returns the connection id of an account
*
Expand All @@ -34,7 +37,9 @@ const { utils } = models
const getConnectionIdFromAccount = account => {
return account.connection && account.connection.raw
? account.connection.raw._id
: utils.getCreatedByApp(account) || getAccountInstitutionLabel(account)
: wasImportedByBanks(account)
? getAccountInstitutionLabel(account)
: utils.getCreatedByApp(account)
}

const AccountsListSettings = ({
Expand Down
2 changes: 2 additions & 0 deletions src/services/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import path from 'path'
import { ArgumentParser } from 'argparse'
import { createClientInteractive } from 'cozy-client/dist/cli'
import { schema } from 'doctypes'
import appMetadata from 'ducks/client/appMetadata'
import runExportService from '../targets/services/export'
import runImportService from '../targets/services/import'
import runRecurrenceService from '../ducks/recurrence/service'
Expand Down Expand Up @@ -48,6 +49,7 @@ const main = async () => {
uri: args.url,
scope: getScope(manifest),
schema,
appMetadata,
oauth: {
softwareID: 'banks.service-cli'
}
Expand Down

0 comments on commit 7d96382

Please sign in to comment.