Skip to content

Commit

Permalink
Merge pull request #2640 from cozy/fix/imported-accounts-grouping
Browse files Browse the repository at this point in the history
Backport of #2639

```
### 🐛 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 e5717c6 + 44eae34 commit 1af5b65
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 1af5b65

Please sign in to comment.