From 7d342ce703ff35ce7ea4652dad85219a5753702c Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Tue, 30 Jul 2024 12:38:04 +0200 Subject: [PATCH 1/6] map empty entity to top level --- src/languages/en.ts | 1 + .../accounting/PolicyAccountingPage.tsx | 2 +- .../intacct/SageIntacctEntityPage.tsx | 21 ++++++++++++------- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 32b9a9eff2b69..a8ef5452af18c 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2077,6 +2077,7 @@ export default { letsDoubleCheck: "Let's double check that everything looks right.", lineItemLevel: 'Line-item level', reportLevel: 'Report level', + topLevel: 'Top level', appliedOnExport: 'Not imported into Expensify, applied on export', shareNote: { header: 'Easily share your workspace with other members.', diff --git a/src/pages/workspace/accounting/PolicyAccountingPage.tsx b/src/pages/workspace/accounting/PolicyAccountingPage.tsx index 89bbfd75d5389..46a8b53e3fc47 100644 --- a/src/pages/workspace/accounting/PolicyAccountingPage.tsx +++ b/src/pages/workspace/accounting/PolicyAccountingPage.tsx @@ -276,7 +276,7 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) { : { description: translate('workspace.intacct.entity'), iconRight: Expensicons.ArrowRight, - title: getCurrentSageIntacctEntityName(policy), + title: getCurrentSageIntacctEntityName(policy) ?? translate('workspace.common.topLevel'), wrapperStyle: [styles.sectionMenuItemTopDescription], titleStyle: styles.fontWeightNormal, shouldShowRightIcon: true, diff --git a/src/pages/workspace/accounting/intacct/SageIntacctEntityPage.tsx b/src/pages/workspace/accounting/intacct/SageIntacctEntityPage.tsx index abdea52d0df9f..837a9d900cd21 100644 --- a/src/pages/workspace/accounting/intacct/SageIntacctEntityPage.tsx +++ b/src/pages/workspace/accounting/intacct/SageIntacctEntityPage.tsx @@ -2,6 +2,7 @@ import React from 'react'; import RadioListItem from '@components/SelectionList/RadioListItem'; import type {ListItem} from '@components/SelectionList/types'; import SelectionScreen from '@components/SelectionScreen'; +import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import {clearSageIntacctErrorField, updateSageIntacctEntity} from '@libs/actions/connections/SageIntacct'; import * as ErrorUtils from '@libs/ErrorUtils'; @@ -14,22 +15,28 @@ function SageIntacctEntityPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); const config = policy?.connections?.intacct?.config; const entityID = config?.entity ?? ''; + const {translate} = useLocalize(); const policyID = policy?.id ?? '-1'; - const sections = - policy?.connections?.intacct?.data?.entities.map((entity) => ({ + const sections = [ + { + text: translate('workspace.common.topLevel'), + value: translate('workspace.common.topLevel'), + keyForList: '', + isSelected: entityID === '', + }, + ]; + policy?.connections?.intacct?.data?.entities.forEach((entity) => { + sections.push({ text: entity.name, value: entity.name, keyForList: entity.id, isSelected: entity.id === entityID, - })) ?? []; + }); + }); const saveSelection = ({keyForList}: ListItem) => { - if (!keyForList) { - return; - } - updateSageIntacctEntity(policyID, keyForList ?? ''); Navigation.goBack(); }; From 90b3b9df920026aeaf1fdd9934ba591246b8f405 Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Tue, 30 Jul 2024 12:46:10 +0200 Subject: [PATCH 2/6] add intacctImportDimensions translation --- src/languages/en.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index a8ef5452af18c..9272633a2fb04 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -3205,6 +3205,8 @@ export default { return 'Marking NetSuite bills and invoices as paid'; case 'intacctCheckConnection': return 'Checking Sage Intacct connection'; + case 'intacctImportDimensions': + return 'Importing Sage Intacct dimensions'; case 'intacctImportTitle': return 'Importing Sage Intacct data'; default: { From 70d4ae2aebf89fce2c86252759e7ca718d30eb0e Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Tue, 30 Jul 2024 13:06:24 +0200 Subject: [PATCH 3/6] add spanish translation --- src/languages/es.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/languages/es.ts b/src/languages/es.ts index 1636512a6fa49..4b49251b228dd 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2125,6 +2125,7 @@ export default { reuseExistingConnection: 'Reutilizar la conexión existente', existingConnections: 'Conexiones existentes', lastSyncDate: (connectionName: string, formattedDate: string) => `${connectionName} - Última sincronización ${formattedDate}`, + topLevel: 'Nivel superior', }, qbo: { importDescription: 'Elige que configuraciónes de codificación son importadas desde QuickBooks Online a Expensify.', From 6900273fea8a8d0b0faac30c58193b5d9d15c0fd Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Wed, 31 Jul 2024 10:06:49 +0200 Subject: [PATCH 4/6] fix lint --- src/languages/en.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index 9272633a2fb04..c24d33c5b878a 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -3210,6 +3210,7 @@ export default { case 'intacctImportTitle': return 'Importing Sage Intacct data'; default: { + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions return `Translation missing for stage: ${stage}`; } } From 523591eb9aebfe786f80ff3b3570318676447a7c Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Wed, 31 Jul 2024 11:56:36 +0200 Subject: [PATCH 5/6] fix PR comments --- src/libs/PolicyUtils.ts | 5 ++++- src/pages/workspace/accounting/PolicyAccountingPage.tsx | 2 +- .../accounting/intacct/advanced/SageIntacctAdvancedPage.tsx | 2 +- .../accounting/intacct/export/SageIntacctExportPage.tsx | 2 +- .../accounting/intacct/import/SageIntacctImportPage.tsx | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 2f27f01857594..97fd260b07d27 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -756,8 +756,11 @@ function getIntegrationLastSuccessfulDate(connection?: Connections[keyof Connect return (connection as ConnectionWithLastSyncData)?.lastSync?.successfulDate; } -function getCurrentSageIntacctEntityName(policy?: Policy): string | undefined { +function getCurrentSageIntacctEntityName(policy: Policy | undefined, translate: LocaleContextProps['translate']): string | undefined { const currentEntityID = policy?.connections?.intacct?.config?.entity; + if (!currentEntityID) { + return translate('workspace.common.topLevel'); + } const entities = policy?.connections?.intacct?.data?.entities; return entities?.find((entity) => entity.id === currentEntityID)?.name; } diff --git a/src/pages/workspace/accounting/PolicyAccountingPage.tsx b/src/pages/workspace/accounting/PolicyAccountingPage.tsx index 46a8b53e3fc47..79b0a5758ffbd 100644 --- a/src/pages/workspace/accounting/PolicyAccountingPage.tsx +++ b/src/pages/workspace/accounting/PolicyAccountingPage.tsx @@ -276,7 +276,7 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) { : { description: translate('workspace.intacct.entity'), iconRight: Expensicons.ArrowRight, - title: getCurrentSageIntacctEntityName(policy) ?? translate('workspace.common.topLevel'), + title: getCurrentSageIntacctEntityName(policy, translate), wrapperStyle: [styles.sectionMenuItemTopDescription], titleStyle: styles.fontWeightNormal, shouldShowRightIcon: true, diff --git a/src/pages/workspace/accounting/intacct/advanced/SageIntacctAdvancedPage.tsx b/src/pages/workspace/accounting/intacct/advanced/SageIntacctAdvancedPage.tsx index 2458b8579539e..b91791c2ddec6 100644 --- a/src/pages/workspace/accounting/intacct/advanced/SageIntacctAdvancedPage.tsx +++ b/src/pages/workspace/accounting/intacct/advanced/SageIntacctAdvancedPage.tsx @@ -100,7 +100,7 @@ function SageIntacctAdvancedPage({policy}: WithPolicyProps) { Date: Fri, 2 Aug 2024 10:52:17 +0200 Subject: [PATCH 6/6] fix PR comments --- src/libs/PolicyUtils.ts | 4 ++-- src/pages/workspace/accounting/PolicyAccountingPage.tsx | 2 +- .../accounting/intacct/advanced/SageIntacctAdvancedPage.tsx | 2 +- .../accounting/intacct/export/SageIntacctExportPage.tsx | 2 +- .../accounting/intacct/import/SageIntacctImportPage.tsx | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 0cfea5ecb110a..709c10d07f6c3 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -761,10 +761,10 @@ function getIntegrationLastSuccessfulDate(connection?: Connections[keyof Connect return (connection as ConnectionWithLastSyncData)?.lastSync?.successfulDate; } -function getCurrentSageIntacctEntityName(policy: Policy | undefined, translate: LocaleContextProps['translate']): string | undefined { +function getCurrentSageIntacctEntityName(policy: Policy | undefined, defaultNameIfNoEntity: string): string | undefined { const currentEntityID = policy?.connections?.intacct?.config?.entity; if (!currentEntityID) { - return translate('workspace.common.topLevel'); + return defaultNameIfNoEntity; } const entities = policy?.connections?.intacct?.data?.entities; return entities?.find((entity) => entity.id === currentEntityID)?.name; diff --git a/src/pages/workspace/accounting/PolicyAccountingPage.tsx b/src/pages/workspace/accounting/PolicyAccountingPage.tsx index 551846ec92bc4..9202591de7f2b 100644 --- a/src/pages/workspace/accounting/PolicyAccountingPage.tsx +++ b/src/pages/workspace/accounting/PolicyAccountingPage.tsx @@ -303,7 +303,7 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) { : { description: translate('workspace.intacct.entity'), iconRight: Expensicons.ArrowRight, - title: getCurrentSageIntacctEntityName(policy, translate), + title: getCurrentSageIntacctEntityName(policy, translate('workspace.common.topLevel')), wrapperStyle: [styles.sectionMenuItemTopDescription], titleStyle: styles.fontWeightNormal, shouldShowRightIcon: true, diff --git a/src/pages/workspace/accounting/intacct/advanced/SageIntacctAdvancedPage.tsx b/src/pages/workspace/accounting/intacct/advanced/SageIntacctAdvancedPage.tsx index 2afd08eb53f8e..5a0df17fc92c0 100644 --- a/src/pages/workspace/accounting/intacct/advanced/SageIntacctAdvancedPage.tsx +++ b/src/pages/workspace/accounting/intacct/advanced/SageIntacctAdvancedPage.tsx @@ -88,7 +88,7 @@ function SageIntacctAdvancedPage({policy}: WithPolicyProps) {