From 99ae8e532e54130142a12a2ee7e99b57ce36051c Mon Sep 17 00:00:00 2001 From: Erwan Guyader Date: Wed, 29 Mar 2023 14:44:36 +0200 Subject: [PATCH 1/2] fix: Pass appMetadata to client in services CLI When instantiating a `CozyClient` instance, we should pass an `appMetadata` argument with the app's slug and version so they can be added to the `cozyMetadata` attribute of created/modified documents. This was missing in the services CLI client's intstantiation so documents imported via the import service were missing crucial data used by the app's graphical components. --- src/services/cli.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/services/cli.js b/src/services/cli.js index 18427fffc7..513f4d0bfd 100644 --- a/src/services/cli.js +++ b/src/services/cli.js @@ -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' @@ -48,6 +49,7 @@ const main = async () => { uri: args.url, scope: getScope(manifest), schema, + appMetadata, oauth: { softwareID: 'banks.service-cli' } From 44eae349e95278392567a78f5298b836878f099e Mon Sep 17 00:00:00 2001 From: Erwan Guyader Date: Wed, 29 Mar 2023 14:48:15 +0200 Subject: [PATCH 2/2] fix: Group imported accounts by institution label MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/ducks/settings/AccountsListSettings.jsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ducks/settings/AccountsListSettings.jsx b/src/ducks/settings/AccountsListSettings.jsx index 0d7435a076..31b535827f 100644 --- a/src/ducks/settings/AccountsListSettings.jsx +++ b/src/ducks/settings/AccountsListSettings.jsx @@ -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 * @@ -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 = ({