From 81565b6ff864cf46068fc88d1ba817f114101aad Mon Sep 17 00:00:00 2001 From: war-in Date: Fri, 14 Jun 2024 14:45:58 +0200 Subject: [PATCH 01/50] sage intacct export page --- src/CONST.ts | 1 + src/ROUTES.ts | 8 ++ src/SCREENS.ts | 2 + src/languages/en.ts | 24 +++++ .../ModalStackNavigators/index.tsx | 3 + .../FULL_SCREEN_TO_RHP_MAPPING.ts | 2 + src/libs/Navigation/linkingConfig/config.ts | 2 + src/libs/Navigation/types.ts | 6 ++ .../accounting/PolicyAccountingPage.tsx | 17 ++++ .../intacct/export/SageIntacctExportPage.tsx | 89 +++++++++++++++++++ 10 files changed, 154 insertions(+) create mode 100644 src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx diff --git a/src/CONST.ts b/src/CONST.ts index 6a936bc97087..b32bedf1235b 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1786,6 +1786,7 @@ const CONST = { // Here we will add other connections names when we add support for them QBO: 'quickbooksOnline', XERO: 'xero', + SAGE_INTACCT: 'intacct', }, SYNC_STAGE_NAME: { STARTING_IMPORT_QBO: 'startingImportQBO', diff --git a/src/ROUTES.ts b/src/ROUTES.ts index eb3b439ea1ff..5c9a18702acb 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -905,6 +905,14 @@ const ROUTES = { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/import/taxes', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/import/taxes` as const, }, + POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT: { + route: 'settings/workspaces/:policyID/accounting/sage-intacct/export', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/sage-intacct/export` as const, + }, + POLICY_ACCOUNTING_SAGE_INTACCT_PREFERRED_EXPORTER: { + route: 'settings/workspaces/:policyID/connections/sage-intacct/export/preferred-exporter', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/sage-intacct/export/preferred-exporter` as const, + }, } as const; /** diff --git a/src/SCREENS.ts b/src/SCREENS.ts index f884cca94ef5..af07c29bdfbc 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -263,6 +263,8 @@ const SCREENS = { XERO_EXPORT_PREFERRED_EXPORTER_SELECT: 'Workspace_Accounting_Xero_Export_Preferred_Exporter_Select', XERO_BILL_PAYMENT_ACCOUNT_SELECTOR: 'Policy_Accounting_Xero_Bill_Payment_Account_Selector', XERO_EXPORT_BANK_ACCOUNT_SELECT: 'Policy_Accounting_Xero_Export_Bank_Account_Select', + SAGE_INTACCT_EXPORT: 'Policy_Accounting_Sage_Intacct_Export', + SAGE_INTACCT_PREFERRED_EXPORTER: 'Policy_Accounting_Sage_Intacct_Preferred_Exporter', }, INITIAL: 'Workspace_Initial', PROFILE: 'Workspace_Profile', diff --git a/src/languages/en.ts b/src/languages/en.ts index 1d3f495369d9..97252dbdf7f1 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2174,6 +2174,17 @@ export default { noAccountsFound: 'No accounts found', noAccountsFoundDescription: 'Add the account in Xero and sync the connection again', }, + sageIntacct: { + preferredExporter: 'Preferred exporter', + notConfigured: 'Not configured', + exportDate: 'Date', + exportDescription: 'Configure how data in Expensify gets exported to Sage Inacct.', + exportReimbursableExpensesAs: 'Export reimbursable expenses as', + exportNonReimbursableExpensesAs: 'Export non-reimbursable expenses as', + exportPreferredExporterNote: + 'The preferred exporter can be any workspace admin, but must also be a Domain Admin if you set different export accounts for individual company cards in Domain Settings.', + exportPreferredExporterSubNote: 'Once set, the preferred exporter will see reports for export in their account.', + }, type: { free: 'Free', control: 'Control', @@ -2394,6 +2405,19 @@ export default { subtitle: 'Connect to your accounting system to code transactions with your chart of accounts, auto-match payments, and keep your finances in sync.', qbo: 'Quickbooks Online', xero: 'Xero', + intacct: 'Sage Intacct', + integrationName: (integration?: ConnectionName): string => { + switch (integration) { + case CONST.POLICY.CONNECTIONS.NAME.QBO: + return 'Quickbooks Online'; + case CONST.POLICY.CONNECTIONS.NAME.XERO: + return 'Xero'; + case CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT: + return 'Sage Intacct'; + default: + return 'Integration'; + } + }, setup: 'Connect', lastSync: 'Last synced just now', import: 'Import', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 0577fdcfc5aa..dc9be18ea41c 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -317,6 +317,9 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/xero/advanced/XeroBillPaymentAccountSelectorPage').default as React.ComponentType, + [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_EXPORT]: () => require('../../../../pages/workspace/accounting/intacct/export/SageIntacctExportPage').default as React.ComponentType, + [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREFERRED_EXPORTER]: () => + require('../../../../pages/workspace/accounting/intacct/export/SageIntacctPreferredExporter').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_FREQUENCY]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingMonthlyOffsetPage').default as React.ComponentType, diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index f91d290639ff..f790bb335afa 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -54,6 +54,8 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.ACCOUNTING.XERO_EXPORT_PREFERRED_EXPORTER_SELECT, SCREENS.WORKSPACE.ACCOUNTING.XERO_BILL_PAYMENT_ACCOUNT_SELECTOR, SCREENS.WORKSPACE.ACCOUNTING.XERO_EXPORT_BANK_ACCOUNT_SELECT, + SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_EXPORT, + SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREFERRED_EXPORTER, ], [SCREENS.WORKSPACE.TAXES]: [ SCREENS.WORKSPACE.TAXES_SETTINGS, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 07dd45701029..7fddfbcdcd20 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -334,6 +334,8 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.ACCOUNTING.XERO_INVOICE_ACCOUNT_SELECTOR]: {path: ROUTES.POLICY_ACCOUNTING_XERO_INVOICE_SELECTOR.route}, [SCREENS.WORKSPACE.ACCOUNTING.XERO_EXPORT_PREFERRED_EXPORTER_SELECT]: {path: ROUTES.POLICY_ACCOUNTING_XERO_PREFERRED_EXPORTER_SELECT.route}, [SCREENS.WORKSPACE.ACCOUNTING.XERO_BILL_PAYMENT_ACCOUNT_SELECTOR]: {path: ROUTES.POLICY_ACCOUNTING_XERO_BILL_PAYMENT_ACCOUNT_SELECTOR.route}, + [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_EXPORT]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.route}, + [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREFERRED_EXPORTER]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_PREFERRED_EXPORTER.route}, [SCREENS.WORKSPACE.DESCRIPTION]: { path: ROUTES.WORKSPACE_PROFILE_DESCRIPTION.route, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index e87f0380a2da..a7d096ba5e93 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -381,6 +381,12 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.ACCOUNTING.XERO_BILL_PAYMENT_ACCOUNT_SELECTOR]: { policyID: string; }; + [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_EXPORT]: { + policyID: string; + }; + [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREFERRED_EXPORTER]: { + policyID: string; + }; [SCREENS.GET_ASSISTANCE]: { backTo: Routes; }; diff --git a/src/pages/workspace/accounting/PolicyAccountingPage.tsx b/src/pages/workspace/accounting/PolicyAccountingPage.tsx index 78dc434b3d2c..e27925e1d9be 100644 --- a/src/pages/workspace/accounting/PolicyAccountingPage.tsx +++ b/src/pages/workspace/accounting/PolicyAccountingPage.tsx @@ -100,6 +100,23 @@ function accountingIntegrationData( onExportPagePress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_EXPORT.getRoute(policyID)), onAdvancedPagePress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_ADVANCED.getRoute(policyID)), }; + case CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT: + return { + title: translate('workspace.accounting.intacct'), + icon: Expensicons.XeroSquare, + setupConnectionButton: ( + + ), + onImportPagePress: () => { + console.log('dupa'); + }, + onExportPagePress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID)), + onAdvancedPagePress: () => {}, + }; default: return undefined; } diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx new file mode 100644 index 000000000000..b5bdb254dda8 --- /dev/null +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx @@ -0,0 +1,89 @@ +import React, {useMemo} from 'react'; +import ConnectionLayout from '@components/ConnectionLayout'; +import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; +import OfflineWithFeedback from '@components/OfflineWithFeedback'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import Navigation from '@libs/Navigation/Navigation'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; + +function SageIntacctExportPage({policy}: WithPolicyProps) { + const {translate} = useLocalize(); + const styles = useThemeStyles(); + const policyID = policy?.id ?? '-1'; + + const {export: exportConfig, pendingFields, errorFields, credentials} = policy?.connections?.intacct?.config ?? {}; + + const currentSageIntacctOrganizationName = credentials.companyID; + + const sections = useMemo( + () => [ + { + description: translate('workspace.sageIntacct.preferredExporter'), + action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_PREFERRED_EXPORTER.getRoute(policyID)), + title: exportConfig.exporter || translate('workspace.sageIntacct.notConfigured'), + hasError: !!errorFields?.export.exporter, + pendingAction: pendingFields?.export.exporter, + }, + { + description: translate('workspace.sageIntacct.exportDate'), + action: () => {}, + title: translate('workspace.sageIntacct.exportDate'), + hasError: !!errorFields?.export.exportDate, + pendingAction: pendingFields?.export.exportDate, + }, + { + description: translate('workspace.sageIntacct.exportReimbursableExpensesAs'), + action: () => {}, + title: exportConfig.reimbursable ? 'reimbursable' : translate('workspace.sageIntacct.notConfigured'), + hasError: !!errorFields?.export.reimbursable, + pendingAction: pendingFields?.export.reimbursable, + }, + { + description: translate('workspace.sageIntacct.exportNonReimbursableExpensesAs'), + action: () => {}, + title: exportConfig.nonReimbursable ? 'nonreimbursable' : translate('workspace.sageIntacct.notConfigured'), + hasError: !!errorFields?.export.nonReimbursable, + pendingAction: pendingFields?.export.nonReimbursable, + }, + ], + [], + ); + + return ( + + {sections.map((section) => ( + + + + ))} + + ); +} + +SageIntacctExportPage.displayName = 'PolicySageIntacctExportPage'; + +export default withPolicyConnections(SageIntacctExportPage); From 8c7466097f26add29c50c1c04310712ce6ece76e Mon Sep 17 00:00:00 2001 From: war-in Date: Fri, 14 Jun 2024 15:12:07 +0200 Subject: [PATCH 02/50] add preferred exporter page --- .../ModalStackNavigators/index.tsx | 2 +- .../intacct/export/SageIntacctExportPage.tsx | 2 +- .../SageIntacctPreferredExporterPage.tsx | 106 ++++++++++++++++++ 3 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index dc9be18ea41c..ed2b8b78817b 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -319,7 +319,7 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/intacct/export/SageIntacctExportPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREFERRED_EXPORTER]: () => - require('../../../../pages/workspace/accounting/intacct/export/SageIntacctPreferredExporter').default as React.ComponentType, + require('@pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_FREQUENCY]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingMonthlyOffsetPage').default as React.ComponentType, diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx index b5bdb254dda8..53bd36816294 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx @@ -50,7 +50,7 @@ function SageIntacctExportPage({policy}: WithPolicyProps) { pendingAction: pendingFields?.export.nonReimbursable, }, ], - [], + [errorFields, exportConfig, pendingFields, policyID, translate], ); return ( diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx new file mode 100644 index 000000000000..2b217d08486f --- /dev/null +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx @@ -0,0 +1,106 @@ +import {isEmpty} from 'lodash'; +import React, {useCallback, useMemo} from 'react'; +import {View} from 'react-native'; +import RadioListItem from '@components/SelectionList/RadioListItem'; +import type {ListItem} from '@components/SelectionList/types'; +import SelectionScreen from '@components/SelectionScreen'; +import Text from '@components/Text'; +import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import * as Connections from '@libs/actions/connections'; +import {getAdminEmployees, isExpensifyTeam} from '@libs/PolicyUtils'; +import Navigation from '@navigation/Navigation'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; + +type CardListItem = ListItem & { + value: string; +}; + +function SageIntacctPreferredExporterPage({policy}: WithPolicyProps) { + const {export: exportConfiguration} = policy?.connections?.intacct?.config ?? {}; + const {translate} = useLocalize(); + const styles = useThemeStyles(); + const policyOwner = policy?.owner ?? ''; + const exporters = getAdminEmployees(policy); + const {login: currentUserLogin} = useCurrentUserPersonalDetails(); + + const policyID = policy?.id ?? '-1'; + const data: CardListItem[] = useMemo(() => { + if (!isEmpty(policyOwner) && isEmpty(exporters)) { + return [ + { + value: policyOwner, + text: policyOwner, + keyForList: policyOwner, + isSelected: true, + }, + ]; + } + + console.log(exporters); + + return exporters?.reduce((options, exporter) => { + if (!exporter.email) { + return options; + } + + // Don't show guides if the current user is not a guide themselves or an Expensify employee + if (isExpensifyTeam(exporter.email) && !isExpensifyTeam(policyOwner) && !isExpensifyTeam(currentUserLogin)) { + return options; + } + + options.push({ + value: exporter.email, + text: exporter.email, + keyForList: exporter.email, + isSelected: exportConfiguration?.exporter === exporter.email, + }); + return options; + }, []); + }, [exportConfiguration, exporters, policyOwner, currentUserLogin]); + + const selectExporter = useCallback( + (row: CardListItem) => { + if (row.value !== exportConfiguration?.exporter) { + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, {exporter: row.value}); + } + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_EXPORT.getRoute(policyID)); + }, + [policyID, exportConfiguration], + ); + + const headerContent = useMemo( + () => ( + + {translate('workspace.sageIntacct.exportPreferredExporterNote')} + {translate('workspace.sageIntacct.exportPreferredExporterSubNote')} + + ), + [translate, styles.pb2, styles.ph5, styles.pb5, styles.textNormal], + ); + + return ( + mode.isSelected)?.keyForList} + onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID))} + title="workspace.sageIntacct.preferredExporter" + connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} + /> + ); +} + +SageIntacctPreferredExporterPage.displayName = 'PolicySageIntacctPreferredExporterPage'; + +export default withPolicyConnections(SageIntacctPreferredExporterPage); From 1e92f34b449271d5aacb5c8b007862eede676872 Mon Sep 17 00:00:00 2001 From: war-in Date: Fri, 14 Jun 2024 15:55:55 +0200 Subject: [PATCH 03/50] add export date page --- src/CONST.ts | 6 ++ src/ROUTES.ts | 4 + src/SCREENS.ts | 1 + src/languages/en.ts | 19 ++++- .../ModalStackNavigators/index.tsx | 1 + .../FULL_SCREEN_TO_RHP_MAPPING.ts | 1 + src/libs/Navigation/linkingConfig/config.ts | 1 + src/libs/Navigation/types.ts | 3 + .../intacct/export/SageIntacctDatePage.tsx | 76 +++++++++++++++++++ .../intacct/export/SageIntacctExportPage.tsx | 22 +++--- 10 files changed, 122 insertions(+), 12 deletions(-) create mode 100644 src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx diff --git a/src/CONST.ts b/src/CONST.ts index b32bedf1235b..99901ea6a76f 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1345,6 +1345,12 @@ const CONST = { REPORT_SUBMITTED: 'REPORT_SUBMITTED', }, + SAGE_INTACCT_EXPORT_DATE: { + LAST_EXPENSE: 'LAST_EXPENSE', + REPORT_EXPORTED: 'REPORT_EXPORTED', + REPORT_SUBMITTED: 'REPORT_SUBMITTED', + }, + QUICKBOOKS_EXPORT_DATE: { LAST_EXPENSE: 'LAST_EXPENSE', REPORT_EXPORTED: 'REPORT_EXPORTED', diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 5c9a18702acb..ea7b32ff3d81 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -913,6 +913,10 @@ const ROUTES = { route: 'settings/workspaces/:policyID/connections/sage-intacct/export/preferred-exporter', getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/sage-intacct/export/preferred-exporter` as const, }, + POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT_DATE: { + route: 'settings/workspaces/:policyID/connections/sage-intacct/export/date', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/sage-intacct/export/date` as const, + }, } as const; /** diff --git a/src/SCREENS.ts b/src/SCREENS.ts index af07c29bdfbc..72b89d23eb54 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -265,6 +265,7 @@ const SCREENS = { XERO_EXPORT_BANK_ACCOUNT_SELECT: 'Policy_Accounting_Xero_Export_Bank_Account_Select', SAGE_INTACCT_EXPORT: 'Policy_Accounting_Sage_Intacct_Export', SAGE_INTACCT_PREFERRED_EXPORTER: 'Policy_Accounting_Sage_Intacct_Preferred_Exporter', + SAGE_INTACCT_EXPORT_DATE: 'Policy_Accounting_Sage_Intacct_Export_Date', }, INITIAL: 'Workspace_Initial', PROFILE: 'Workspace_Profile', diff --git a/src/languages/en.ts b/src/languages/en.ts index 97252dbdf7f1..5781fea2c881 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2177,7 +2177,24 @@ export default { sageIntacct: { preferredExporter: 'Preferred exporter', notConfigured: 'Not configured', - exportDate: 'Date', + exportDate: { + label: 'Export date', + description: 'Use this date when exporting reports to Sage Intacct.', + values: { + [CONST.SAGE_INTACCT_EXPORT_DATE.LAST_EXPENSE]: { + label: 'Date of last expense', + description: 'Date of the most recent expense on the report.', + }, + [CONST.SAGE_INTACCT_EXPORT_DATE.REPORT_EXPORTED]: { + label: 'Export date', + description: 'Date the report was exported to Sage Intacct.', + }, + [CONST.SAGE_INTACCT_EXPORT_DATE.REPORT_SUBMITTED]: { + label: 'Submitted date', + description: 'Date the report was submitted for approval.', + }, + }, + }, exportDescription: 'Configure how data in Expensify gets exported to Sage Inacct.', exportReimbursableExpensesAs: 'Export reimbursable expenses as', exportNonReimbursableExpensesAs: 'Export non-reimbursable expenses as', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index ed2b8b78817b..59af1add8a10 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -320,6 +320,7 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/intacct/export/SageIntacctExportPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREFERRED_EXPORTER]: () => require('@pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage').default as React.ComponentType, + [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_EXPORT_DATE]: () => require('@pages/workspace/accounting/intacct/export/SageIntacctDatePage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_FREQUENCY]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingMonthlyOffsetPage').default as React.ComponentType, diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index f790bb335afa..a7e5a90eddfc 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -56,6 +56,7 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.ACCOUNTING.XERO_EXPORT_BANK_ACCOUNT_SELECT, SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_EXPORT, SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREFERRED_EXPORTER, + SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_EXPORT_DATE, ], [SCREENS.WORKSPACE.TAXES]: [ SCREENS.WORKSPACE.TAXES_SETTINGS, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 7fddfbcdcd20..cadc948149d4 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -336,6 +336,7 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.ACCOUNTING.XERO_BILL_PAYMENT_ACCOUNT_SELECTOR]: {path: ROUTES.POLICY_ACCOUNTING_XERO_BILL_PAYMENT_ACCOUNT_SELECTOR.route}, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_EXPORT]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.route}, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREFERRED_EXPORTER]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_PREFERRED_EXPORTER.route}, + [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_EXPORT_DATE]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT_DATE.route}, [SCREENS.WORKSPACE.DESCRIPTION]: { path: ROUTES.WORKSPACE_PROFILE_DESCRIPTION.route, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index a7d096ba5e93..c237829e270c 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -387,6 +387,9 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREFERRED_EXPORTER]: { policyID: string; }; + [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_EXPORT_DATE]: { + policyID: string; + }; [SCREENS.GET_ASSISTANCE]: { backTo: Routes; }; diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx new file mode 100644 index 000000000000..931449c020e8 --- /dev/null +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx @@ -0,0 +1,76 @@ +import {isEmpty} from 'lodash'; +import React, {useCallback, useMemo} from 'react'; +import {View} from 'react-native'; +import type {ValueOf} from 'type-fest'; +import RadioListItem from '@components/SelectionList/RadioListItem'; +import type {ListItem} from '@components/SelectionList/types'; +import SelectionScreen, {type SelectorType} from '@components/SelectionScreen'; +import Text from '@components/Text'; +import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import * as Connections from '@libs/actions/connections'; +import {getAdminEmployees, isExpensifyTeam} from '@libs/PolicyUtils'; +import Navigation from '@navigation/Navigation'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; + +type MenuListItem = ListItem & { + value: ValueOf; +}; + +function SageIntacctDatePage({policy}: WithPolicyProps) { + const {translate} = useLocalize(); + const policyID = policy?.id ?? '-1'; + const styles = useThemeStyles(); + const {date} = policy?.connections?.intacct?.config?.export ?? {}; + const data: MenuListItem[] = Object.values(CONST.SAGE_INTACCT_EXPORT_DATE).map((dateType) => ({ + value: dateType, + text: translate(`workspace.sageIntacct.exportDate.values.${dateType}.label`), + alternateText: translate(`workspace.sageIntacct.exportDate.values.${dateType}.description`), + keyForList: dateType, + isSelected: date === dateType, + })); + + const headerContent = useMemo( + () => ( + + {translate('workspace.sageIntacct.exportDate.description')} + + ), + [translate, styles.pb5, styles.ph5], + ); + + const selectExportDate = useCallback( + (row: MenuListItem) => { + if (row.value !== date) { + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, {date: row.value}); + } + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_EXPORT_PURCHASE_BILL_DATE_SELECT.getRoute(policyID)); + }, + [date, policyID], + ); + + return ( + selectExportDate(selection as MenuListItem)} + initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} + policyID={policyID} + accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]} + featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} + onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID))} + connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} + /> + ); +} + +SageIntacctDatePage.displayName = 'PolicySageIntacctDatePage'; + +export default withPolicyConnections(SageIntacctDatePage); diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx index 53bd36816294..3ee615eb15f7 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx @@ -25,29 +25,29 @@ function SageIntacctExportPage({policy}: WithPolicyProps) { description: translate('workspace.sageIntacct.preferredExporter'), action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_PREFERRED_EXPORTER.getRoute(policyID)), title: exportConfig.exporter || translate('workspace.sageIntacct.notConfigured'), - hasError: !!errorFields?.export.exporter, - pendingAction: pendingFields?.export.exporter, + hasError: !!errorFields?.exporter, + pendingAction: pendingFields?.export, }, { - description: translate('workspace.sageIntacct.exportDate'), - action: () => {}, - title: translate('workspace.sageIntacct.exportDate'), - hasError: !!errorFields?.export.exportDate, - pendingAction: pendingFields?.export.exportDate, + description: translate('workspace.sageIntacct.exportDate.label'), + action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT_DATE.getRoute(policyID)), + title: exportConfig.date ? translate(`workspace.sageIntacct.exportDate.values.${exportConfig.date}.label`) : translate(`workspace.sageIntacct.notConfigured`), + hasError: !!errorFields?.exportDate, + pendingAction: pendingFields?.export, }, { description: translate('workspace.sageIntacct.exportReimbursableExpensesAs'), action: () => {}, title: exportConfig.reimbursable ? 'reimbursable' : translate('workspace.sageIntacct.notConfigured'), - hasError: !!errorFields?.export.reimbursable, - pendingAction: pendingFields?.export.reimbursable, + hasError: !!errorFields?.reimbursable, + pendingAction: pendingFields?.export, }, { description: translate('workspace.sageIntacct.exportNonReimbursableExpensesAs'), action: () => {}, title: exportConfig.nonReimbursable ? 'nonreimbursable' : translate('workspace.sageIntacct.notConfigured'), - hasError: !!errorFields?.export.nonReimbursable, - pendingAction: pendingFields?.export.nonReimbursable, + hasError: !!errorFields?.nonReimbursable, + pendingAction: pendingFields?.export, }, ], [errorFields, exportConfig, pendingFields, policyID, translate], From 4f9b8a0d76e6da14c7591a7d4f236652d7bbb047 Mon Sep 17 00:00:00 2001 From: war-in Date: Fri, 14 Jun 2024 16:07:03 +0200 Subject: [PATCH 04/50] cleaning --- src/pages/workspace/accounting/PolicyAccountingPage.tsx | 4 +--- .../accounting/intacct/export/SageIntacctDatePage.tsx | 6 ++---- .../intacct/export/SageIntacctPreferredExporterPage.tsx | 2 -- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/pages/workspace/accounting/PolicyAccountingPage.tsx b/src/pages/workspace/accounting/PolicyAccountingPage.tsx index e27925e1d9be..0395928c52ad 100644 --- a/src/pages/workspace/accounting/PolicyAccountingPage.tsx +++ b/src/pages/workspace/accounting/PolicyAccountingPage.tsx @@ -111,9 +111,7 @@ function accountingIntegrationData( integrationToDisconnect={integrationToDisconnect} /> ), - onImportPagePress: () => { - console.log('dupa'); - }, + onImportPagePress: () => {}, onExportPagePress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID)), onAdvancedPagePress: () => {}, }; diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx index 931449c020e8..e96d18e1457c 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx @@ -1,16 +1,14 @@ -import {isEmpty} from 'lodash'; import React, {useCallback, useMemo} from 'react'; import {View} from 'react-native'; import type {ValueOf} from 'type-fest'; import RadioListItem from '@components/SelectionList/RadioListItem'; import type {ListItem} from '@components/SelectionList/types'; -import SelectionScreen, {type SelectorType} from '@components/SelectionScreen'; +import SelectionScreen from '@components/SelectionScreen'; +import type {SelectorType} from '@components/SelectionScreen'; import Text from '@components/Text'; -import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import * as Connections from '@libs/actions/connections'; -import {getAdminEmployees, isExpensifyTeam} from '@libs/PolicyUtils'; import Navigation from '@navigation/Navigation'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx index 2b217d08486f..4a306df6b380 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx @@ -41,8 +41,6 @@ function SageIntacctPreferredExporterPage({policy}: WithPolicyProps) { ]; } - console.log(exporters); - return exporters?.reduce((options, exporter) => { if (!exporter.email) { return options; From 1fa9639c05a13f769fa8ed033cfb54457beef34f Mon Sep 17 00:00:00 2001 From: war-in Date: Mon, 17 Jun 2024 10:50:08 +0200 Subject: [PATCH 05/50] rename onyx field `date` to `exportDate` --- .../accounting/intacct/export/SageIntacctDatePage.tsx | 10 +++++----- .../intacct/export/SageIntacctExportPage.tsx | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx index e96d18e1457c..13e76bf0ee67 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx @@ -23,13 +23,13 @@ function SageIntacctDatePage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const policyID = policy?.id ?? '-1'; const styles = useThemeStyles(); - const {date} = policy?.connections?.intacct?.config?.export ?? {}; + const {exportDate} = policy?.connections?.intacct?.config?.export ?? {}; const data: MenuListItem[] = Object.values(CONST.SAGE_INTACCT_EXPORT_DATE).map((dateType) => ({ value: dateType, text: translate(`workspace.sageIntacct.exportDate.values.${dateType}.label`), alternateText: translate(`workspace.sageIntacct.exportDate.values.${dateType}.description`), keyForList: dateType, - isSelected: date === dateType, + isSelected: exportDate === dateType, })); const headerContent = useMemo( @@ -43,12 +43,12 @@ function SageIntacctDatePage({policy}: WithPolicyProps) { const selectExportDate = useCallback( (row: MenuListItem) => { - if (row.value !== date) { - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, {date: row.value}); + if (row.value !== exportDate) { + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, {exportDate: row.value}); } Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_EXPORT_PURCHASE_BILL_DATE_SELECT.getRoute(policyID)); }, - [date, policyID], + [exportDate, policyID], ); return ( diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx index 3ee615eb15f7..4f35e478da0e 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx @@ -31,7 +31,7 @@ function SageIntacctExportPage({policy}: WithPolicyProps) { { description: translate('workspace.sageIntacct.exportDate.label'), action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT_DATE.getRoute(policyID)), - title: exportConfig.date ? translate(`workspace.sageIntacct.exportDate.values.${exportConfig.date}.label`) : translate(`workspace.sageIntacct.notConfigured`), + title: exportConfig.exportDate ? translate(`workspace.sageIntacct.exportDate.values.${exportConfig.exportDate}.label`) : translate(`workspace.sageIntacct.notConfigured`), hasError: !!errorFields?.exportDate, pendingAction: pendingFields?.export, }, From 5579f167dff142121873f4f01086420183891e1d Mon Sep 17 00:00:00 2001 From: war-in Date: Mon, 17 Jun 2024 11:46:12 +0200 Subject: [PATCH 06/50] add reimbursable expenses page --- src/CONST.ts | 5 ++ src/ROUTES.ts | 4 + src/SCREENS.ts | 1 + src/languages/en.ts | 9 ++- .../ModalStackNavigators/index.tsx | 2 + .../FULL_SCREEN_TO_RHP_MAPPING.ts | 1 + src/libs/Navigation/linkingConfig/config.ts | 1 + src/libs/Navigation/types.ts | 3 + .../intacct/export/SageIntacctDatePage.tsx | 2 +- .../intacct/export/SageIntacctExportPage.tsx | 8 +- .../SageIntacctReimbursableExpensesPage.tsx | 74 +++++++++++++++++++ 11 files changed, 105 insertions(+), 5 deletions(-) create mode 100644 src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx diff --git a/src/CONST.ts b/src/CONST.ts index 99901ea6a76f..71862773ac7c 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1339,6 +1339,11 @@ const CONST = { JOURNAL_ENTRY: 'journal_entry', }, + SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE: { + EXPENSE_REPORT: 'EXPENSE_REPORT', + VENDOR_BILL: 'VENDOR_BILL', + }, + XERO_EXPORT_DATE: { LAST_EXPENSE: 'LAST_EXPENSE', REPORT_EXPORTED: 'REPORT_EXPORTED', diff --git a/src/ROUTES.ts b/src/ROUTES.ts index ea7b32ff3d81..6b255b652551 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -917,6 +917,10 @@ const ROUTES = { route: 'settings/workspaces/:policyID/connections/sage-intacct/export/date', getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/sage-intacct/export/date` as const, }, + POLICY_ACCOUNTING_SAGE_INTACCT_REIMBURSABLE_EXPENSES: { + route: 'settings/workspaces/:policyID/connections/sage-intacct/export/reimbursable', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/sage-intacct/export/reimbursable` as const, + }, } as const; /** diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 72b89d23eb54..810d1b4ad185 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -266,6 +266,7 @@ const SCREENS = { SAGE_INTACCT_EXPORT: 'Policy_Accounting_Sage_Intacct_Export', SAGE_INTACCT_PREFERRED_EXPORTER: 'Policy_Accounting_Sage_Intacct_Preferred_Exporter', SAGE_INTACCT_EXPORT_DATE: 'Policy_Accounting_Sage_Intacct_Export_Date', + SAGE_INTACCT_REIMBURSABLE_EXPENSES: 'Policy_Accounting_Sage_Intacct_Reimbursable_Expenses', }, INITIAL: 'Workspace_Initial', PROFILE: 'Workspace_Profile', diff --git a/src/languages/en.ts b/src/languages/en.ts index 5781fea2c881..e980791d4598 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2195,8 +2195,15 @@ export default { }, }, }, + reimbursableExpenses: { + label: 'Export reimbursable expenses as', + description: 'Reimbursable expenses will export as expense reports to Sage Intacct. Bills will export as vendor bills.', + values: { + [CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE.EXPENSE_REPORT]: 'Expense reports', + [CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL]: 'Vendor bills', + }, + }, exportDescription: 'Configure how data in Expensify gets exported to Sage Inacct.', - exportReimbursableExpensesAs: 'Export reimbursable expenses as', exportNonReimbursableExpensesAs: 'Export non-reimbursable expenses as', exportPreferredExporterNote: 'The preferred exporter can be any workspace admin, but must also be a Domain Admin if you set different export accounts for individual company cards in Domain Settings.', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 59af1add8a10..21d717906b1a 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -321,6 +321,8 @@ const SettingsModalStackNavigator = createModalStackNavigator require('@pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_EXPORT_DATE]: () => require('@pages/workspace/accounting/intacct/export/SageIntacctDatePage').default as React.ComponentType, + [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_REIMBURSABLE_EXPENSES]: () => + require('@pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_FREQUENCY]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingMonthlyOffsetPage').default as React.ComponentType, diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index a7e5a90eddfc..7e38b2f617d5 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -57,6 +57,7 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_EXPORT, SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREFERRED_EXPORTER, SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_EXPORT_DATE, + SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_REIMBURSABLE_EXPENSES, ], [SCREENS.WORKSPACE.TAXES]: [ SCREENS.WORKSPACE.TAXES_SETTINGS, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index cadc948149d4..2b77590c363d 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -337,6 +337,7 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_EXPORT]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.route}, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREFERRED_EXPORTER]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_PREFERRED_EXPORTER.route}, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_EXPORT_DATE]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT_DATE.route}, + [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_REIMBURSABLE_EXPENSES]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_REIMBURSABLE_EXPENSES.route}, [SCREENS.WORKSPACE.DESCRIPTION]: { path: ROUTES.WORKSPACE_PROFILE_DESCRIPTION.route, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index c237829e270c..8e64273e7867 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -390,6 +390,9 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_EXPORT_DATE]: { policyID: string; }; + [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_REIMBURSABLE_EXPENSES]: { + policyID: string; + }; [SCREENS.GET_ASSISTANCE]: { backTo: Routes; }; diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx index 13e76bf0ee67..1c3889de2986 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx @@ -46,7 +46,7 @@ function SageIntacctDatePage({policy}: WithPolicyProps) { if (row.value !== exportDate) { Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, {exportDate: row.value}); } - Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_EXPORT_PURCHASE_BILL_DATE_SELECT.getRoute(policyID)); + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID)); }, [exportDate, policyID], ); diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx index 4f35e478da0e..9e5a6305b27b 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx @@ -36,9 +36,11 @@ function SageIntacctExportPage({policy}: WithPolicyProps) { pendingAction: pendingFields?.export, }, { - description: translate('workspace.sageIntacct.exportReimbursableExpensesAs'), - action: () => {}, - title: exportConfig.reimbursable ? 'reimbursable' : translate('workspace.sageIntacct.notConfigured'), + description: translate('workspace.sageIntacct.reimbursableExpenses.label'), + action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_REIMBURSABLE_EXPENSES.getRoute(policyID)), + title: exportConfig.reimbursable + ? translate(`workspace.sageIntacct.reimbursableExpenses.values.${exportConfig.reimbursable}`) + : translate('workspace.sageIntacct.notConfigured'), hasError: !!errorFields?.reimbursable, pendingAction: pendingFields?.export, }, diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx new file mode 100644 index 000000000000..d792c4a58b3b --- /dev/null +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx @@ -0,0 +1,74 @@ +import React, {useCallback, useMemo} from 'react'; +import {View} from 'react-native'; +import type {ValueOf} from 'type-fest'; +import RadioListItem from '@components/SelectionList/RadioListItem'; +import type {ListItem} from '@components/SelectionList/types'; +import SelectionScreen from '@components/SelectionScreen'; +import type {SelectorType} from '@components/SelectionScreen'; +import Text from '@components/Text'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import * as Connections from '@libs/actions/connections'; +import Navigation from '@navigation/Navigation'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; + +type MenuListItem = ListItem & { + value: ValueOf; +}; + +function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { + const {translate} = useLocalize(); + const policyID = policy?.id ?? '-1'; + const styles = useThemeStyles(); + const {reimbursable} = policy?.connections?.intacct?.config?.export ?? {}; + const data: MenuListItem[] = Object.values(CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE).map((expenseType) => ({ + value: expenseType, + text: translate(`workspace.sageIntacct.reimbursableExpenses.values.${expenseType}`), + keyForList: expenseType, + isSelected: reimbursable === expenseType, + })); + + const headerContent = useMemo( + () => ( + + {translate('workspace.sageIntacct.reimbursableExpenses.description')} + + ), + [translate, styles.pb5, styles.ph5], + ); + + const selectExportDate = useCallback( + (row: MenuListItem) => { + if (row.value !== reimbursable) { + // TODO: change CONST.XERO_CONFIG.EXPORT to CONST.SAGE_INTACCT.EXPORT + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, {reimbursable: row.value}); + } + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID)); + }, + [reimbursable, policyID], + ); + + return ( + selectExportDate(selection as MenuListItem)} + initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} + policyID={policyID} + accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]} + featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} + onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID))} + connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} + /> + ); +} + +SageIntacctReimbursableExpensesPage.displayName = 'PolicySageIntacctReimbursableExpensesPage'; + +export default withPolicyConnections(SageIntacctReimbursableExpensesPage); From 647013bb98bbe066f47b49e55d8399cbcf1290f2 Mon Sep 17 00:00:00 2001 From: war-in Date: Mon, 17 Jun 2024 15:55:45 +0200 Subject: [PATCH 07/50] add non-reimbursable page and default vendor subpage --- src/CONST.ts | 5 + src/ROUTES.ts | 8 + src/SCREENS.ts | 2 + src/languages/en.ts | 13 +- .../ModalStackNavigators/index.tsx | 4 + .../FULL_SCREEN_TO_RHP_MAPPING.ts | 2 + src/libs/Navigation/linkingConfig/config.ts | 2 + src/libs/Navigation/types.ts | 6 + src/libs/PolicyUtils.ts | 24 +++ .../intacct/export/SageIntacctExportPage.tsx | 8 +- ...ntacctNonReimbursableDefaultVendorPage.tsx | 99 ++++++++++++ ...SageIntacctNonReimbursableExpensesPage.tsx | 149 ++++++++++++++++++ 12 files changed, 318 insertions(+), 4 deletions(-) create mode 100644 src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableDefaultVendorPage.tsx create mode 100644 src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx diff --git a/src/CONST.ts b/src/CONST.ts index 71862773ac7c..176e850d42c5 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1344,6 +1344,11 @@ const CONST = { VENDOR_BILL: 'VENDOR_BILL', }, + SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE: { + CREDIT_CARD_CHARGE: 'CREDIT_CARD_CHARGE', + VENDOR_BILL: 'VENDOR_BILL', + }, + XERO_EXPORT_DATE: { LAST_EXPENSE: 'LAST_EXPENSE', REPORT_EXPORTED: 'REPORT_EXPORTED', diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 6b255b652551..48c1ab4a94fd 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -921,6 +921,14 @@ const ROUTES = { route: 'settings/workspaces/:policyID/connections/sage-intacct/export/reimbursable', getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/sage-intacct/export/reimbursable` as const, }, + POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES: { + route: 'settings/workspaces/:policyID/connections/sage-intacct/export/non-reimbursable', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/sage-intacct/export/non-reimbursable` as const, + }, + POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_DEFAULT_VENDOR: { + route: 'settings/workspaces/:policyID/connections/sage-intacct/export/non-reimbursable/default-vendor', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/sage-intacct/export/non-reimbursable/default-vendor` as const, + }, } as const; /** diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 810d1b4ad185..bd1e755fd4b5 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -267,6 +267,8 @@ const SCREENS = { SAGE_INTACCT_PREFERRED_EXPORTER: 'Policy_Accounting_Sage_Intacct_Preferred_Exporter', SAGE_INTACCT_EXPORT_DATE: 'Policy_Accounting_Sage_Intacct_Export_Date', SAGE_INTACCT_REIMBURSABLE_EXPENSES: 'Policy_Accounting_Sage_Intacct_Reimbursable_Expenses', + SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES: 'Policy_Accounting_Sage_Intacct_Non_Reimbursable_Expenses', + SAGE_INTACCT_NON_REIMBURSABLE_DEFAULT_VENDOR: 'Policy_Accounting_Sage_Intacct_Non_Reimbursable_Default_Vendor', }, INITIAL: 'Workspace_Initial', PROFILE: 'Workspace_Profile', diff --git a/src/languages/en.ts b/src/languages/en.ts index e980791d4598..78f5290da0ec 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2203,8 +2203,19 @@ export default { [CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL]: 'Vendor bills', }, }, + nonReimbursableExpenses: { + label: 'Export non-reimbursable expenses as', + description: + 'Non-reimbursable expenses will export to Sage Intacct as either credit card transactions or vendor bills and credit the account selected below. Learn more about assigning cards to individual accounts.', + values: { + [CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE]: 'Credit card transactions', + [CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL]: 'Vendor bills', + }, + }, + creditCardAccount: 'Credit card account', + defaultVendor: 'Default vendor', + defaultVendorDescription: "Set a default vendor that will apply to nonreimbursable expenses that don't have a matching vendor in Sage Intacct.", exportDescription: 'Configure how data in Expensify gets exported to Sage Inacct.', - exportNonReimbursableExpensesAs: 'Export non-reimbursable expenses as', exportPreferredExporterNote: 'The preferred exporter can be any workspace admin, but must also be a Domain Admin if you set different export accounts for individual company cards in Domain Settings.', exportPreferredExporterSubNote: 'Once set, the preferred exporter will see reports for export in their account.', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 21d717906b1a..3afc189cd4b4 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -323,6 +323,10 @@ const SettingsModalStackNavigator = createModalStackNavigator require('@pages/workspace/accounting/intacct/export/SageIntacctDatePage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_REIMBURSABLE_EXPENSES]: () => require('@pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage').default as React.ComponentType, + [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES]: () => + require('@pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage').default as React.ComponentType, + [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_DEFAULT_VENDOR]: () => + require('@pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableDefaultVendorPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_FREQUENCY]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingMonthlyOffsetPage').default as React.ComponentType, diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index 7e38b2f617d5..6a7da321d52f 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -58,6 +58,8 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREFERRED_EXPORTER, SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_EXPORT_DATE, SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_REIMBURSABLE_EXPENSES, + SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES, + SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_DEFAULT_VENDOR, ], [SCREENS.WORKSPACE.TAXES]: [ SCREENS.WORKSPACE.TAXES_SETTINGS, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 2b77590c363d..b268128429cb 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -338,6 +338,8 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREFERRED_EXPORTER]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_PREFERRED_EXPORTER.route}, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_EXPORT_DATE]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT_DATE.route}, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_REIMBURSABLE_EXPENSES]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_REIMBURSABLE_EXPENSES.route}, + [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.route}, + [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_DEFAULT_VENDOR]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_DEFAULT_VENDOR.route}, [SCREENS.WORKSPACE.DESCRIPTION]: { path: ROUTES.WORKSPACE_PROFILE_DESCRIPTION.route, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 8e64273e7867..0e5e59a0efa4 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -393,6 +393,12 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_REIMBURSABLE_EXPENSES]: { policyID: string; }; + [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES]: { + policyID: string; + }; + [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_DEFAULT_VENDOR]: { + policyID: string; + }; [SCREENS.GET_ASSISTANCE]: { backTo: Routes; }; diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index af3f3b264d13..a5c1813d36e2 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -461,6 +461,28 @@ function getXeroBankAccountsWithDefaultSelect(policy: Policy | undefined, select })); } +function getSageIntacctVendors(policy: Policy | undefined, selectedVendorId: string | undefined): SelectorType[] { + const vendors = policy?.connections?.intacct?.data?.vendors ?? []; + const isMatchFound = vendors?.some(({id}) => id === selectedVendorId); + + return (vendors ?? []).map(({id, name, value}, index) => ({ + value: id, + text: value, + keyForList: id, + isSelected: isMatchFound && selectedVendorId === id, + })); +} + +function getSageIntacctActiveDefaultVendor(policy: Policy | undefined): string { + const { + nonReimbursableCreditCardChargeDefaultVendor: creditCardDefaultVendor, + nonReimbursableExpenseReportDefaultVendor: expenseReportDefaultVendor, + nonReimbursable, + } = policy?.connections?.intacct?.config.export ?? {}; + + return nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE ? creditCardDefaultVendor : expenseReportDefaultVendor; +} + /** * Sort the workspaces by their name, while keeping the selected one at the beginning. * @param workspace1 Details of the first workspace to be compared. @@ -546,6 +568,8 @@ export { findCurrentXeroOrganization, getCurrentXeroOrganizationName, getXeroBankAccountsWithDefaultSelect, + getSageIntacctVendors, + getSageIntacctActiveDefaultVendor, getCustomUnit, getCustomUnitRate, sortWorkspacesBySelected, diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx index 9e5a6305b27b..f61ca69a205a 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx @@ -45,9 +45,11 @@ function SageIntacctExportPage({policy}: WithPolicyProps) { pendingAction: pendingFields?.export, }, { - description: translate('workspace.sageIntacct.exportNonReimbursableExpensesAs'), - action: () => {}, - title: exportConfig.nonReimbursable ? 'nonreimbursable' : translate('workspace.sageIntacct.notConfigured'), + description: translate('workspace.sageIntacct.nonReimbursableExpenses.label'), + action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID)), + title: exportConfig.nonReimbursable + ? translate(`workspace.sageIntacct.nonReimbursableExpenses.values.${exportConfig.nonReimbursable}`) + : translate('workspace.sageIntacct.notConfigured'), hasError: !!errorFields?.nonReimbursable, pendingAction: pendingFields?.export, }, diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableDefaultVendorPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableDefaultVendorPage.tsx new file mode 100644 index 000000000000..3c98ad60271a --- /dev/null +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableDefaultVendorPage.tsx @@ -0,0 +1,99 @@ +import {de} from 'date-fns/locale'; +import React, {useCallback, useMemo} from 'react'; +import {View} from 'react-native'; +import BlockingView from '@components/BlockingViews/BlockingView'; +import * as Illustrations from '@components/Icon/Illustrations'; +import RadioListItem from '@components/SelectionList/RadioListItem'; +import type {SelectorType} from '@components/SelectionScreen'; +import SelectionScreen from '@components/SelectionScreen'; +import Text from '@components/Text'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import * as Connections from '@libs/actions/connections'; +import Navigation from '@libs/Navigation/Navigation'; +import {getSageIntacctActiveDefaultVendor, getSageIntacctVendors} from '@libs/PolicyUtils'; +import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import variables from '@styles/variables'; +import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; + +function SageIntacctNonReimbursableDefaultVendorPage({policy}: WithPolicyConnectionsProps) { + const styles = useThemeStyles(); + const {translate} = useLocalize(); + + const policyID = policy?.id ?? '-1'; + + const { + nonReimbursableCreditCardChargeDefaultVendor: creditCardDefaultVendor, + nonReimbursableExpenseReportDefaultVendor: expenseReportDefaultVendor, + nonReimbursable, + } = policy?.connections?.intacct?.config.export ?? {}; + + const activeDefaultVendor = getSageIntacctActiveDefaultVendor(policy); + + const vendorSelectorOptions = useMemo(() => getSageIntacctVendors(policy ?? undefined, activeDefaultVendor), [activeDefaultVendor, policy]); + + const listHeaderComponent = useMemo( + () => ( + + {translate('workspace.sageIntacct.defaultVendorDescription')} + + ), + [translate, styles.pb2, styles.ph5, styles.pb5, styles.textNormal], + ); + + const updateDefaultVendor = useCallback( + ({value}: SelectorType) => { + if (value !== activeDefaultVendor) { + Connections.updatePolicyConnectionConfig( + policyID, + CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, + CONST.XERO_CONFIG.EXPORT, + nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE + ? { + nonReimbursableCreditCardChargeDefaultVendor: value, + } + : {nonReimbursableExpenseReportDefaultVendor: value}, + ); + } + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID)); + }, + [policyID], + ); + + const listEmptyContent = useMemo( + () => ( + + ), + [translate, styles.pb10], + ); + + return ( + mode.isSelected)?.keyForList} + headerContent={listHeaderComponent} + onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID))} + title="workspace.sageIntacct.defaultVendor" + listEmptyContent={listEmptyContent} + connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} + /> + ); +} + +SageIntacctNonReimbursableDefaultVendorPage.displayName = 'PolicySageIntacctNonReimbursableDefaultVendorPage'; + +export default withPolicyConnections(SageIntacctNonReimbursableDefaultVendorPage); diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx new file mode 100644 index 000000000000..77fd6e3da9e0 --- /dev/null +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx @@ -0,0 +1,149 @@ +import React, {useCallback, useMemo, useState} from 'react'; +import {View} from 'react-native'; +import type {ValueOf} from 'type-fest'; +import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; +import OfflineWithFeedback from '@components/OfflineWithFeedback'; +import RadioListItem from '@components/SelectionList/RadioListItem'; +import type {ListItem} from '@components/SelectionList/types'; +import SelectionScreen from '@components/SelectionScreen'; +import type {SelectorType} from '@components/SelectionScreen'; +import Text from '@components/Text'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import * as Connections from '@libs/actions/connections'; +import {getSageIntacctActiveDefaultVendor} from '@libs/PolicyUtils'; +import Navigation from '@navigation/Navigation'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; +import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; + +type MenuListItem = ListItem & { + value: ValueOf; +}; + +function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { + const {translate} = useLocalize(); + const policyID = policy?.id ?? '-1'; + const styles = useThemeStyles(); + const { + data: intacctData, + config: {export: exportConfig, pendingFields, errorFields}, + } = policy?.connections?.intacct ?? {}; + + const [isSwitchOn, setIsSwitchOn] = useState(!!exportConfig.nonReimbursableCreditCardChargeDefaultVendor); + + const data: MenuListItem[] = Object.values(CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE).map((expenseType) => ({ + value: expenseType, + text: translate(`workspace.sageIntacct.nonReimbursableExpenses.values.${expenseType}`), + keyForList: expenseType, + isSelected: exportConfig.nonReimbursable === expenseType, + })); + + const headerContent = useMemo( + () => ( + + {translate('workspace.sageIntacct.nonReimbursableExpenses.description')} + + ), + [translate, styles.pb5, styles.ph5], + ); + + const selectExportDate = useCallback( + (row: MenuListItem) => { + if (row.value !== exportConfig.nonReimbursable) { + // TODO: change CONST.XERO_CONFIG.EXPORT to CONST.SAGE_INTACCT.EXPORT + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, {nonReimbursable: row.value}); + } + }, + [exportConfig.nonReimbursable, policyID], + ); + + const activeDefaultVendor = getSageIntacctActiveDefaultVendor(policy); + const defaultVendorSection = { + description: translate('workspace.sageIntacct.defaultVendor'), + action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_DEFAULT_VENDOR.getRoute(policyID)), + title: activeDefaultVendor ? intacctData.vendors.find((vendor) => vendor.id === activeDefaultVendor).value : translate('workspace.sageIntacct.notConfigured'), + hasError: !!errorFields?.exporter, + pendingAction: pendingFields?.export, + }; + + const defaultVendor = ( + + + + ); + + const creditCardAccountSection = { + description: translate('workspace.sageIntacct.creditCardAccount'), + action: () => {}, + title: exportConfig.nonReimbursableAccount ? exportConfig.nonReimbursableAccount : translate('workspace.sageIntacct.notConfigured'), + hasError: !!errorFields?.exporter, + pendingAction: pendingFields?.export, + }; + + return ( + + selectExportDate(selection as MenuListItem)} + initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} + policyID={policyID} + accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]} + featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} + onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID))} + connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} + /> + {exportConfig.nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL && defaultVendor} + {exportConfig.nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE && ( + + + + + { + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, { + nonReimbursableCreditCardChargeDefaultVendor: null, + }); + setIsSwitchOn(!isSwitchOn); + }} + wrapperStyle={styles.ph5} + /> + {isSwitchOn && defaultVendor} + + )} + + ); +} + +SageIntacctNonReimbursableExpensesPage.displayName = 'PolicySageIntacctNonReimbursableExpensesPage'; + +export default withPolicyConnections(SageIntacctNonReimbursableExpensesPage); From 3c24cb3450f8d0fb8efb0029f798e4deb7610eb4 Mon Sep 17 00:00:00 2001 From: war-in Date: Mon, 17 Jun 2024 17:16:32 +0200 Subject: [PATCH 08/50] add credit card selection screen to non-reimbursable page --- src/ROUTES.ts | 4 + src/SCREENS.ts | 1 + src/languages/en.ts | 1 + .../ModalStackNavigators/index.tsx | 2 + .../FULL_SCREEN_TO_RHP_MAPPING.ts | 1 + src/libs/Navigation/linkingConfig/config.ts | 3 + src/libs/Navigation/types.ts | 3 + src/libs/PolicyUtils.ts | 17 +++- ...ctNonReimbursableCreditCardAccountPage.tsx | 85 +++++++++++++++++++ ...ntacctNonReimbursableDefaultVendorPage.tsx | 9 +- ...SageIntacctNonReimbursableExpensesPage.tsx | 15 ++-- 11 files changed, 126 insertions(+), 15 deletions(-) create mode 100644 src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 48c1ab4a94fd..30b17385f333 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -929,6 +929,10 @@ const ROUTES = { route: 'settings/workspaces/:policyID/connections/sage-intacct/export/non-reimbursable/default-vendor', getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/sage-intacct/export/non-reimbursable/default-vendor` as const, }, + POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT: { + route: 'settings/workspaces/:policyID/connections/sage-intacct/export/non-reimbursable/credit-card-account', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/sage-intacct/export/non-reimbursable/credit-card-account` as const, + }, } as const; /** diff --git a/src/SCREENS.ts b/src/SCREENS.ts index bd1e755fd4b5..05c8c0689b58 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -269,6 +269,7 @@ const SCREENS = { SAGE_INTACCT_REIMBURSABLE_EXPENSES: 'Policy_Accounting_Sage_Intacct_Reimbursable_Expenses', SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES: 'Policy_Accounting_Sage_Intacct_Non_Reimbursable_Expenses', SAGE_INTACCT_NON_REIMBURSABLE_DEFAULT_VENDOR: 'Policy_Accounting_Sage_Intacct_Non_Reimbursable_Default_Vendor', + SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT: 'Policy_Accounting_Sage_Intacct_Non_Reimbursable_Credit_Card_Account', }, INITIAL: 'Workspace_Initial', PROFILE: 'Workspace_Profile', diff --git a/src/languages/en.ts b/src/languages/en.ts index 78f5290da0ec..1711423952ff 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2213,6 +2213,7 @@ export default { }, }, creditCardAccount: 'Credit card account', + creditCardAccountDescription: 'We should have some description here, right?', defaultVendor: 'Default vendor', defaultVendorDescription: "Set a default vendor that will apply to nonreimbursable expenses that don't have a matching vendor in Sage Intacct.", exportDescription: 'Configure how data in Expensify gets exported to Sage Inacct.', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 3afc189cd4b4..a2547a572fae 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -327,6 +327,8 @@ const SettingsModalStackNavigator = createModalStackNavigator require('@pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableDefaultVendorPage').default as React.ComponentType, + [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT]: () => + require('@pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_FREQUENCY]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingMonthlyOffsetPage').default as React.ComponentType, diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index 6a7da321d52f..2c4294e24c7f 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -60,6 +60,7 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_REIMBURSABLE_EXPENSES, SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES, SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_DEFAULT_VENDOR, + SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT, ], [SCREENS.WORKSPACE.TAXES]: [ SCREENS.WORKSPACE.TAXES_SETTINGS, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index b268128429cb..4bb91b7b3a4b 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -340,6 +340,9 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_REIMBURSABLE_EXPENSES]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_REIMBURSABLE_EXPENSES.route}, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.route}, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_DEFAULT_VENDOR]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_DEFAULT_VENDOR.route}, + [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT]: { + path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT.route, + }, [SCREENS.WORKSPACE.DESCRIPTION]: { path: ROUTES.WORKSPACE_PROFILE_DESCRIPTION.route, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 0e5e59a0efa4..eab8c39ed863 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -399,6 +399,9 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_DEFAULT_VENDOR]: { policyID: string; }; + [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT]: { + policyID: string; + }; [SCREENS.GET_ASSISTANCE]: { backTo: Routes; }; diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index a5c1813d36e2..4753658d59af 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -465,7 +465,7 @@ function getSageIntacctVendors(policy: Policy | undefined, selectedVendorId: str const vendors = policy?.connections?.intacct?.data?.vendors ?? []; const isMatchFound = vendors?.some(({id}) => id === selectedVendorId); - return (vendors ?? []).map(({id, name, value}, index) => ({ + return (vendors ?? []).map(({id, value}) => ({ value: id, text: value, keyForList: id, @@ -473,7 +473,7 @@ function getSageIntacctVendors(policy: Policy | undefined, selectedVendorId: str })); } -function getSageIntacctActiveDefaultVendor(policy: Policy | undefined): string { +function getSageIntacctActiveDefaultVendor(policy: Policy | undefined): string | null { const { nonReimbursableCreditCardChargeDefaultVendor: creditCardDefaultVendor, nonReimbursableExpenseReportDefaultVendor: expenseReportDefaultVendor, @@ -483,6 +483,18 @@ function getSageIntacctActiveDefaultVendor(policy: Policy | undefined): string { return nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE ? creditCardDefaultVendor : expenseReportDefaultVendor; } +function getSageIntacctCreditCards(policy: Policy | undefined, selectedAccountId: string | undefined): SelectorType[] { + const creditCards = policy?.connections?.intacct?.data?.creditCards ?? []; + const isMatchFound = creditCards?.some(({id}) => id === selectedAccountId); + + return (creditCards ?? []).map(({id, name}) => ({ + value: id, + text: name, + keyForList: id, + isSelected: isMatchFound && selectedAccountId === id, + })); +} + /** * Sort the workspaces by their name, while keeping the selected one at the beginning. * @param workspace1 Details of the first workspace to be compared. @@ -570,6 +582,7 @@ export { getXeroBankAccountsWithDefaultSelect, getSageIntacctVendors, getSageIntacctActiveDefaultVendor, + getSageIntacctCreditCards, getCustomUnit, getCustomUnitRate, sortWorkspacesBySelected, diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx new file mode 100644 index 000000000000..1cfe89219a9f --- /dev/null +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx @@ -0,0 +1,85 @@ +import React, {useCallback, useMemo} from 'react'; +import {View} from 'react-native'; +import BlockingView from '@components/BlockingViews/BlockingView'; +import * as Illustrations from '@components/Icon/Illustrations'; +import RadioListItem from '@components/SelectionList/RadioListItem'; +import type {SelectorType} from '@components/SelectionScreen'; +import SelectionScreen from '@components/SelectionScreen'; +import Text from '@components/Text'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import * as Connections from '@libs/actions/connections'; +import Navigation from '@libs/Navigation/Navigation'; +import {getSageIntacctCreditCards} from '@libs/PolicyUtils'; +import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import variables from '@styles/variables'; +import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; + +function SageIntacctNonReimbursableCreditCardAccountPage({policy}: WithPolicyConnectionsProps) { + const styles = useThemeStyles(); + const {translate} = useLocalize(); + + const policyID = policy?.id ?? '-1'; + + const {nonReimbursableAccount} = policy?.connections?.intacct?.config.export ?? {}; + + const vendorSelectorOptions = useMemo(() => getSageIntacctCreditCards(policy, nonReimbursableAccount), [nonReimbursableAccount, policy]); + + const listHeaderComponent = useMemo( + () => ( + + {translate('workspace.sageIntacct.creditCardAccountDescription')} + + ), + [translate, styles.pb2, styles.ph5, styles.pb5, styles.textNormal], + ); + + const updateDefaultVendor = useCallback( + ({value}: SelectorType) => { + if (value !== nonReimbursableAccount) { + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, { + nonReimbursableAccount: value, + }); + } + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID)); + }, + [policyID, nonReimbursableAccount], + ); + + const listEmptyContent = useMemo( + () => ( + + ), + [translate, styles.pb10], + ); + + return ( + mode.isSelected)?.keyForList} + headerContent={listHeaderComponent} + onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID))} + title="workspace.sageIntacct.creditCardAccount" + listEmptyContent={listEmptyContent} + connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} + /> + ); +} + +SageIntacctNonReimbursableCreditCardAccountPage.displayName = 'PolicySageIntacctNonReimbursableCreditCardAccountPage'; + +export default withPolicyConnections(SageIntacctNonReimbursableCreditCardAccountPage); diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableDefaultVendorPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableDefaultVendorPage.tsx index 3c98ad60271a..db45e7f96d8e 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableDefaultVendorPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableDefaultVendorPage.tsx @@ -1,4 +1,3 @@ -import {de} from 'date-fns/locale'; import React, {useCallback, useMemo} from 'react'; import {View} from 'react-native'; import BlockingView from '@components/BlockingViews/BlockingView'; @@ -24,11 +23,7 @@ function SageIntacctNonReimbursableDefaultVendorPage({policy}: WithPolicyConnect const policyID = policy?.id ?? '-1'; - const { - nonReimbursableCreditCardChargeDefaultVendor: creditCardDefaultVendor, - nonReimbursableExpenseReportDefaultVendor: expenseReportDefaultVendor, - nonReimbursable, - } = policy?.connections?.intacct?.config.export ?? {}; + const {nonReimbursable} = policy?.connections?.intacct?.config.export ?? {}; const activeDefaultVendor = getSageIntacctActiveDefaultVendor(policy); @@ -59,7 +54,7 @@ function SageIntacctNonReimbursableDefaultVendorPage({policy}: WithPolicyConnect } Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID)); }, - [policyID], + [policyID, activeDefaultVendor, nonReimbursable], ); const listEmptyContent = useMemo( diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx index 77fd6e3da9e0..5d092e906527 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx @@ -52,10 +52,11 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { const selectExportDate = useCallback( (row: MenuListItem) => { - if (row.value !== exportConfig.nonReimbursable) { - // TODO: change CONST.XERO_CONFIG.EXPORT to CONST.SAGE_INTACCT.EXPORT - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, {nonReimbursable: row.value}); + if (row.value === exportConfig.nonReimbursable) { + return; } + // TODO: change CONST.XERO_CONFIG.EXPORT to CONST.SAGE_INTACCT.EXPORT + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, {nonReimbursable: row.value}); }, [exportConfig.nonReimbursable, policyID], ); @@ -86,8 +87,10 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { const creditCardAccountSection = { description: translate('workspace.sageIntacct.creditCardAccount'), - action: () => {}, - title: exportConfig.nonReimbursableAccount ? exportConfig.nonReimbursableAccount : translate('workspace.sageIntacct.notConfigured'), + action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT.getRoute(policyID)), + title: exportConfig.nonReimbursableAccount + ? intacctData.creditCards.find((creditCard) => creditCard.id === exportConfig.nonReimbursableAccount).name + : translate('workspace.sageIntacct.notConfigured'), hasError: !!errorFields?.exporter, pendingAction: pendingFields?.export, }; @@ -126,7 +129,7 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { { From b879cc2ed5b938ac4eee421c2d9c32d1ac3ffa77 Mon Sep 17 00:00:00 2001 From: war-in Date: Mon, 17 Jun 2024 17:59:06 +0200 Subject: [PATCH 09/50] cleaning --- .../intacct/export/SageIntacctDatePage.tsx | 4 +- .../intacct/export/SageIntacctExportPage.tsx | 4 +- ...ctNonReimbursableCreditCardAccountPage.tsx | 11 +++--- ...ntacctNonReimbursableDefaultVendorPage.tsx | 1 + ...SageIntacctNonReimbursableExpensesPage.tsx | 37 ++++++++++--------- .../SageIntacctPreferredExporterPage.tsx | 2 +- .../SageIntacctReimbursableExpensesPage.tsx | 5 +-- 7 files changed, 33 insertions(+), 31 deletions(-) diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx index 1c3889de2986..7a8cebfeb921 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx @@ -42,7 +42,7 @@ function SageIntacctDatePage({policy}: WithPolicyProps) { ); const selectExportDate = useCallback( - (row: MenuListItem) => { + (row: SelectorType) => { if (row.value !== exportDate) { Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, {exportDate: row.value}); } @@ -58,7 +58,7 @@ function SageIntacctDatePage({policy}: WithPolicyProps) { headerContent={headerContent} sections={[{data}]} listItem={RadioListItem} - onSelectRow={(selection: SelectorType) => selectExportDate(selection as MenuListItem)} + onSelectRow={selectExportDate} initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} policyID={policyID} accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]} diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx index f61ca69a205a..4484c2daa24c 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx @@ -17,8 +17,6 @@ function SageIntacctExportPage({policy}: WithPolicyProps) { const {export: exportConfig, pendingFields, errorFields, credentials} = policy?.connections?.intacct?.config ?? {}; - const currentSageIntacctOrganizationName = credentials.companyID; - const sections = useMemo( () => [ { @@ -61,7 +59,7 @@ function SageIntacctExportPage({policy}: WithPolicyProps) { (() => getSageIntacctCreditCards(policy, nonReimbursableAccount), [nonReimbursableAccount, policy]); + const creditCardSelectorOptions = useMemo(() => getSageIntacctCreditCards(policy, nonReimbursableAccount), [nonReimbursableAccount, policy]); const listHeaderComponent = useMemo( () => ( @@ -36,7 +36,7 @@ function SageIntacctNonReimbursableCreditCardAccountPage({policy}: WithPolicyCon [translate, styles.pb2, styles.ph5, styles.pb5, styles.textNormal], ); - const updateDefaultVendor = useCallback( + const updateCreditCardAccount = useCallback( ({value}: SelectorType) => { if (value !== nonReimbursableAccount) { Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, { @@ -48,6 +48,7 @@ function SageIntacctNonReimbursableCreditCardAccountPage({policy}: WithPolicyCon [policyID, nonReimbursableAccount], ); + // TODO: test on empty data const listEmptyContent = useMemo( () => ( mode.isSelected)?.keyForList} + onSelectRow={updateCreditCardAccount} + initiallyFocusedOptionKey={creditCardSelectorOptions.find((mode) => mode.isSelected)?.keyForList} headerContent={listHeaderComponent} onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID))} title="workspace.sageIntacct.creditCardAccount" diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableDefaultVendorPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableDefaultVendorPage.tsx index db45e7f96d8e..dec468f2d886 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableDefaultVendorPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableDefaultVendorPage.tsx @@ -57,6 +57,7 @@ function SageIntacctNonReimbursableDefaultVendorPage({policy}: WithPolicyConnect [policyID, activeDefaultVendor, nonReimbursable], ); + // TODO: test on empty list const listEmptyContent = useMemo( () => ( { + const selectNonReimbursableExpense = useCallback( + (row: SelectorType) => { if (row.value === exportConfig.nonReimbursable) { return; } - // TODO: change CONST.XERO_CONFIG.EXPORT to CONST.SAGE_INTACCT.EXPORT Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, {nonReimbursable: row.value}); }, [exportConfig.nonReimbursable, policyID], @@ -95,6 +94,21 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { pendingAction: pendingFields?.export, }; + const creditCardAccount = ( + + + + ); + return ( selectExportDate(selection as MenuListItem)} + onSelectRow={selectNonReimbursableExpense} initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} policyID={policyID} accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]} @@ -114,18 +128,7 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { {exportConfig.nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL && defaultVendor} {exportConfig.nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE && ( - - - + {creditCardAccount} {isSwitchOn && defaultVendor} diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx index 4a306df6b380..4c44c10744f6 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx @@ -21,10 +21,10 @@ type CardListItem = ListItem & { }; function SageIntacctPreferredExporterPage({policy}: WithPolicyProps) { - const {export: exportConfiguration} = policy?.connections?.intacct?.config ?? {}; const {translate} = useLocalize(); const styles = useThemeStyles(); const policyOwner = policy?.owner ?? ''; + const {export: exportConfiguration} = policy?.connections?.intacct?.config ?? {}; const exporters = getAdminEmployees(policy); const {login: currentUserLogin} = useCurrentUserPersonalDetails(); diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx index d792c4a58b3b..a0010e027b04 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx @@ -41,9 +41,8 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { ); const selectExportDate = useCallback( - (row: MenuListItem) => { + (row: SelectorType) => { if (row.value !== reimbursable) { - // TODO: change CONST.XERO_CONFIG.EXPORT to CONST.SAGE_INTACCT.EXPORT Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, {reimbursable: row.value}); } Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID)); @@ -58,7 +57,7 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { headerContent={headerContent} sections={[{data}]} listItem={RadioListItem} - onSelectRow={(selection: SelectorType) => selectExportDate(selection as MenuListItem)} + onSelectRow={selectExportDate} initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} policyID={policyID} accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]} From 9e92d8b09950b1c32625fb8b42c95f06a798d315 Mon Sep 17 00:00:00 2001 From: war-in Date: Mon, 17 Jun 2024 18:10:00 +0200 Subject: [PATCH 10/50] add spanish translations --- src/languages/es.ts | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/languages/es.ts b/src/languages/es.ts index 6556735ff167..bb36778d7cb9 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2213,6 +2213,53 @@ export default { noAccountsFound: 'No se ha encontrado ninguna cuenta', noAccountsFoundDescription: 'Añade la cuenta en Xero y sincroniza de nuevo la conexión', }, + sageIntacct: { + preferredExporter: 'Exportador preferido', + notConfigured: 'No configurado', + exportDate: { + label: 'Fecha de exportación', + description: 'Utilice esta fecha cuando exporte informes a Sage Intacct.', + values: { + [CONST.SAGE_INTACCT_EXPORT_DATE.LAST_EXPENSE]: { + label: 'Fecha del último gasto', + description: 'Fecha del gasto más reciente del informe.', + }, + [CONST.SAGE_INTACCT_EXPORT_DATE.REPORT_EXPORTED]: { + label: 'Fecha de exportación', + description: 'Fecha en la que se exportó el informe a Sage Intacct.', + }, + [CONST.SAGE_INTACCT_EXPORT_DATE.REPORT_SUBMITTED]: { + label: 'Fecha de envío', + description: 'Fecha de presentación del informe para su aprobación.', + }, + }, + }, + reimbursableExpenses: { + label: 'Gastos reembolsables de exportación como', + description: 'Los gastos reembolsables se exportarán como informes de gastos a Sage Intacct. Las facturas se exportarán como facturas de proveedores.', + values: { + [CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE.EXPENSE_REPORT]: 'Informes de gastos', + [CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL]: 'Facturas de proveedores', + }, + }, + nonReimbursableExpenses: { + label: 'Exportar gastos no reembolsables como', + description: + 'Los gastos no reembolsables se exportarán a Sage Intacct como transacciones de tarjetas de crédito o facturas de proveedores y se abonarán en la cuenta seleccionada a continuación. Más información sobre la asignación de tarjetas a cuentas individuales.', + values: { + [CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE]: 'Transacciones con tarjeta de crédito', + [CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL]: 'Facturas de proveedores', + }, + }, + creditCardAccount: 'Cuenta de tarjeta de crédito', + creditCardAccountDescription: '!!!!!!!!', + defaultVendor: 'Proveedor por defecto', + defaultVendorDescription: 'Establezca un proveedor predeterminado que se aplicará a los gastos no reembolsables que no tienen un proveedor coincidente en Sage Intacct.', + exportDescription: 'Configure cómo se exportan los datos de Expensify a Sage Inacct.', + exportPreferredExporterNote: + 'El exportador preferido puede ser cualquier administrador del área de trabajo, pero también debe ser un administrador del dominio si establece diferentes cuentas de exportación para tarjetas de empresa individuales en Configuración del dominio.', + exportPreferredExporterSubNote: 'Una vez configurado, el exportador preferido verá los informes para exportar en su cuenta.', + }, type: { free: 'Gratis', control: 'Control', From a22a6039910bda0233ba1470c45c1a91036a4136 Mon Sep 17 00:00:00 2001 From: war-in Date: Tue, 18 Jun 2024 16:47:13 +0200 Subject: [PATCH 11/50] fix always selected user --- .../intacct/export/SageIntacctPreferredExporterPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx index 4c44c10744f6..31596d9826a1 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx @@ -36,7 +36,7 @@ function SageIntacctPreferredExporterPage({policy}: WithPolicyProps) { value: policyOwner, text: policyOwner, keyForList: policyOwner, - isSelected: true, + isSelected: exportConfiguration?.exporter === policyOwner, }, ]; } From 52d8765c80a391fa1330bf368917506aa2882df5 Mon Sep 17 00:00:00 2001 From: war-in Date: Mon, 24 Jun 2024 15:27:33 +0200 Subject: [PATCH 12/50] add default vendor for reimbursable expenses (and unify this page) --- src/ROUTES.ts | 6 +- src/SCREENS.ts | 2 +- .../ModalStackNavigators/index.tsx | 3 +- .../FULL_SCREEN_TO_RHP_MAPPING.ts | 2 +- src/libs/Navigation/linkingConfig/config.ts | 2 +- src/libs/Navigation/types.ts | 3 +- src/libs/PolicyUtils.ts | 21 ++--- .../intacct/export/SageIntacctDatePage.tsx | 2 +- ...e.tsx => SageIntacctDefaultVendorPage.tsx} | 69 +++++++++----- .../intacct/export/SageIntacctExportPage.tsx | 10 +- ...SageIntacctNonReimbursableExpensesPage.tsx | 45 +++++---- .../SageIntacctReimbursableExpensesPage.tsx | 93 +++++++++++++++---- src/types/onyx/Policy.ts | 79 +++++++++++++++- 13 files changed, 245 insertions(+), 92 deletions(-) rename src/pages/workspace/accounting/intacct/export/{SageIntacctNonReimbursableDefaultVendorPage.tsx => SageIntacctDefaultVendorPage.tsx} (50%) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index cced1dddfa36..515661e93152 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -933,9 +933,9 @@ const ROUTES = { route: 'settings/workspaces/:policyID/connections/sage-intacct/export/non-reimbursable', getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/sage-intacct/export/non-reimbursable` as const, }, - POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_DEFAULT_VENDOR: { - route: 'settings/workspaces/:policyID/connections/sage-intacct/export/non-reimbursable/default-vendor', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/sage-intacct/export/non-reimbursable/default-vendor` as const, + POLICY_ACCOUNTING_SAGE_INTACCT_DEFAULT_VENDOR: { + route: 'settings/workspaces/:policyID/connections/sage-intacct/export/:reimbursable/default-vendor', + getRoute: (policyID: string, reimbursable: string) => `settings/workspaces/${policyID}/connections/sage-intacct/export/${reimbursable}/default-vendor` as const, }, POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT: { route: 'settings/workspaces/:policyID/connections/sage-intacct/export/non-reimbursable/credit-card-account', diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 79d59e587f46..e7acea4185cb 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -273,7 +273,7 @@ const SCREENS = { SAGE_INTACCT_EXPORT_DATE: 'Policy_Accounting_Sage_Intacct_Export_Date', SAGE_INTACCT_REIMBURSABLE_EXPENSES: 'Policy_Accounting_Sage_Intacct_Reimbursable_Expenses', SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES: 'Policy_Accounting_Sage_Intacct_Non_Reimbursable_Expenses', - SAGE_INTACCT_NON_REIMBURSABLE_DEFAULT_VENDOR: 'Policy_Accounting_Sage_Intacct_Non_Reimbursable_Default_Vendor', + SAGE_INTACCT_DEFAULT_VENDOR: 'Policy_Accounting_Sage_Intacct_Default_Vendor', SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT: 'Policy_Accounting_Sage_Intacct_Non_Reimbursable_Credit_Card_Account', }, INITIAL: 'Workspace_Initial', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 63b38c06e55e..70cf6b6a5cfe 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -326,8 +326,7 @@ const SettingsModalStackNavigator = createModalStackNavigator require('@pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage').default as React.ComponentType, - [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_DEFAULT_VENDOR]: () => - require('@pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableDefaultVendorPage').default as React.ComponentType, + [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_DEFAULT_VENDOR]: () => require('@pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT]: () => require('@pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_FREQUENCY]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage').default as React.ComponentType, diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index 2c4294e24c7f..7882b92bbc6d 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -59,7 +59,7 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_EXPORT_DATE, SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_REIMBURSABLE_EXPENSES, SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES, - SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_DEFAULT_VENDOR, + SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_DEFAULT_VENDOR, SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT, ], [SCREENS.WORKSPACE.TAXES]: [ diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 3790e529caef..7104e7bf4b65 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -342,7 +342,7 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_EXPORT_DATE]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT_DATE.route}, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_REIMBURSABLE_EXPENSES]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_REIMBURSABLE_EXPENSES.route}, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.route}, - [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_DEFAULT_VENDOR]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_DEFAULT_VENDOR.route}, + [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_DEFAULT_VENDOR]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_DEFAULT_VENDOR.route}, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT]: { path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT.route, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 34805c979a07..deb5c2d431ba 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -400,8 +400,9 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES]: { policyID: string; }; - [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_DEFAULT_VENDOR]: { + [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_DEFAULT_VENDOR]: { policyID: string; + reimbursable: string; }; [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT]: { policyID: string; diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 4753658d59af..2d21e2da8197 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -461,7 +461,7 @@ function getXeroBankAccountsWithDefaultSelect(policy: Policy | undefined, select })); } -function getSageIntacctVendors(policy: Policy | undefined, selectedVendorId: string | undefined): SelectorType[] { +function getSageIntacctVendors(policy: Policy | undefined, selectedVendorId: string | null | undefined): SelectorType[] { const vendors = policy?.connections?.intacct?.data?.vendors ?? []; const isMatchFound = vendors?.some(({id}) => id === selectedVendorId); @@ -473,25 +473,24 @@ function getSageIntacctVendors(policy: Policy | undefined, selectedVendorId: str })); } -function getSageIntacctActiveDefaultVendor(policy: Policy | undefined): string | null { +function getSageIntacctNonReimbursableActiveDefaultVendor(policy: Policy | undefined): string | null | undefined { const { nonReimbursableCreditCardChargeDefaultVendor: creditCardDefaultVendor, - nonReimbursableExpenseReportDefaultVendor: expenseReportDefaultVendor, + nonReimbursableVendor: expenseReportDefaultVendor, nonReimbursable, } = policy?.connections?.intacct?.config.export ?? {}; return nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE ? creditCardDefaultVendor : expenseReportDefaultVendor; } -function getSageIntacctCreditCards(policy: Policy | undefined, selectedAccountId: string | undefined): SelectorType[] { +function getSageIntacctCreditCards(policy: Policy | undefined, selectedAccount: string | undefined): SelectorType[] { const creditCards = policy?.connections?.intacct?.data?.creditCards ?? []; - const isMatchFound = creditCards?.some(({id}) => id === selectedAccountId); + const isMatchFound = creditCards?.some(({name}) => name === selectedAccount); - return (creditCards ?? []).map(({id, name}) => ({ - value: id, - text: name, - keyForList: id, - isSelected: isMatchFound && selectedAccountId === id, + return (creditCards ?? []).map(({name}) => ({ + value: name, + keyForList: name, + isSelected: isMatchFound && name === selectedAccount, })); } @@ -581,7 +580,7 @@ export { getCurrentXeroOrganizationName, getXeroBankAccountsWithDefaultSelect, getSageIntacctVendors, - getSageIntacctActiveDefaultVendor, + getSageIntacctNonReimbursableActiveDefaultVendor, getSageIntacctCreditCards, getCustomUnit, getCustomUnitRate, diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx index 7a8cebfeb921..e8d0150dab90 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx @@ -42,7 +42,7 @@ function SageIntacctDatePage({policy}: WithPolicyProps) { ); const selectExportDate = useCallback( - (row: SelectorType) => { + (row: MenuListItem) => { if (row.value !== exportDate) { Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, {exportDate: row.value}); } diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableDefaultVendorPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx similarity index 50% rename from src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableDefaultVendorPage.tsx rename to src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx index dec468f2d886..911177dddcaf 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableDefaultVendorPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx @@ -1,5 +1,7 @@ +import type {StackScreenProps} from '@react-navigation/stack'; import React, {useCallback, useMemo} from 'react'; import {View} from 'react-native'; +import {useOnyx} from 'react-native-onyx'; import BlockingView from '@components/BlockingViews/BlockingView'; import * as Illustrations from '@components/Icon/Illustrations'; import RadioListItem from '@components/SelectionList/RadioListItem'; @@ -10,24 +12,34 @@ import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import * as Connections from '@libs/actions/connections'; import Navigation from '@libs/Navigation/Navigation'; -import {getSageIntacctActiveDefaultVendor, getSageIntacctVendors} from '@libs/PolicyUtils'; -import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; -import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import {getSageIntacctNonReimbursableActiveDefaultVendor, getSageIntacctVendors} from '@libs/PolicyUtils'; +import type {SettingsNavigatorParamList} from '@navigation/types'; import variables from '@styles/variables'; import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; +import type SCREENS from '@src/SCREENS'; -function SageIntacctNonReimbursableDefaultVendorPage({policy}: WithPolicyConnectionsProps) { +type SageIntacctDefaultVendorPageProps = StackScreenProps; + +function SageIntacctDefaultVendorPage({route}: SageIntacctDefaultVendorPageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); - const policyID = policy?.id ?? '-1'; + const policyID = route.params.policyID ?? '-1'; + const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); - const {nonReimbursable} = policy?.connections?.intacct?.config.export ?? {}; + const isReimbursable = route.params.reimbursable === 'reimbursable'; - const activeDefaultVendor = getSageIntacctActiveDefaultVendor(policy); + let defaultVendor; + if (!isReimbursable) { + defaultVendor = getSageIntacctNonReimbursableActiveDefaultVendor(policy); + } else { + const {reimbursableExpenseReportDefaultVendor} = policy?.connections?.intacct?.config.export ?? {}; + defaultVendor = reimbursableExpenseReportDefaultVendor; + } - const vendorSelectorOptions = useMemo(() => getSageIntacctVendors(policy ?? undefined, activeDefaultVendor), [activeDefaultVendor, policy]); + const vendorSelectorOptions = useMemo(() => getSageIntacctVendors(policy ?? undefined, defaultVendor), [defaultVendor, policy]); const listHeaderComponent = useMemo( () => ( @@ -40,21 +52,24 @@ function SageIntacctNonReimbursableDefaultVendorPage({policy}: WithPolicyConnect const updateDefaultVendor = useCallback( ({value}: SelectorType) => { - if (value !== activeDefaultVendor) { - Connections.updatePolicyConnectionConfig( - policyID, - CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, - CONST.XERO_CONFIG.EXPORT, - nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE - ? { - nonReimbursableCreditCardChargeDefaultVendor: value, - } - : {nonReimbursableExpenseReportDefaultVendor: value}, - ); + if (value !== defaultVendor) { + let settingValue; + if (isReimbursable) { + settingValue = {reimbursableExpenseReportDefaultVendor: value}; + } else { + const {nonReimbursable} = policy?.connections?.intacct?.config.export ?? {}; + settingValue = + nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE + ? { + nonReimbursableCreditCardChargeDefaultVendor: value, + } + : {nonReimbursableVendor: value}; + } + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, settingValue); } Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID)); }, - [policyID, activeDefaultVendor, nonReimbursable], + [policyID, defaultVendor], ); // TODO: test on empty list @@ -76,13 +91,19 @@ function SageIntacctNonReimbursableDefaultVendorPage({policy}: WithPolicyConnect mode.isSelected)?.keyForList} headerContent={listHeaderComponent} - onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID))} + onBackButtonPress={() => + Navigation.goBack( + isReimbursable + ? ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_REIMBURSABLE_EXPENSES.getRoute(policyID) + : ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID), + ) + } title="workspace.sageIntacct.defaultVendor" listEmptyContent={listEmptyContent} connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} @@ -90,6 +111,6 @@ function SageIntacctNonReimbursableDefaultVendorPage({policy}: WithPolicyConnect ); } -SageIntacctNonReimbursableDefaultVendorPage.displayName = 'PolicySageIntacctNonReimbursableDefaultVendorPage'; +SageIntacctDefaultVendorPage.displayName = 'PolicySageIntacctDefaultVendorPage'; -export default withPolicyConnections(SageIntacctNonReimbursableDefaultVendorPage); +export default SageIntacctDefaultVendorPage; diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx index 4484c2daa24c..dc9686710dad 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx @@ -22,21 +22,21 @@ function SageIntacctExportPage({policy}: WithPolicyProps) { { description: translate('workspace.sageIntacct.preferredExporter'), action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_PREFERRED_EXPORTER.getRoute(policyID)), - title: exportConfig.exporter || translate('workspace.sageIntacct.notConfigured'), + title: exportConfig?.exporter ?? translate('workspace.sageIntacct.notConfigured'), hasError: !!errorFields?.exporter, pendingAction: pendingFields?.export, }, { description: translate('workspace.sageIntacct.exportDate.label'), action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT_DATE.getRoute(policyID)), - title: exportConfig.exportDate ? translate(`workspace.sageIntacct.exportDate.values.${exportConfig.exportDate}.label`) : translate(`workspace.sageIntacct.notConfigured`), + title: exportConfig?.exportDate ? translate(`workspace.sageIntacct.exportDate.values.${exportConfig.exportDate}.label`) : translate(`workspace.sageIntacct.notConfigured`), hasError: !!errorFields?.exportDate, pendingAction: pendingFields?.export, }, { description: translate('workspace.sageIntacct.reimbursableExpenses.label'), action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_REIMBURSABLE_EXPENSES.getRoute(policyID)), - title: exportConfig.reimbursable + title: exportConfig?.reimbursable ? translate(`workspace.sageIntacct.reimbursableExpenses.values.${exportConfig.reimbursable}`) : translate('workspace.sageIntacct.notConfigured'), hasError: !!errorFields?.reimbursable, @@ -45,7 +45,7 @@ function SageIntacctExportPage({policy}: WithPolicyProps) { { description: translate('workspace.sageIntacct.nonReimbursableExpenses.label'), action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID)), - title: exportConfig.nonReimbursable + title: exportConfig?.nonReimbursable ? translate(`workspace.sageIntacct.nonReimbursableExpenses.values.${exportConfig.nonReimbursable}`) : translate('workspace.sageIntacct.notConfigured'), hasError: !!errorFields?.nonReimbursable, @@ -59,7 +59,7 @@ function SageIntacctExportPage({policy}: WithPolicyProps) { ; }; +function getDefaultVendorName(defaultVendor: string, vendors: SageIntacctDataElementWithValue[]): string { + return vendors.find((vendor) => vendor.id === defaultVendor)?.value ?? defaultVendor; +} + function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const policyID = policy?.id ?? '-1'; const styles = useThemeStyles(); - const { - data: intacctData, - config: {export: exportConfig, pendingFields, errorFields}, - } = policy?.connections?.intacct ?? {}; + const {data: intacctData, config} = policy?.connections?.intacct ?? {}; - const [isSwitchOn, setIsSwitchOn] = useState(!!exportConfig.nonReimbursableCreditCardChargeDefaultVendor); + const [isSwitchOn, setIsSwitchOn] = useState(!!config?.export.nonReimbursableCreditCardChargeDefaultVendor); const data: MenuListItem[] = Object.values(CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE).map((expenseType) => ({ value: expenseType, text: translate(`workspace.sageIntacct.nonReimbursableExpenses.values.${expenseType}`), keyForList: expenseType, - isSelected: exportConfig.nonReimbursable === expenseType, + isSelected: config?.export.nonReimbursable === expenseType, })); const headerContent = useMemo( @@ -51,22 +52,22 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { ); const selectNonReimbursableExpense = useCallback( - (row: SelectorType) => { - if (row.value === exportConfig.nonReimbursable) { + (row: MenuListItem) => { + if (row.value === config?.export.nonReimbursable) { return; } Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, {nonReimbursable: row.value}); }, - [exportConfig.nonReimbursable, policyID], + [config?.export.nonReimbursable, policyID], ); - const activeDefaultVendor = getSageIntacctActiveDefaultVendor(policy); + const activeDefaultVendor = getSageIntacctNonReimbursableActiveDefaultVendor(policy); const defaultVendorSection = { description: translate('workspace.sageIntacct.defaultVendor'), - action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_DEFAULT_VENDOR.getRoute(policyID)), - title: activeDefaultVendor ? intacctData.vendors.find((vendor) => vendor.id === activeDefaultVendor).value : translate('workspace.sageIntacct.notConfigured'), - hasError: !!errorFields?.exporter, - pendingAction: pendingFields?.export, + action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_DEFAULT_VENDOR.getRoute(policyID, 'non-reimbursable')), + title: activeDefaultVendor ? getDefaultVendorName(activeDefaultVendor, intacctData?.vendors ?? []) : translate('workspace.sageIntacct.notConfigured'), + hasError: !!config?.errorFields?.exporter, + pendingAction: config?.pendingFields?.export, }; const defaultVendor = ( @@ -87,11 +88,9 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { const creditCardAccountSection = { description: translate('workspace.sageIntacct.creditCardAccount'), action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT.getRoute(policyID)), - title: exportConfig.nonReimbursableAccount - ? intacctData.creditCards.find((creditCard) => creditCard.id === exportConfig.nonReimbursableAccount).name - : translate('workspace.sageIntacct.notConfigured'), - hasError: !!errorFields?.exporter, - pendingAction: pendingFields?.export, + title: config?.export.nonReimbursableAccount ? config.export.nonReimbursableAccount : translate('workspace.sageIntacct.notConfigured'), + hasError: !!config?.errorFields?.exporter, + pendingAction: config?.pendingFields?.export, }; const creditCardAccount = ( @@ -125,8 +124,8 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID))} connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} /> - {exportConfig.nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL && defaultVendor} - {exportConfig.nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE && ( + {config?.export.nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL && defaultVendor} + {config?.export.nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE && ( {creditCardAccount} ; }; +function getDefaultVendorName(defaultVendor: string, vendors: SageIntacctDataElementWithValue[]): string { + return vendors.find((vendor) => vendor.id === defaultVendor)?.value ?? defaultVendor; +} + function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const policyID = policy?.id ?? '-1'; const styles = useThemeStyles(); - const {reimbursable} = policy?.connections?.intacct?.config?.export ?? {}; + const {data: intacctData, config} = policy?.connections?.intacct ?? {}; + const {reimbursable, reimbursableExpenseReportDefaultVendor} = policy?.connections?.intacct?.config?.export ?? {}; + + const [isSwitchOn, setIsSwitchOn] = useState(!!reimbursableExpenseReportDefaultVendor); + const data: MenuListItem[] = Object.values(CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE).map((expenseType) => ({ value: expenseType, text: translate(`workspace.sageIntacct.reimbursableExpenses.values.${expenseType}`), @@ -41,7 +52,7 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { ); const selectExportDate = useCallback( - (row: SelectorType) => { + (row: MenuListItem) => { if (row.value !== reimbursable) { Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, {reimbursable: row.value}); } @@ -50,21 +61,67 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { [reimbursable, policyID], ); + const defaultVendorSection = { + description: translate('workspace.sageIntacct.defaultVendor'), + action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_DEFAULT_VENDOR.getRoute(policyID, 'reimbursable')), + title: reimbursableExpenseReportDefaultVendor + ? getDefaultVendorName(reimbursableExpenseReportDefaultVendor, intacctData?.vendors ?? []) + : translate('workspace.sageIntacct.notConfigured'), + hasError: !!config?.errorFields?.exporter, + pendingAction: config?.pendingFields?.export, + }; + + const defaultVendor = ( + + + + ); + return ( - mode.isSelected)?.keyForList} - policyID={policyID} - accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]} - featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} - onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID))} - connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} - /> + + mode.isSelected)?.keyForList} + policyID={policyID} + accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]} + featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} + onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID))} + connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} + /> + {reimbursable === CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE.EXPENSE_REPORT && ( + + { + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, { + reimbursableExpenseReportDefaultVendor: null, + }); + setIsSwitchOn(!isSwitchOn); + }} + wrapperStyle={[styles.ph5, styles.pv3]} + /> + {isSwitchOn && defaultVendor} + + )} + ); } diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index bd8f5e7d33d9..a67ead8fe4eb 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -594,6 +594,79 @@ type XeroConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ errorFields?: OnyxCommon.ErrorFields; }>; +/** One of the SageIntacctConnectionData object elements */ +type SageIntacctDataElement = { + /** Element ID */ + id: string; + + /** Element name */ + name: string; +}; + +/** One of the SageIntacctConnectionData object elements with value */ +type SageIntacctDataElementWithValue = SageIntacctDataElement & { + /** Element value */ + value: string; +}; + +/** + * Connection data for Sage Intacct + */ +type SageIntacctConnectionData = { + /** Collection of credit cards */ + creditCards: SageIntacctDataElement[]; + + /** Collection of bank accounts */ + bankAccounts: SageIntacctDataElement[]; + + /** Collection of vendors */ + vendors: SageIntacctDataElementWithValue[]; +}; + +/** + * Connection config for Sage Intacct + */ +type SageIntacctConnectiosConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ + /** Sage Intacct credentials */ + credentials: { + /** Sage Intacct companyID */ + companyID: string; + }; + + /** Sage Intacct export configs */ + export: { + /** Current export status */ + exportDate: ValueOf; + + /** The e-mail of the exporter */ + exporter: string; + + /** TODO: Will be handled in another issue */ + nonReimbursable: ValueOf; + + /** TODO: Will be handled in another issue */ + nonReimbursableAccount: string; + + /** */ + nonReimbursableCreditCardChargeDefaultVendor: string | null; + + /** */ + nonReimbursableVendor: string | null; + + /** TODO: Will be handled in another issue */ + reimbursable: ValueOf; + + /** */ + reimbursableExpenseReportDefaultVendor: string | null; + }; + + /** Collection of Sage Intacct config errors */ + errors?: OnyxCommon.Errors; + + /** Collection of form field errors */ + errorFields?: OnyxCommon.ErrorFields; +}>; + /** Data stored about subsidiaries from NetSuite */ type Subsidiary = { /** ID of the subsidiary */ @@ -952,7 +1025,7 @@ type NetSuiteConnection = { /** State of integration connection */ type Connection = { /** State of the last synchronization */ - lastSync?: ConnectionLastSync; + lastSync?: ConnectionLxastSync; /** Data imported from integration */ data?: ConnectionData; @@ -971,6 +1044,9 @@ type Connections = { /** NetSuite integration connection */ netsuite: NetSuiteConnection; + + /** Sage Intacct integration connection */ + intacct: Connection; }; /** Names of integration connections */ @@ -1314,4 +1390,5 @@ export type { QBOReimbursableExportAccountType, QBOConnectionConfig, XeroTrackingCategory, + SageIntacctDataElementWithValue, }; From def13fe85939736652926e23c0a40b308f1bc1ce Mon Sep 17 00:00:00 2001 From: war-in Date: Mon, 24 Jun 2024 15:44:28 +0200 Subject: [PATCH 13/50] fix typecheck --- src/languages/es.ts | 13 +++++++++++++ .../intacct/export/SageIntacctDatePage.tsx | 2 +- .../intacct/export/SageIntacctDefaultVendorPage.tsx | 2 +- .../SageIntacctNonReimbursableExpensesPage.tsx | 3 ++- .../export/SageIntacctReimbursableExpensesPage.tsx | 3 ++- src/types/onyx/Policy.ts | 2 +- 6 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index 9f95e03e5099..df2f8653df51 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2454,6 +2454,19 @@ export default { subtitle: 'Conecta a tu sistema de contabilidad para codificar transacciones con tu plan de cuentas, auto-cotejar pagos, y mantener tus finanzas sincronizadas.', qbo: 'Quickbooks Online', xero: 'Xero', + intacct: 'Sage Intacct', + integrationName: (integration?: ConnectionName): string => { + switch (integration) { + case CONST.POLICY.CONNECTIONS.NAME.QBO: + return 'Quickbooks Online'; + case CONST.POLICY.CONNECTIONS.NAME.XERO: + return 'Xero'; + case CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT: + return 'Sage Intacct'; + default: + return 'Integration'; + } + }, setup: 'Configurar', lastSync: 'Recién sincronizado', import: 'Importar', diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx index e8d0150dab90..1c3889de2986 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx @@ -58,7 +58,7 @@ function SageIntacctDatePage({policy}: WithPolicyProps) { headerContent={headerContent} sections={[{data}]} listItem={RadioListItem} - onSelectRow={selectExportDate} + onSelectRow={(selection: SelectorType) => selectExportDate(selection as MenuListItem)} initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} policyID={policyID} accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]} diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx index 911177dddcaf..c7c958558b28 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx @@ -69,7 +69,7 @@ function SageIntacctDefaultVendorPage({route}: SageIntacctDefaultVendorPageProps } Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID)); }, - [policyID, defaultVendor], + [defaultVendor, policyID, isReimbursable, policy?.connections?.intacct?.config.export], ); // TODO: test on empty list diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx index 000388a5c32c..b1ab9b6c3ae5 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx @@ -5,6 +5,7 @@ import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; import RadioListItem from '@components/SelectionList/RadioListItem'; import type {ListItem} from '@components/SelectionList/types'; +import type {SelectorType} from '@components/SelectionScreen'; import SelectionScreen from '@components/SelectionScreen'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; @@ -116,7 +117,7 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { headerContent={headerContent} sections={[{data}]} listItem={RadioListItem} - onSelectRow={selectNonReimbursableExpense} + onSelectRow={(selection: SelectorType) => selectNonReimbursableExpense(selection as MenuListItem)} initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} policyID={policyID} accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]} diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx index 4aa84c931203..521a98beed1d 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx @@ -5,6 +5,7 @@ import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; import RadioListItem from '@components/SelectionList/RadioListItem'; import type {ListItem} from '@components/SelectionList/types'; +import type {SelectorType} from '@components/SelectionScreen'; import SelectionScreen from '@components/SelectionScreen'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; @@ -94,7 +95,7 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { headerContent={headerContent} sections={[{data}]} listItem={RadioListItem} - onSelectRow={selectExportDate} + onSelectRow={(selection: SelectorType) => selectExportDate(selection as MenuListItem)} initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} policyID={policyID} accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]} diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index a67ead8fe4eb..1a26722492f0 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -1025,7 +1025,7 @@ type NetSuiteConnection = { /** State of integration connection */ type Connection = { /** State of the last synchronization */ - lastSync?: ConnectionLxastSync; + lastSync?: ConnectionLastSync; /** Data imported from integration */ data?: ConnectionData; From 105cd0a82711ca35b47edb82f58876916d74b8c0 Mon Sep 17 00:00:00 2001 From: war-in Date: Mon, 24 Jun 2024 15:52:33 +0200 Subject: [PATCH 14/50] address review comments --- src/CONST.ts | 4 ++++ .../accounting/intacct/export/SageIntacctDatePage.tsx | 4 ++-- .../intacct/export/SageIntacctDefaultVendorPage.tsx | 2 +- .../SageIntacctNonReimbursableCreditCardAccountPage.tsx | 2 +- .../intacct/export/SageIntacctNonReimbursableExpensesPage.tsx | 4 ++-- .../intacct/export/SageIntacctPreferredExporterPage.tsx | 4 ++-- .../intacct/export/SageIntacctReimbursableExpensesPage.tsx | 4 ++-- 7 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 697444ad42a9..1ef6cd9aa54d 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1347,6 +1347,10 @@ const CONST = { }, }, + SAGE_INTACCT_CONFIG: { + EXPORT: 'export', + }, + QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE: { VENDOR_BILL: 'bill', CHECK: 'check', diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx index 1c3889de2986..2a0564844073 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx @@ -16,7 +16,7 @@ import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; type MenuListItem = ListItem & { - value: ValueOf; + value: ValueOf; }; function SageIntacctDatePage({policy}: WithPolicyProps) { @@ -44,7 +44,7 @@ function SageIntacctDatePage({policy}: WithPolicyProps) { const selectExportDate = useCallback( (row: MenuListItem) => { if (row.value !== exportDate) { - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, {exportDate: row.value}); + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.SAGE_INTACCT_CONFIG.EXPORT, {exportDate: row.value}); } Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID)); }, diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx index c7c958558b28..d86eea3edc48 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx @@ -65,7 +65,7 @@ function SageIntacctDefaultVendorPage({route}: SageIntacctDefaultVendorPageProps } : {nonReimbursableVendor: value}; } - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, settingValue); + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.SAGE_INTACCT_CONFIG.EXPORT, settingValue); } Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID)); }, diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx index 62a99dba7faa..a5c03617c792 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx @@ -39,7 +39,7 @@ function SageIntacctNonReimbursableCreditCardAccountPage({policy}: WithPolicyCon const updateCreditCardAccount = useCallback( ({value}: SelectorType) => { if (value !== nonReimbursableAccount) { - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, { + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.SAGE_INTACCT_CONFIG.EXPORT, { nonReimbursableAccount: value, }); } diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx index b1ab9b6c3ae5..26c532aea8af 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx @@ -57,7 +57,7 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { if (row.value === config?.export.nonReimbursable) { return; } - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, {nonReimbursable: row.value}); + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.SAGE_INTACCT_CONFIG.EXPORT, {nonReimbursable: row.value}); }, [config?.export.nonReimbursable, policyID], ); @@ -136,7 +136,7 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { switchAccessibilityLabel={translate('workspace.sageIntacct.defaultVendor')} isActive={isSwitchOn} onToggle={() => { - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, { + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.SAGE_INTACCT_CONFIG.EXPORT, { nonReimbursableCreditCardChargeDefaultVendor: null, }); setIsSwitchOn(!isSwitchOn); diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx index 31596d9826a1..0e8fa0a340f5 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx @@ -64,9 +64,9 @@ function SageIntacctPreferredExporterPage({policy}: WithPolicyProps) { const selectExporter = useCallback( (row: CardListItem) => { if (row.value !== exportConfiguration?.exporter) { - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, {exporter: row.value}); + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.SAGE_INTACCT_CONFIG.EXPORT, {exporter: row.value}); } - Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_EXPORT.getRoute(policyID)); + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID)); }, [policyID, exportConfiguration], ); diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx index 521a98beed1d..38452f1d75b2 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx @@ -55,7 +55,7 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { const selectExportDate = useCallback( (row: MenuListItem) => { if (row.value !== reimbursable) { - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, {reimbursable: row.value}); + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.SAGE_INTACCT_CONFIG.EXPORT, {reimbursable: row.value}); } Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID)); }, @@ -112,7 +112,7 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { switchAccessibilityLabel={translate('workspace.sageIntacct.defaultVendor')} isActive={isSwitchOn} onToggle={() => { - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.XERO_CONFIG.EXPORT, { + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.SAGE_INTACCT_CONFIG.EXPORT, { reimbursableExpenseReportDefaultVendor: null, }); setIsSwitchOn(!isSwitchOn); From 049c22743d2b326a8e180be3be14d376b623a315 Mon Sep 17 00:00:00 2001 From: war-in Date: Mon, 24 Jun 2024 16:08:57 +0200 Subject: [PATCH 15/50] add customizable translation for default vendor --- src/languages/en.ts | 3 ++- .../accounting/intacct/export/SageIntacctDefaultVendorPage.tsx | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 3deace7da721..7d4365211927 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2222,7 +2222,8 @@ export default { creditCardAccount: 'Credit card account', creditCardAccountDescription: 'We should have some description here, right?', defaultVendor: 'Default vendor', - defaultVendorDescription: "Set a default vendor that will apply to nonreimbursable expenses that don't have a matching vendor in Sage Intacct.", + defaultVendorDescription: (isReimbursable: boolean): string => + `Set a default vendor that will apply to ${isReimbursable ? '' : 'non-'}reimbursable expenses that don't have a matching vendor in Sage Intacct.`, exportDescription: 'Configure how data in Expensify gets exported to Sage Inacct.', exportPreferredExporterNote: 'The preferred exporter can be any workspace admin, but must also be a Domain Admin if you set different export accounts for individual company cards in Domain Settings.', diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx index d86eea3edc48..581ed20b816d 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx @@ -44,7 +44,7 @@ function SageIntacctDefaultVendorPage({route}: SageIntacctDefaultVendorPageProps const listHeaderComponent = useMemo( () => ( - {translate('workspace.sageIntacct.defaultVendorDescription')} + {translate('workspace.sageIntacct.defaultVendorDescription', isReimbursable)} ), [translate, styles.pb2, styles.ph5, styles.pb5, styles.textNormal], From ec7f075a70eb4cfbb76699e6c8f74aa9cc6e835a Mon Sep 17 00:00:00 2001 From: war-in Date: Mon, 24 Jun 2024 17:40:05 +0200 Subject: [PATCH 16/50] create functions for api calls --- src/libs/PolicyUtils.ts | 1 + src/libs/actions/connections/SageIntacct.ts | 138 ++++++++++++++++++ .../intacct/export/SageIntacctDatePage.tsx | 4 +- .../export/SageIntacctDefaultVendorPage.tsx | 6 +- ...ctNonReimbursableCreditCardAccountPage.tsx | 6 +- ...SageIntacctNonReimbursableExpensesPage.tsx | 8 +- .../SageIntacctPreferredExporterPage.tsx | 4 +- .../SageIntacctReimbursableExpensesPage.tsx | 10 +- 8 files changed, 156 insertions(+), 21 deletions(-) create mode 100644 src/libs/actions/connections/SageIntacct.ts diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 2d21e2da8197..a5788fc05ba7 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -489,6 +489,7 @@ function getSageIntacctCreditCards(policy: Policy | undefined, selectedAccount: return (creditCards ?? []).map(({name}) => ({ value: name, + text: name, keyForList: name, isSelected: isMatchFound && name === selectedAccount, })); diff --git a/src/libs/actions/connections/SageIntacct.ts b/src/libs/actions/connections/SageIntacct.ts new file mode 100644 index 000000000000..e2e7eec41491 --- /dev/null +++ b/src/libs/actions/connections/SageIntacct.ts @@ -0,0 +1,138 @@ +import type {OnyxUpdate} from 'react-native-onyx'; +import Onyx from 'react-native-onyx'; +import type {ValueOf} from 'type-fest'; +import * as API from '@libs/API'; +import {WRITE_COMMANDS} from '@libs/API/types'; +import * as ErrorUtils from '@libs/ErrorUtils'; +import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; +import type {ConnectionName, Connections} from '@src/types/onyx/Policy'; + +function prepareOnyxData( + policyID: string, + connectionName: TConnectionName, + settingName: TSettingName, + settingValue: Partial, +) { + const optimisticData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + connections: { + [connectionName]: { + config: { + [settingName]: settingValue ?? null, + pendingFields: { + [settingName]: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + errorFields: { + [settingName]: null, + }, + }, + }, + }, + }, + }, + ]; + + const failureData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + connections: { + [connectionName]: { + config: { + [settingName]: settingValue ?? null, + pendingFields: { + [settingName]: null, + }, + errorFields: { + [settingName]: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), + }, + }, + }, + }, + }, + }, + ]; + + const successData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + connections: { + [connectionName]: { + config: { + [settingName]: settingValue ?? null, + pendingFields: { + [settingName]: null, + }, + errorFields: { + [settingName]: null, + }, + }, + }, + }, + }, + }, + ]; + + return {optimisticData, failureData, successData}; +} + +function prepareOnyxDataForExport(policyID: string, settingValue: Partial) { + return prepareOnyxData(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.SAGE_INTACCT_CONFIG.EXPORT, settingValue); +} + +function prepareParametersForExport(policyID: string, settingValue: Partial) { + return { + policyID, + connectionName: CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, + settingName: CONST.SAGE_INTACCT_CONFIG.EXPORT, + settingValue: JSON.stringify(settingValue), + idempotencyKey: CONST.SAGE_INTACCT_CONFIG.EXPORT, + }; +} + +function updateSageIntacctExport(policyID: string, settingValue: Partial) { + const {optimisticData, failureData, successData} = prepareOnyxDataForExport(policyID, settingValue); + const parameters = prepareParametersForExport(policyID, settingValue); + + API.write(WRITE_COMMANDS.UPDATE_POLICY_CONNECTION_CONFIG, parameters, {optimisticData, failureData, successData}); +} + +function updateSageIntacctExporter(policyID: string, exporter: string) { + updateSageIntacctExport(policyID, {exporter}); +} + +function updateSageIntacctExportDate(policyID: string, date: ValueOf) { + updateSageIntacctExport(policyID, {exportDate: date}); +} + +function updateSageIntacctExportReimbursableExpense(policyID: string, reimbursable: ValueOf) { + updateSageIntacctExport(policyID, {reimbursable}); +} + +function updateSageIntacctDefaultVendor(policyID: string, settingValue: Partial) { + updateSageIntacctExport(policyID, settingValue); +} + +function updateSageIntacctExportNonReimbursableExpense(policyID: string, nonReimbursable: ValueOf) { + updateSageIntacctExport(policyID, {nonReimbursable}); +} + +function updateSageIntacctExportNonReimbursableAccount(policyID: string, nonReimbursableAccount: string) { + updateSageIntacctExport(policyID, {nonReimbursableAccount}); +} + +export { + updateSageIntacctExporter, + updateSageIntacctExportDate, + updateSageIntacctExportReimbursableExpense, + updateSageIntacctDefaultVendor, + updateSageIntacctExportNonReimbursableExpense, + updateSageIntacctExportNonReimbursableAccount, +}; diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx index 2a0564844073..7af7c46b8c1e 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx @@ -8,10 +8,10 @@ import type {SelectorType} from '@components/SelectionScreen'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; -import * as Connections from '@libs/actions/connections'; import Navigation from '@navigation/Navigation'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import {updateSageIntacctExportDate} from '@userActions/connections/SageIntacct'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -44,7 +44,7 @@ function SageIntacctDatePage({policy}: WithPolicyProps) { const selectExportDate = useCallback( (row: MenuListItem) => { if (row.value !== exportDate) { - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.SAGE_INTACCT_CONFIG.EXPORT, {exportDate: row.value}); + updateSageIntacctExportDate(policyID, row.value); } Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID)); }, diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx index 581ed20b816d..8bd49e00fbc5 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx @@ -10,11 +10,11 @@ import SelectionScreen from '@components/SelectionScreen'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; -import * as Connections from '@libs/actions/connections'; import Navigation from '@libs/Navigation/Navigation'; import {getSageIntacctNonReimbursableActiveDefaultVendor, getSageIntacctVendors} from '@libs/PolicyUtils'; import type {SettingsNavigatorParamList} from '@navigation/types'; import variables from '@styles/variables'; +import {updateSageIntacctDefaultVendor} from '@userActions/connections/SageIntacct'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; @@ -47,7 +47,7 @@ function SageIntacctDefaultVendorPage({route}: SageIntacctDefaultVendorPageProps {translate('workspace.sageIntacct.defaultVendorDescription', isReimbursable)} ), - [translate, styles.pb2, styles.ph5, styles.pb5, styles.textNormal], + [translate, styles.pb2, styles.ph5, styles.pb5, styles.textNormal, isReimbursable], ); const updateDefaultVendor = useCallback( @@ -65,7 +65,7 @@ function SageIntacctDefaultVendorPage({route}: SageIntacctDefaultVendorPageProps } : {nonReimbursableVendor: value}; } - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.SAGE_INTACCT_CONFIG.EXPORT, settingValue); + updateSageIntacctDefaultVendor(policyID, settingValue); } Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID)); }, diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx index a5c03617c792..157dc129094c 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx @@ -8,12 +8,12 @@ import SelectionScreen from '@components/SelectionScreen'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; -import * as Connections from '@libs/actions/connections'; import Navigation from '@libs/Navigation/Navigation'; import {getSageIntacctCreditCards} from '@libs/PolicyUtils'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import variables from '@styles/variables'; +import {updateSageIntacctExportNonReimbursableAccount} from '@userActions/connections/SageIntacct'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -39,9 +39,7 @@ function SageIntacctNonReimbursableCreditCardAccountPage({policy}: WithPolicyCon const updateCreditCardAccount = useCallback( ({value}: SelectorType) => { if (value !== nonReimbursableAccount) { - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.SAGE_INTACCT_CONFIG.EXPORT, { - nonReimbursableAccount: value, - }); + updateSageIntacctExportNonReimbursableAccount(policyID, value); } Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID)); }, diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx index 26c532aea8af..718870df8d92 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx @@ -10,12 +10,12 @@ import SelectionScreen from '@components/SelectionScreen'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; -import * as Connections from '@libs/actions/connections'; import {getSageIntacctNonReimbursableActiveDefaultVendor} from '@libs/PolicyUtils'; import Navigation from '@navigation/Navigation'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; +import {updateSageIntacctDefaultVendor, updateSageIntacctExportNonReimbursableExpense} from '@userActions/connections/SageIntacct'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import type {SageIntacctDataElementWithValue} from '@src/types/onyx/Policy'; @@ -57,7 +57,7 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { if (row.value === config?.export.nonReimbursable) { return; } - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.SAGE_INTACCT_CONFIG.EXPORT, {nonReimbursable: row.value}); + updateSageIntacctExportNonReimbursableExpense(policyID, row.value); }, [config?.export.nonReimbursable, policyID], ); @@ -131,12 +131,12 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { {creditCardAccount} { - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.SAGE_INTACCT_CONFIG.EXPORT, { + updateSageIntacctDefaultVendor(policyID, { nonReimbursableCreditCardChargeDefaultVendor: null, }); setIsSwitchOn(!isSwitchOn); diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx index 0e8fa0a340f5..3558835b3314 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx @@ -8,11 +8,11 @@ import Text from '@components/Text'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; -import * as Connections from '@libs/actions/connections'; import {getAdminEmployees, isExpensifyTeam} from '@libs/PolicyUtils'; import Navigation from '@navigation/Navigation'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import {updateSageIntacctExporter} from '@userActions/connections/SageIntacct'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -64,7 +64,7 @@ function SageIntacctPreferredExporterPage({policy}: WithPolicyProps) { const selectExporter = useCallback( (row: CardListItem) => { if (row.value !== exportConfiguration?.exporter) { - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.SAGE_INTACCT_CONFIG.EXPORT, {exporter: row.value}); + updateSageIntacctExporter(policyID, row.value); } Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID)); }, diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx index 38452f1d75b2..ee5968785bb9 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx @@ -10,11 +10,11 @@ import SelectionScreen from '@components/SelectionScreen'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; -import * as Connections from '@libs/actions/connections'; import Navigation from '@navigation/Navigation'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; +import {updateSageIntacctDefaultVendor, updateSageIntacctExportReimbursableExpense} from '@userActions/connections/SageIntacct'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import type {SageIntacctDataElementWithValue} from '@src/types/onyx/Policy'; @@ -55,7 +55,7 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { const selectExportDate = useCallback( (row: MenuListItem) => { if (row.value !== reimbursable) { - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.SAGE_INTACCT_CONFIG.EXPORT, {reimbursable: row.value}); + updateSageIntacctExportReimbursableExpense(policyID, row.value); } Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID)); }, @@ -107,14 +107,12 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { { - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.SAGE_INTACCT_CONFIG.EXPORT, { - reimbursableExpenseReportDefaultVendor: null, - }); + updateSageIntacctDefaultVendor(policyID, {reimbursableExpenseReportDefaultVendor: null}); setIsSwitchOn(!isSwitchOn); }} wrapperStyle={[styles.ph5, styles.pv3]} From bd51b4dfccad9bef916641b2f7b01ac53a27cdf1 Mon Sep 17 00:00:00 2001 From: war-in Date: Mon, 24 Jun 2024 17:40:25 +0200 Subject: [PATCH 17/50] update es translations --- src/languages/es.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index df2f8653df51..0f3a1c73fa80 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2258,7 +2258,8 @@ export default { creditCardAccount: 'Cuenta de tarjeta de crédito', creditCardAccountDescription: '!!!!!!!!', defaultVendor: 'Proveedor por defecto', - defaultVendorDescription: 'Establezca un proveedor predeterminado que se aplicará a los gastos no reembolsables que no tienen un proveedor coincidente en Sage Intacct.', + defaultVendorDescription: (isReimbursable: boolean): string => + `Establezca un proveedor predeterminado que se aplicará a los gastos ${isReimbursable ? '' : 'no '}reembolsables que no tienen un proveedor coincidente en Sage Intacct.`, exportDescription: 'Configure cómo se exportan los datos de Expensify a Sage Inacct.', exportPreferredExporterNote: 'El exportador preferido puede ser cualquier administrador del área de trabajo, pero también debe ser un administrador del dominio si establece diferentes cuentas de exportación para tarjetas de empresa individuales en Configuración del dominio.', From eb27d1912d5c5b06922059945efc0c40936a890a Mon Sep 17 00:00:00 2001 From: war-in Date: Mon, 24 Jun 2024 18:08:17 +0200 Subject: [PATCH 18/50] unify `noAccountsFound` translations --- src/languages/en.ts | 32 +++++++++---------- src/languages/es.ts | 32 +++++++++---------- .../export/SageIntacctDefaultVendorPage.tsx | 4 +-- ...ctNonReimbursableCreditCardAccountPage.tsx | 4 +-- .../advanced/QuickbooksAccountSelectPage.tsx | 4 +-- .../QuickbooksInvoiceAccountSelectPage.tsx | 4 +-- ...oksCompanyCardExpenseAccountSelectPage.tsx | 4 +-- ...ickbooksExportInvoiceAccountSelectPage.tsx | 4 +-- ...NonReimbursableDefaultVendorSelectPage.tsx | 4 +-- ...oksOutOfPocketExpenseAccountSelectPage.tsx | 4 +-- .../XeroBillPaymentAccountSelectorPage.tsx | 4 +-- .../XeroInvoiceAccountSelectorPage.tsx | 4 +-- .../xero/export/XeroBankAccountSelectPage.tsx | 4 +-- 13 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 7d4365211927..93a3cb9392f7 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -112,6 +112,19 @@ type States = Record; type AllCountries = Record; +function integrationName(integration: ConnectionName): string { + switch (integration) { + case CONST.POLICY.CONNECTIONS.NAME.QBO: + return 'Quickbooks Online'; + case CONST.POLICY.CONNECTIONS.NAME.XERO: + return 'Xero'; + case CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT: + return 'Sage Intacct'; + default: + return 'Integration'; + } +} + /* eslint-disable max-len */ export default { common: { @@ -1987,6 +2000,8 @@ export default { welcomeNote: ({workspaceName}: WelcomeNoteParams) => `You have been invited to ${workspaceName || 'a workspace'}! Download the Expensify mobile app at use.expensify.com/download to start tracking your expenses.`, subscription: 'Subscription', + noAccountsFound: 'No accounts found', + noAccountsFoundDescription: (integration: ConnectionName) => `Add the account in ${integrationName(integration)} and sync the connection again.`, }, qbo: { importDescription: 'Choose which coding configurations to import from QuickBooks Online to Expensify.', @@ -2099,8 +2114,6 @@ export default { [`${CONST.QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE.CHECK}Error`]: 'Checks are unavailable when locations are enabled. Please choose a different export option.', [`${CONST.QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE.JOURNAL_ENTRY}Error`]: 'Journal entries are unavailable when taxes are enabled. Please choose a different export option.', }, - noAccountsFound: 'No accounts found', - noAccountsFoundDescription: 'Add the account in Quickbooks Online and sync the connection again.', }, xero: { organization: 'Xero organization', @@ -2178,8 +2191,6 @@ export default { exportPreferredExporterNote: 'The preferred exporter can be any workspace admin, but must be a domain admin if you set different export accounts for individual company cards in domain settings.', exportPreferredExporterSubNote: 'Once set, the preferred exporter will see reports for export in their account.', - noAccountsFound: 'No accounts found', - noAccountsFoundDescription: 'Add the account in Xero and sync the connection again.', }, sageIntacct: { preferredExporter: 'Preferred exporter', @@ -2452,18 +2463,7 @@ export default { qbo: 'Quickbooks Online', xero: 'Xero', intacct: 'Sage Intacct', - integrationName: (integration?: ConnectionName): string => { - switch (integration) { - case CONST.POLICY.CONNECTIONS.NAME.QBO: - return 'Quickbooks Online'; - case CONST.POLICY.CONNECTIONS.NAME.XERO: - return 'Xero'; - case CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT: - return 'Sage Intacct'; - default: - return 'Integration'; - } - }, + integrationName, setup: 'Connect', lastSync: 'Last synced just now', import: 'Import', diff --git a/src/languages/es.ts b/src/languages/es.ts index 0f3a1c73fa80..141a17f26aa7 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -103,6 +103,19 @@ import type { ZipCodeExampleFormatParams, } from './types'; +function integrationName(integration: ConnectionName): string { + switch (integration) { + case CONST.POLICY.CONNECTIONS.NAME.QBO: + return 'Quickbooks Online'; + case CONST.POLICY.CONNECTIONS.NAME.XERO: + return 'Xero'; + case CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT: + return 'Sage Intacct'; + default: + return 'Integration'; + } +} + /* eslint-disable max-len */ export default { common: { @@ -2012,6 +2025,8 @@ export default { welcomeNote: ({workspaceName}: WelcomeNoteParams) => `¡Has sido invitado a ${workspaceName}! Descargue la aplicación móvil Expensify en use.expensify.com/download para comenzar a rastrear sus gastos.`, subscription: 'Suscripción', + noAccountsFound: 'No se ha encontrado ninguna cuenta', + noAccountsFoundDescription: (integration: ConnectionName) => `Añade la cuenta en ${integrationName(integration)} y sincroniza de nuevo la conexión.`, }, qbo: { importDescription: 'Elige que configuraciónes de codificación son importadas desde QuickBooks Online a Expensify.', @@ -2132,8 +2147,6 @@ export default { [`${CONST.QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE.JOURNAL_ENTRY}Error`]: 'El asiento de diario no está disponible cuando los impuestos están habilitados. Por favor, selecciona otra opción de exportación diferente.', }, - noAccountsFound: 'No se ha encontrado ninguna cuenta', - noAccountsFoundDescription: 'Añade la cuenta en Quickbooks Online y sincroniza de nuevo la conexión.', }, xero: { organization: 'Organización Xero', @@ -2214,8 +2227,6 @@ export default { exportPreferredExporterNote: 'Puede ser cualquier administrador del espacio de trabajo, pero debe ser un administrador de dominio si configura diferentes cuentas de exportación para tarjetas de empresa individuales en la configuración del dominio.', exportPreferredExporterSubNote: 'Una vez configurado, el exportador preferido verá los informes para exportar en su cuenta.', - noAccountsFound: 'No se ha encontrado ninguna cuenta', - noAccountsFoundDescription: 'Añade la cuenta en Xero y sincroniza de nuevo la conexión.', }, sageIntacct: { preferredExporter: 'Exportador preferido', @@ -2456,18 +2467,7 @@ export default { qbo: 'Quickbooks Online', xero: 'Xero', intacct: 'Sage Intacct', - integrationName: (integration?: ConnectionName): string => { - switch (integration) { - case CONST.POLICY.CONNECTIONS.NAME.QBO: - return 'Quickbooks Online'; - case CONST.POLICY.CONNECTIONS.NAME.XERO: - return 'Xero'; - case CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT: - return 'Sage Intacct'; - default: - return 'Integration'; - } - }, + integrationName, setup: 'Configurar', lastSync: 'Recién sincronizado', import: 'Importar', diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx index 8bd49e00fbc5..a6d431ee1708 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx @@ -79,8 +79,8 @@ function SageIntacctDefaultVendorPage({route}: SageIntacctDefaultVendorPageProps icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.xero.noAccountsFound')} - subtitle={translate('workspace.xero.noAccountsFoundDescription')} + title={translate('workspace.common.noAccountsFound')} + subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT)} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx index 157dc129094c..0037b8f54970 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx @@ -53,8 +53,8 @@ function SageIntacctNonReimbursableCreditCardAccountPage({policy}: WithPolicyCon icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.xero.noAccountsFound')} - subtitle={translate('workspace.xero.noAccountsFoundDescription')} + title={translate('workspace.common.noAccountsFound')} + subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT)} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx index 3c93bb683166..c0c360bc13ad 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx @@ -67,8 +67,8 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyConnectionsProps) { icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.qbo.noAccountsFound')} - subtitle={translate('workspace.qbo.noAccountsFoundDescription')} + title={translate('workspace.common.noAccountsFound')} + subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.QBO)} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx index 0459f61b88d6..b4425751dc35 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx @@ -68,8 +68,8 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyConnectionsProps icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.qbo.noAccountsFound')} - subtitle={translate('workspace.qbo.noAccountsFoundDescription')} + title={translate('workspace.common.noAccountsFound')} + subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.QBO)} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx index 013539334681..8ed75a402ba5 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx @@ -71,8 +71,8 @@ function QuickbooksCompanyCardExpenseAccountSelectPage({policy}: WithPolicyConne icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.qbo.noAccountsFound')} - subtitle={translate('workspace.qbo.noAccountsFoundDescription')} + title={translate('workspace.common.noAccountsFound')} + subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.QBO)} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx index b95e70fe11dd..a07fe1c6deb9 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx @@ -57,8 +57,8 @@ function QuickbooksExportInvoiceAccountSelectPage({policy}: WithPolicyConnection icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.qbo.noAccountsFound')} - subtitle={translate('workspace.qbo.noAccountsFoundDescription')} + title={translate('workspace.common.noAccountsFound')} + subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.QBO)} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksNonReimbursableDefaultVendorSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksNonReimbursableDefaultVendorSelectPage.tsx index 55c5cf7e9898..5bcabbfbf2fa 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksNonReimbursableDefaultVendorSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksNonReimbursableDefaultVendorSelectPage.tsx @@ -56,8 +56,8 @@ function QuickbooksNonReimbursableDefaultVendorSelectPage({policy}: WithPolicyCo icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.qbo.noAccountsFound')} - subtitle={translate('workspace.qbo.noAccountsFoundDescription')} + title={translate('workspace.common.noAccountsFound')} + subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.QBO)} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx index 50b44640642b..12594947619b 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx @@ -95,8 +95,8 @@ function QuickbooksOutOfPocketExpenseAccountSelectPage({policy}: WithPolicyConne icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.qbo.noAccountsFound')} - subtitle={translate('workspace.qbo.noAccountsFoundDescription')} + title={translate('workspace.common.noAccountsFound')} + subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.QBO)} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/xero/advanced/XeroBillPaymentAccountSelectorPage.tsx b/src/pages/workspace/accounting/xero/advanced/XeroBillPaymentAccountSelectorPage.tsx index 05b7cf877d33..5b5bf3e92baa 100644 --- a/src/pages/workspace/accounting/xero/advanced/XeroBillPaymentAccountSelectorPage.tsx +++ b/src/pages/workspace/accounting/xero/advanced/XeroBillPaymentAccountSelectorPage.tsx @@ -53,8 +53,8 @@ function XeroBillPaymentAccountSelectorPage({policy}: WithPolicyConnectionsProps icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.xero.noAccountsFound')} - subtitle={translate('workspace.xero.noAccountsFoundDescription')} + title={translate('workspace.common.noAccountsFound')} + subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.XERO)} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/xero/advanced/XeroInvoiceAccountSelectorPage.tsx b/src/pages/workspace/accounting/xero/advanced/XeroInvoiceAccountSelectorPage.tsx index 49fac2e38a9b..c5ec54bc3859 100644 --- a/src/pages/workspace/accounting/xero/advanced/XeroInvoiceAccountSelectorPage.tsx +++ b/src/pages/workspace/accounting/xero/advanced/XeroInvoiceAccountSelectorPage.tsx @@ -53,8 +53,8 @@ function XeroInvoiceAccountSelectorPage({policy}: WithPolicyConnectionsProps) { icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.xero.noAccountsFound')} - subtitle={translate('workspace.xero.noAccountsFoundDescription')} + title={translate('workspace.common.noAccountsFound')} + subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.XERO)} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/xero/export/XeroBankAccountSelectPage.tsx b/src/pages/workspace/accounting/xero/export/XeroBankAccountSelectPage.tsx index 76a6c9cabed1..ff2a484205a5 100644 --- a/src/pages/workspace/accounting/xero/export/XeroBankAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/xero/export/XeroBankAccountSelectPage.tsx @@ -55,8 +55,8 @@ function XeroBankAccountSelectPage({policy}: WithPolicyConnectionsProps) { icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.xero.noAccountsFound')} - subtitle={translate('workspace.xero.noAccountsFoundDescription')} + title={translate('workspace.common.noAccountsFound')} + subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.XERO)} containerStyle={styles.pb10} /> ), From 9dd45824512ec205e8f42762bd73a25329dca592 Mon Sep 17 00:00:00 2001 From: war-in Date: Mon, 24 Jun 2024 18:18:09 +0200 Subject: [PATCH 19/50] test on empty list --- src/languages/en.ts | 1 + .../accounting/intacct/export/SageIntacctDefaultVendorPage.tsx | 1 - .../export/SageIntacctNonReimbursableCreditCardAccountPage.tsx | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 93a3cb9392f7..a4dc962de0c8 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2231,6 +2231,7 @@ export default { }, }, creditCardAccount: 'Credit card account', + // TODO: verify if we need description creditCardAccountDescription: 'We should have some description here, right?', defaultVendor: 'Default vendor', defaultVendorDescription: (isReimbursable: boolean): string => diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx index a6d431ee1708..b42115ae0379 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx @@ -72,7 +72,6 @@ function SageIntacctDefaultVendorPage({route}: SageIntacctDefaultVendorPageProps [defaultVendor, policyID, isReimbursable, policy?.connections?.intacct?.config.export], ); - // TODO: test on empty list const listEmptyContent = useMemo( () => ( ( Date: Tue, 25 Jun 2024 11:47:11 +0200 Subject: [PATCH 20/50] disable going back for expense report --- .../intacct/export/SageIntacctReimbursableExpensesPage.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx index ee5968785bb9..d1eb2fec330d 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx @@ -57,7 +57,9 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { if (row.value !== reimbursable) { updateSageIntacctExportReimbursableExpense(policyID, row.value); } - Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID)); + if (row.value === CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL) { + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID)); + } }, [reimbursable, policyID], ); From 5367c73e0de4c967b5ec16be1b9aa5313f242d17 Mon Sep 17 00:00:00 2001 From: war-in Date: Tue, 25 Jun 2024 16:45:37 +0200 Subject: [PATCH 21/50] adjust hasError and pendingAction fields --- src/libs/PolicyUtils.ts | 4 +- src/libs/actions/connections/SageIntacct.ts | 85 +++++++++---------- .../export/SageIntacctDefaultVendorPage.tsx | 15 ++-- .../intacct/export/SageIntacctExportPage.tsx | 20 ++--- ...SageIntacctNonReimbursableExpensesPage.tsx | 18 ++-- .../SageIntacctReimbursableExpensesPage.tsx | 6 +- src/types/onyx/Policy.ts | 7 +- 7 files changed, 78 insertions(+), 77 deletions(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 5c8c8df236b0..33260c80b5e2 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -479,7 +479,7 @@ function getSageIntacctVendors(policy: Policy | undefined, selectedVendorId: str })); } -function getSageIntacctNonReimbursableActiveDefaultVendor(policy: Policy | undefined): string | null | undefined { +function getSageIntacctNonReimbursableActiveDefaultVendor(policy?: Policy): string | null | undefined { const { nonReimbursableCreditCardChargeDefaultVendor: creditCardDefaultVendor, nonReimbursableVendor: expenseReportDefaultVendor, @@ -489,7 +489,7 @@ function getSageIntacctNonReimbursableActiveDefaultVendor(policy: Policy | undef return nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE ? creditCardDefaultVendor : expenseReportDefaultVendor; } -function getSageIntacctCreditCards(policy: Policy | undefined, selectedAccount: string | undefined): SelectorType[] { +function getSageIntacctCreditCards(policy?: Policy, selectedAccount?: string): SelectorType[] { const creditCards = policy?.connections?.intacct?.data?.creditCards ?? []; const isMatchFound = creditCards?.some(({name}) => name === selectedAccount); diff --git a/src/libs/actions/connections/SageIntacct.ts b/src/libs/actions/connections/SageIntacct.ts index e2e7eec41491..0f3b77d98f39 100644 --- a/src/libs/actions/connections/SageIntacct.ts +++ b/src/libs/actions/connections/SageIntacct.ts @@ -6,28 +6,25 @@ import {WRITE_COMMANDS} from '@libs/API/types'; import * as ErrorUtils from '@libs/ErrorUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {ConnectionName, Connections} from '@src/types/onyx/Policy'; +import type {Connections} from '@src/types/onyx/Policy'; -function prepareOnyxData( - policyID: string, - connectionName: TConnectionName, - settingName: TSettingName, - settingValue: Partial, -) { +function prepareOnyxData(policyID: string, settingName: keyof Connections['intacct']['config']['export'], settingValue: string | null) { const optimisticData: OnyxUpdate[] = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, value: { connections: { - [connectionName]: { + intacct: { config: { - [settingName]: settingValue ?? null, - pendingFields: { - [settingName]: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, - }, - errorFields: { - [settingName]: null, + export: { + [settingName]: settingValue, + pendingFields: { + [settingName]: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + errorFields: { + [settingName]: null, + }, }, }, }, @@ -42,14 +39,16 @@ function prepareOnyxData) { - return prepareOnyxData(policyID, CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, CONST.SAGE_INTACCT_CONFIG.EXPORT, settingValue); -} - -function prepareParametersForExport(policyID: string, settingValue: Partial) { +function prepareParametersForExport(policyID: string, settingName: keyof Connections['intacct']['config']['export'], settingValue: string | null) { return { policyID, connectionName: CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, settingName: CONST.SAGE_INTACCT_CONFIG.EXPORT, - settingValue: JSON.stringify(settingValue), + settingValue: JSON.stringify({[settingName]: settingValue}), idempotencyKey: CONST.SAGE_INTACCT_CONFIG.EXPORT, }; } -function updateSageIntacctExport(policyID: string, settingValue: Partial) { - const {optimisticData, failureData, successData} = prepareOnyxDataForExport(policyID, settingValue); - const parameters = prepareParametersForExport(policyID, settingValue); +function updateSageIntacctExport(policyID: string, settingName: keyof Connections['intacct']['config']['export'], settingValue: string | null) { + const {optimisticData, failureData, successData} = prepareOnyxData(policyID, settingName, settingValue); + const parameters = prepareParametersForExport(policyID, settingName, settingValue); API.write(WRITE_COMMANDS.UPDATE_POLICY_CONNECTION_CONFIG, parameters, {optimisticData, failureData, successData}); } function updateSageIntacctExporter(policyID: string, exporter: string) { - updateSageIntacctExport(policyID, {exporter}); + updateSageIntacctExport(policyID, 'exporter', exporter); } function updateSageIntacctExportDate(policyID: string, date: ValueOf) { - updateSageIntacctExport(policyID, {exportDate: date}); + updateSageIntacctExport(policyID, 'exportDate', date); } function updateSageIntacctExportReimbursableExpense(policyID: string, reimbursable: ValueOf) { - updateSageIntacctExport(policyID, {reimbursable}); + updateSageIntacctExport(policyID, 'reimbursable', reimbursable); } -function updateSageIntacctDefaultVendor(policyID: string, settingValue: Partial) { - updateSageIntacctExport(policyID, settingValue); +function updateSageIntacctDefaultVendor(policyID: string, settingName: keyof Connections['intacct']['config']['export'], settingValue: string | null) { + updateSageIntacctExport(policyID, settingName, settingValue); } function updateSageIntacctExportNonReimbursableExpense(policyID: string, nonReimbursable: ValueOf) { - updateSageIntacctExport(policyID, {nonReimbursable}); + updateSageIntacctExport(policyID, 'nonReimbursable', nonReimbursable); } function updateSageIntacctExportNonReimbursableAccount(policyID: string, nonReimbursableAccount: string) { - updateSageIntacctExport(policyID, {nonReimbursableAccount}); + updateSageIntacctExport(policyID, 'nonReimbursableAccount', nonReimbursableAccount); } export { diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx index b42115ae0379..790d521a25a1 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx @@ -19,6 +19,7 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; +import type {Connections} from '@src/types/onyx/Policy'; type SageIntacctDefaultVendorPageProps = StackScreenProps; @@ -53,19 +54,15 @@ function SageIntacctDefaultVendorPage({route}: SageIntacctDefaultVendorPageProps const updateDefaultVendor = useCallback( ({value}: SelectorType) => { if (value !== defaultVendor) { - let settingValue; + let settingName: keyof Connections['intacct']['config']['export']; if (isReimbursable) { - settingValue = {reimbursableExpenseReportDefaultVendor: value}; + settingName = 'reimbursableExpenseReportDefaultVendor'; } else { const {nonReimbursable} = policy?.connections?.intacct?.config.export ?? {}; - settingValue = - nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE - ? { - nonReimbursableCreditCardChargeDefaultVendor: value, - } - : {nonReimbursableVendor: value}; + settingName = + nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE ? 'nonReimbursableCreditCardChargeDefaultVendor' : 'nonReimbursableVendor'; } - updateSageIntacctDefaultVendor(policyID, settingValue); + updateSageIntacctDefaultVendor(policyID, settingName, value); } Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID)); }, diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx index dc9686710dad..565aeacc185a 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx @@ -15,7 +15,7 @@ function SageIntacctExportPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); const policyID = policy?.id ?? '-1'; - const {export: exportConfig, pendingFields, errorFields, credentials} = policy?.connections?.intacct?.config ?? {}; + const {export: exportConfig, credentials} = policy?.connections?.intacct?.config ?? {}; const sections = useMemo( () => [ @@ -23,15 +23,15 @@ function SageIntacctExportPage({policy}: WithPolicyProps) { description: translate('workspace.sageIntacct.preferredExporter'), action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_PREFERRED_EXPORTER.getRoute(policyID)), title: exportConfig?.exporter ?? translate('workspace.sageIntacct.notConfigured'), - hasError: !!errorFields?.exporter, - pendingAction: pendingFields?.export, + hasError: !!exportConfig?.errorFields?.exporter, + pendingAction: exportConfig?.pendingFields?.exporter, }, { description: translate('workspace.sageIntacct.exportDate.label'), action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT_DATE.getRoute(policyID)), title: exportConfig?.exportDate ? translate(`workspace.sageIntacct.exportDate.values.${exportConfig.exportDate}.label`) : translate(`workspace.sageIntacct.notConfigured`), - hasError: !!errorFields?.exportDate, - pendingAction: pendingFields?.export, + hasError: !!exportConfig?.errorFields?.exportDate, + pendingAction: exportConfig?.pendingFields?.exportDate, }, { description: translate('workspace.sageIntacct.reimbursableExpenses.label'), @@ -39,8 +39,8 @@ function SageIntacctExportPage({policy}: WithPolicyProps) { title: exportConfig?.reimbursable ? translate(`workspace.sageIntacct.reimbursableExpenses.values.${exportConfig.reimbursable}`) : translate('workspace.sageIntacct.notConfigured'), - hasError: !!errorFields?.reimbursable, - pendingAction: pendingFields?.export, + hasError: !!exportConfig?.errorFields?.reimbursable, + pendingAction: exportConfig?.pendingFields?.reimbursable, }, { description: translate('workspace.sageIntacct.nonReimbursableExpenses.label'), @@ -48,11 +48,11 @@ function SageIntacctExportPage({policy}: WithPolicyProps) { title: exportConfig?.nonReimbursable ? translate(`workspace.sageIntacct.nonReimbursableExpenses.values.${exportConfig.nonReimbursable}`) : translate('workspace.sageIntacct.notConfigured'), - hasError: !!errorFields?.nonReimbursable, - pendingAction: pendingFields?.export, + hasError: !!exportConfig?.errorFields?.nonReimbursable, + pendingAction: exportConfig?.pendingFields?.nonReimbursable, }, ], - [errorFields, exportConfig, pendingFields, policyID, translate], + [exportConfig, policyID, translate], ); return ( diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx index 718870df8d92..e96166a6c7d8 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx @@ -67,8 +67,14 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { description: translate('workspace.sageIntacct.defaultVendor'), action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_DEFAULT_VENDOR.getRoute(policyID, 'non-reimbursable')), title: activeDefaultVendor ? getDefaultVendorName(activeDefaultVendor, intacctData?.vendors ?? []) : translate('workspace.sageIntacct.notConfigured'), - hasError: !!config?.errorFields?.exporter, - pendingAction: config?.pendingFields?.export, + hasError: + config?.export.nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL + ? !!config?.export?.errorFields?.nonReimbursableVendor + : !!config?.export?.errorFields?.nonReimbursableCreditCardChargeDefaultVendor, + pendingAction: + config?.export.nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL + ? config?.export?.pendingFields?.nonReimbursableVendor + : config?.export?.pendingFields?.nonReimbursableCreditCardChargeDefaultVendor, }; const defaultVendor = ( @@ -90,8 +96,8 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { description: translate('workspace.sageIntacct.creditCardAccount'), action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT.getRoute(policyID)), title: config?.export.nonReimbursableAccount ? config.export.nonReimbursableAccount : translate('workspace.sageIntacct.notConfigured'), - hasError: !!config?.errorFields?.exporter, - pendingAction: config?.pendingFields?.export, + hasError: !!config?.export?.errorFields?.nonReimbursableAccount, + pendingAction: config?.export?.pendingFields?.nonReimbursableAccount, }; const creditCardAccount = ( @@ -136,9 +142,7 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { switchAccessibilityLabel={translate('workspace.sageIntacct.defaultVendor')} isActive={isSwitchOn} onToggle={() => { - updateSageIntacctDefaultVendor(policyID, { - nonReimbursableCreditCardChargeDefaultVendor: null, - }); + updateSageIntacctDefaultVendor(policyID, 'nonReimbursableCreditCardChargeDefaultVendor', null); setIsSwitchOn(!isSwitchOn); }} wrapperStyle={[styles.ph5, styles.pv3]} diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx index d1eb2fec330d..6020652dcaf1 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx @@ -70,8 +70,8 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { title: reimbursableExpenseReportDefaultVendor ? getDefaultVendorName(reimbursableExpenseReportDefaultVendor, intacctData?.vendors ?? []) : translate('workspace.sageIntacct.notConfigured'), - hasError: !!config?.errorFields?.exporter, - pendingAction: config?.pendingFields?.export, + hasError: !!config?.export?.errorFields?.reimbursableExpenseReportDefaultVendor, + pendingAction: config?.export?.pendingFields?.reimbursableExpenseReportDefaultVendor, }; const defaultVendor = ( @@ -114,7 +114,7 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { switchAccessibilityLabel={translate('workspace.sageIntacct.defaultVendor')} isActive={isSwitchOn} onToggle={() => { - updateSageIntacctDefaultVendor(policyID, {reimbursableExpenseReportDefaultVendor: null}); + updateSageIntacctDefaultVendor(policyID, 'reimbursableExpenseReportDefaultVendor', null); setIsSwitchOn(!isSwitchOn); }} wrapperStyle={[styles.ph5, styles.pv3]} diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 1a26722492f0..718e62d2c1e0 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -634,7 +634,7 @@ type SageIntacctConnectiosConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ }; /** Sage Intacct export configs */ - export: { + export: OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Current export status */ exportDate: ValueOf; @@ -658,7 +658,10 @@ type SageIntacctConnectiosConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** */ reimbursableExpenseReportDefaultVendor: string | null; - }; + + /** Collection of mapping field errors, which will be triggered when update action fails */ + errorFields?: OnyxCommon.ErrorFields; + }>; /** Collection of Sage Intacct config errors */ errors?: OnyxCommon.Errors; From b0fb1771def222b8540dd02118996cc6120c3d77 Mon Sep 17 00:00:00 2001 From: war-in Date: Tue, 25 Jun 2024 17:29:09 +0200 Subject: [PATCH 22/50] show error messages --- src/libs/actions/Policy/Policy.ts | 5 ++ .../intacct/export/SageIntacctDatePage.tsx | 45 +++++++++------ .../export/SageIntacctDefaultVendorPage.tsx | 55 ++++++++++++------- ...ctNonReimbursableCreditCardAccountPage.tsx | 45 +++++++++------ ...SageIntacctNonReimbursableExpensesPage.tsx | 10 +++- .../SageIntacctPreferredExporterPage.tsx | 37 ++++++++----- .../SageIntacctReimbursableExpensesPage.tsx | 10 +++- 7 files changed, 133 insertions(+), 74 deletions(-) diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index a81dc08ba587..e155a99c4151 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -528,6 +528,10 @@ function clearXeroErrorField(policyID: string, fieldName: string) { Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {connections: {xero: {config: {errorFields: {[fieldName]: null}}}}}); } +function clearSageIntacctExportErrorField(policyID: string, fieldName: string) { + Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {connections: {intacct: {config: {export: {errorFields: {[fieldName]: null}}}}}}); +} + function setWorkspaceReimbursement(policyID: string, reimbursementChoice: ValueOf, reimburserEmail: string) { const policy = getPolicy(policyID); @@ -2992,6 +2996,7 @@ export { generateCustomUnitID, clearQBOErrorField, clearXeroErrorField, + clearSageIntacctExportErrorField, clearWorkspaceReimbursementErrors, setWorkspaceCurrencyDefault, setForeignCurrencyDefault, diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx index 7af7c46b8c1e..430a8d69dd23 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx @@ -1,6 +1,7 @@ import React, {useCallback, useMemo} from 'react'; import {View} from 'react-native'; import type {ValueOf} from 'type-fest'; +import OfflineWithFeedback from '@components/OfflineWithFeedback'; import RadioListItem from '@components/SelectionList/RadioListItem'; import type {ListItem} from '@components/SelectionList/types'; import SelectionScreen from '@components/SelectionScreen'; @@ -8,10 +9,12 @@ import type {SelectorType} from '@components/SelectionScreen'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@navigation/Navigation'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import {updateSageIntacctExportDate} from '@userActions/connections/SageIntacct'; +import * as Policy from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -23,13 +26,13 @@ function SageIntacctDatePage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const policyID = policy?.id ?? '-1'; const styles = useThemeStyles(); - const {exportDate} = policy?.connections?.intacct?.config?.export ?? {}; + const {export: exportConfig} = policy?.connections?.intacct?.config ?? {}; const data: MenuListItem[] = Object.values(CONST.SAGE_INTACCT_EXPORT_DATE).map((dateType) => ({ value: dateType, text: translate(`workspace.sageIntacct.exportDate.values.${dateType}.label`), alternateText: translate(`workspace.sageIntacct.exportDate.values.${dateType}.description`), keyForList: dateType, - isSelected: exportDate === dateType, + isSelected: exportConfig?.exportDate === dateType, })); const headerContent = useMemo( @@ -43,29 +46,35 @@ function SageIntacctDatePage({policy}: WithPolicyProps) { const selectExportDate = useCallback( (row: MenuListItem) => { - if (row.value !== exportDate) { + if (row.value !== exportConfig?.exportDate) { updateSageIntacctExportDate(policyID, row.value); } Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID)); }, - [exportDate, policyID], + [exportConfig?.exportDate, policyID], ); return ( - selectExportDate(selection as MenuListItem)} - initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} - policyID={policyID} - accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]} - featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} - onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID))} - connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} - /> + Policy.clearSageIntacctExportErrorField(policyID, 'exportDate')} + > + selectExportDate(selection as MenuListItem)} + initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} + policyID={policyID} + accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]} + featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} + onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID))} + connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} + /> + ); } diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx index 790d521a25a1..a128b7e56915 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx @@ -4,17 +4,20 @@ import {View} from 'react-native'; import {useOnyx} from 'react-native-onyx'; import BlockingView from '@components/BlockingViews/BlockingView'; import * as Illustrations from '@components/Icon/Illustrations'; +import OfflineWithFeedback from '@components/OfflineWithFeedback'; import RadioListItem from '@components/SelectionList/RadioListItem'; import type {SelectorType} from '@components/SelectionScreen'; import SelectionScreen from '@components/SelectionScreen'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; import {getSageIntacctNonReimbursableActiveDefaultVendor, getSageIntacctVendors} from '@libs/PolicyUtils'; import type {SettingsNavigatorParamList} from '@navigation/types'; import variables from '@styles/variables'; import {updateSageIntacctDefaultVendor} from '@userActions/connections/SageIntacct'; +import * as Policy from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; @@ -29,15 +32,20 @@ function SageIntacctDefaultVendorPage({route}: SageIntacctDefaultVendorPageProps const policyID = route.params.policyID ?? '-1'; const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); + const {export: exportConfig} = policy?.connections?.intacct?.config ?? {}; const isReimbursable = route.params.reimbursable === 'reimbursable'; let defaultVendor; + let errorFieldName; if (!isReimbursable) { + const {nonReimbursable} = policy?.connections?.intacct?.config.export ?? {}; defaultVendor = getSageIntacctNonReimbursableActiveDefaultVendor(policy); + errorFieldName = nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE ? 'nonReimbursableCreditCardChargeDefaultVendor' : 'nonReimbursableVendor'; } else { const {reimbursableExpenseReportDefaultVendor} = policy?.connections?.intacct?.config.export ?? {}; defaultVendor = reimbursableExpenseReportDefaultVendor; + errorFieldName = 'reimbursableExpenseReportDefaultVendor'; } const vendorSelectorOptions = useMemo(() => getSageIntacctVendors(policy ?? undefined, defaultVendor), [defaultVendor, policy]); @@ -84,26 +92,33 @@ function SageIntacctDefaultVendorPage({route}: SageIntacctDefaultVendorPageProps ); return ( - mode.isSelected)?.keyForList} - headerContent={listHeaderComponent} - onBackButtonPress={() => - Navigation.goBack( - isReimbursable - ? ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_REIMBURSABLE_EXPENSES.getRoute(policyID) - : ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID), - ) - } - title="workspace.sageIntacct.defaultVendor" - listEmptyContent={listEmptyContent} - connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} - /> + // TODO: add scroll here + Policy.clearSageIntacctExportErrorField(policyID, errorFieldName)} + > + mode.isSelected)?.keyForList} + headerContent={listHeaderComponent} + onBackButtonPress={() => + Navigation.goBack( + isReimbursable + ? ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_REIMBURSABLE_EXPENSES.getRoute(policyID) + : ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID), + ) + } + title="workspace.sageIntacct.defaultVendor" + listEmptyContent={listEmptyContent} + connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} + /> + ); } diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx index 676c6db23f69..570a554f9123 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx @@ -2,18 +2,21 @@ import React, {useCallback, useMemo} from 'react'; import {View} from 'react-native'; import BlockingView from '@components/BlockingViews/BlockingView'; import * as Illustrations from '@components/Icon/Illustrations'; +import OfflineWithFeedback from '@components/OfflineWithFeedback'; import RadioListItem from '@components/SelectionList/RadioListItem'; import type {SelectorType} from '@components/SelectionScreen'; import SelectionScreen from '@components/SelectionScreen'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; import {getSageIntacctCreditCards} from '@libs/PolicyUtils'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import variables from '@styles/variables'; import {updateSageIntacctExportNonReimbursableAccount} from '@userActions/connections/SageIntacct'; +import * as Policy from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -23,9 +26,9 @@ function SageIntacctNonReimbursableCreditCardAccountPage({policy}: WithPolicyCon const policyID = policy?.id ?? '-1'; - const {nonReimbursableAccount} = policy?.connections?.intacct?.config.export ?? {}; + const {export: exportConfig} = policy?.connections?.intacct?.config ?? {}; - const creditCardSelectorOptions = useMemo(() => getSageIntacctCreditCards(policy, nonReimbursableAccount), [nonReimbursableAccount, policy]); + const creditCardSelectorOptions = useMemo(() => getSageIntacctCreditCards(policy, exportConfig?.nonReimbursableAccount), [exportConfig?.nonReimbursableAccount, policy]); const listHeaderComponent = useMemo( () => ( @@ -38,12 +41,12 @@ function SageIntacctNonReimbursableCreditCardAccountPage({policy}: WithPolicyCon const updateCreditCardAccount = useCallback( ({value}: SelectorType) => { - if (value !== nonReimbursableAccount) { + if (value !== exportConfig?.nonReimbursableAccount) { updateSageIntacctExportNonReimbursableAccount(policyID, value); } Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID)); }, - [policyID, nonReimbursableAccount], + [policyID, exportConfig?.nonReimbursableAccount], ); const listEmptyContent = useMemo( @@ -61,20 +64,26 @@ function SageIntacctNonReimbursableCreditCardAccountPage({policy}: WithPolicyCon ); return ( - mode.isSelected)?.keyForList} - headerContent={listHeaderComponent} - onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID))} - title="workspace.sageIntacct.creditCardAccount" - listEmptyContent={listEmptyContent} - connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} - /> + Policy.clearSageIntacctExportErrorField(policyID, 'nonReimbursableAccount')} + > + mode.isSelected)?.keyForList} + headerContent={listHeaderComponent} + onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID))} + title="workspace.sageIntacct.creditCardAccount" + listEmptyContent={listEmptyContent} + connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} + /> + ); } diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx index e96166a6c7d8..46ec7bc82dc0 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx @@ -10,12 +10,14 @@ import SelectionScreen from '@components/SelectionScreen'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import * as ErrorUtils from '@libs/ErrorUtils'; import {getSageIntacctNonReimbursableActiveDefaultVendor} from '@libs/PolicyUtils'; import Navigation from '@navigation/Navigation'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; import {updateSageIntacctDefaultVendor, updateSageIntacctExportNonReimbursableExpense} from '@userActions/connections/SageIntacct'; +import * as Policy from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import type {SageIntacctDataElementWithValue} from '@src/types/onyx/Policy'; @@ -116,7 +118,11 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { ); return ( - + Policy.clearSageIntacctExportErrorField(policyID, 'nonReimbursable')} + > )} - + ); } diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx index 3558835b3314..d43fe15356f7 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx @@ -1,6 +1,7 @@ import {isEmpty} from 'lodash'; import React, {useCallback, useMemo} from 'react'; import {View} from 'react-native'; +import OfflineWithFeedback from '@components/OfflineWithFeedback'; import RadioListItem from '@components/SelectionList/RadioListItem'; import type {ListItem} from '@components/SelectionList/types'; import SelectionScreen from '@components/SelectionScreen'; @@ -8,11 +9,13 @@ import Text from '@components/Text'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import * as ErrorUtils from '@libs/ErrorUtils'; import {getAdminEmployees, isExpensifyTeam} from '@libs/PolicyUtils'; import Navigation from '@navigation/Navigation'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import {updateSageIntacctExporter} from '@userActions/connections/SageIntacct'; +import * as Policy from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -82,20 +85,26 @@ function SageIntacctPreferredExporterPage({policy}: WithPolicyProps) { ); return ( - mode.isSelected)?.keyForList} - onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID))} - title="workspace.sageIntacct.preferredExporter" - connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} - /> + Policy.clearSageIntacctExportErrorField(policyID, 'exporter')} + > + mode.isSelected)?.keyForList} + onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID))} + title="workspace.sageIntacct.preferredExporter" + connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} + /> + ); } diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx index 6020652dcaf1..d511b067c34a 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx @@ -10,11 +10,13 @@ import SelectionScreen from '@components/SelectionScreen'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@navigation/Navigation'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; import {updateSageIntacctDefaultVendor, updateSageIntacctExportReimbursableExpense} from '@userActions/connections/SageIntacct'; +import * as Policy from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import type {SageIntacctDataElementWithValue} from '@src/types/onyx/Policy'; @@ -90,7 +92,11 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { ); return ( - + Policy.clearSageIntacctExportErrorField(policyID, 'reimbursable')} + > )} - + ); } From fec221a8141608f5a3e06ce6f0d676f4598c4b54 Mon Sep 17 00:00:00 2001 From: war-in Date: Tue, 25 Jun 2024 18:09:46 +0200 Subject: [PATCH 23/50] add pending to toggles --- .../intacct/export/SageIntacctNonReimbursableExpensesPage.tsx | 1 + .../intacct/export/SageIntacctReimbursableExpensesPage.tsx | 1 + 2 files changed, 2 insertions(+) diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx index 46ec7bc82dc0..9a1949349055 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx @@ -152,6 +152,7 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { setIsSwitchOn(!isSwitchOn); }} wrapperStyle={[styles.ph5, styles.pv3]} + pendingAction={config?.export?.pendingFields?.nonReimbursableCreditCardChargeDefaultVendor} /> {isSwitchOn && defaultVendor} diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx index d511b067c34a..dcc93a068df2 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx @@ -124,6 +124,7 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { setIsSwitchOn(!isSwitchOn); }} wrapperStyle={[styles.ph5, styles.pv3]} + pendingAction={config?.export?.pendingFields?.reimbursableExpenseReportDefaultVendor} /> {isSwitchOn && defaultVendor} From f87450e55be599d533bebf17ffaf692a358a017a Mon Sep 17 00:00:00 2001 From: war-in Date: Tue, 25 Jun 2024 18:24:09 +0200 Subject: [PATCH 24/50] add sage intacct config consts --- src/CONST.ts | 8 +++++++ src/libs/actions/connections/SageIntacct.ts | 10 ++++---- .../intacct/export/SageIntacctDatePage.tsx | 4 ++-- .../export/SageIntacctDefaultVendorPage.tsx | 23 ++++++++----------- ...ctNonReimbursableCreditCardAccountPage.tsx | 4 ++-- ...SageIntacctNonReimbursableExpensesPage.tsx | 6 ++--- .../SageIntacctPreferredExporterPage.tsx | 4 ++-- .../SageIntacctReimbursableExpensesPage.tsx | 6 ++--- 8 files changed, 34 insertions(+), 31 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 9115f23cf107..9f7eb817cc61 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1335,6 +1335,14 @@ const CONST = { SAGE_INTACCT_CONFIG: { EXPORT: 'export', + EXPORT_DATE: 'exportDate', + NON_REIMBURSABLE_CREDIT_CARD_VENDOR: 'nonReimbursableCreditCardChargeDefaultVendor', + NON_REIMBURSABLE_VENDOR: 'nonReimbursableVendor', + REIMBURSABLE_VENDOR: 'reimbursableExpenseReportDefaultVendor', + NON_REIMBURSABLE_ACCOUNT: 'nonReimbursableAccount', + NON_REIMBURSABLE: 'nonReimbursable', + EXPORTER: 'exporter', + REIMBURSABLE: 'reimbursable', }, QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE: { diff --git a/src/libs/actions/connections/SageIntacct.ts b/src/libs/actions/connections/SageIntacct.ts index 0f3b77d98f39..5140ad1ef537 100644 --- a/src/libs/actions/connections/SageIntacct.ts +++ b/src/libs/actions/connections/SageIntacct.ts @@ -102,15 +102,15 @@ function updateSageIntacctExport(policyID: string, settingName: keyof Connection } function updateSageIntacctExporter(policyID: string, exporter: string) { - updateSageIntacctExport(policyID, 'exporter', exporter); + updateSageIntacctExport(policyID, CONST.SAGE_INTACCT_CONFIG.EXPORTER, exporter); } function updateSageIntacctExportDate(policyID: string, date: ValueOf) { - updateSageIntacctExport(policyID, 'exportDate', date); + updateSageIntacctExport(policyID, CONST.SAGE_INTACCT_CONFIG.EXPORT_DATE, date); } function updateSageIntacctExportReimbursableExpense(policyID: string, reimbursable: ValueOf) { - updateSageIntacctExport(policyID, 'reimbursable', reimbursable); + updateSageIntacctExport(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE, reimbursable); } function updateSageIntacctDefaultVendor(policyID: string, settingName: keyof Connections['intacct']['config']['export'], settingValue: string | null) { @@ -118,11 +118,11 @@ function updateSageIntacctDefaultVendor(policyID: string, settingName: keyof Con } function updateSageIntacctExportNonReimbursableExpense(policyID: string, nonReimbursable: ValueOf) { - updateSageIntacctExport(policyID, 'nonReimbursable', nonReimbursable); + updateSageIntacctExport(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE, nonReimbursable); } function updateSageIntacctExportNonReimbursableAccount(policyID: string, nonReimbursableAccount: string) { - updateSageIntacctExport(policyID, 'nonReimbursableAccount', nonReimbursableAccount); + updateSageIntacctExport(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_ACCOUNT, nonReimbursableAccount); } export { diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx index 430a8d69dd23..2a138d25360e 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx @@ -56,9 +56,9 @@ function SageIntacctDatePage({policy}: WithPolicyProps) { return ( Policy.clearSageIntacctExportErrorField(policyID, 'exportDate')} + onClose={() => Policy.clearSageIntacctExportErrorField(policyID, CONST.SAGE_INTACCT_CONFIG.EXPORT_DATE)} > (() => getSageIntacctVendors(policy ?? undefined, defaultVendor), [defaultVendor, policy]); @@ -62,19 +65,11 @@ function SageIntacctDefaultVendorPage({route}: SageIntacctDefaultVendorPageProps const updateDefaultVendor = useCallback( ({value}: SelectorType) => { if (value !== defaultVendor) { - let settingName: keyof Connections['intacct']['config']['export']; - if (isReimbursable) { - settingName = 'reimbursableExpenseReportDefaultVendor'; - } else { - const {nonReimbursable} = policy?.connections?.intacct?.config.export ?? {}; - settingName = - nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE ? 'nonReimbursableCreditCardChargeDefaultVendor' : 'nonReimbursableVendor'; - } updateSageIntacctDefaultVendor(policyID, settingName, value); } Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID)); }, - [defaultVendor, policyID, isReimbursable, policy?.connections?.intacct?.config.export], + [defaultVendor, policyID, settingName], ); const listEmptyContent = useMemo( @@ -94,9 +89,9 @@ function SageIntacctDefaultVendorPage({route}: SageIntacctDefaultVendorPageProps return ( // TODO: add scroll here Policy.clearSageIntacctExportErrorField(policyID, errorFieldName)} + onClose={() => Policy.clearSageIntacctExportErrorField(policyID, settingName)} > Policy.clearSageIntacctExportErrorField(policyID, 'nonReimbursableAccount')} + onClose={() => Policy.clearSageIntacctExportErrorField(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_ACCOUNT)} > Policy.clearSageIntacctExportErrorField(policyID, 'nonReimbursable')} + onClose={() => Policy.clearSageIntacctExportErrorField(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE)} > { - updateSageIntacctDefaultVendor(policyID, 'nonReimbursableCreditCardChargeDefaultVendor', null); + updateSageIntacctDefaultVendor(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_CREDIT_CARD_VENDOR, null); setIsSwitchOn(!isSwitchOn); }} wrapperStyle={[styles.ph5, styles.pv3]} diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx index d43fe15356f7..91b89ed1076c 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx @@ -86,9 +86,9 @@ function SageIntacctPreferredExporterPage({policy}: WithPolicyProps) { return ( Policy.clearSageIntacctExportErrorField(policyID, 'exporter')} + onClose={() => Policy.clearSageIntacctExportErrorField(policyID, CONST.SAGE_INTACCT_CONFIG.EXPORTER)} > Policy.clearSageIntacctExportErrorField(policyID, 'reimbursable')} + onClose={() => Policy.clearSageIntacctExportErrorField(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE)} > { - updateSageIntacctDefaultVendor(policyID, 'reimbursableExpenseReportDefaultVendor', null); + updateSageIntacctDefaultVendor(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE_VENDOR, null); setIsSwitchOn(!isSwitchOn); }} wrapperStyle={[styles.ph5, styles.pv3]} From 730a7a783aea11e5df74a36f0d95f7dcb971726b Mon Sep 17 00:00:00 2001 From: war-in Date: Tue, 25 Jun 2024 18:43:16 +0200 Subject: [PATCH 25/50] add todos --- .../intacct/export/SageIntacctNonReimbursableExpensesPage.tsx | 1 + .../intacct/export/SageIntacctReimbursableExpensesPage.tsx | 1 + 2 files changed, 2 insertions(+) diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx index 5f74f1c8545a..0f313053c4e9 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx @@ -148,6 +148,7 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { switchAccessibilityLabel={translate('workspace.sageIntacct.defaultVendor')} isActive={isSwitchOn} onToggle={() => { + // TODO: should we set default vendor to first on the list? (it works this way in old dot) updateSageIntacctDefaultVendor(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_CREDIT_CARD_VENDOR, null); setIsSwitchOn(!isSwitchOn); }} diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx index 866b68c2f4f6..fd9633ed307a 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx @@ -120,6 +120,7 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { switchAccessibilityLabel={translate('workspace.sageIntacct.defaultVendor')} isActive={isSwitchOn} onToggle={() => { + // TODO: should we set default vendor to first on the list? (it works this way in old dot) updateSageIntacctDefaultVendor(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE_VENDOR, null); setIsSwitchOn(!isSwitchOn); }} From 3531341efa3a201b7cff51a567b8e490315151a2 Mon Sep 17 00:00:00 2001 From: war-in Date: Fri, 28 Jun 2024 11:18:41 +0200 Subject: [PATCH 26/50] add API call for exporter --- .../API/parameters/UpdateSageIntacctExporterParams.ts | 6 ++++++ src/libs/API/parameters/index.ts | 1 + src/libs/API/types.ts | 3 +++ src/libs/actions/connections/SageIntacct.ts | 9 ++++++++- 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 src/libs/API/parameters/UpdateSageIntacctExporterParams.ts diff --git a/src/libs/API/parameters/UpdateSageIntacctExporterParams.ts b/src/libs/API/parameters/UpdateSageIntacctExporterParams.ts new file mode 100644 index 000000000000..152b124eb9bd --- /dev/null +++ b/src/libs/API/parameters/UpdateSageIntacctExporterParams.ts @@ -0,0 +1,6 @@ +type UpdateSageIntacctExporterParams = { + policyID: string; + email: string; +}; + +export default UpdateSageIntacctExporterParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index 269821318889..feddb9d69d4c 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -233,3 +233,4 @@ export type {default as UpdateSubscriptionAutoRenewParams} from './UpdateSubscri export type {default as UpdateSubscriptionAddNewUsersAutomaticallyParams} from './UpdateSubscriptionAddNewUsersAutomaticallyParams'; export type {default as GenerateSpotnanaTokenParams} from './GenerateSpotnanaTokenParams'; export type {default as UpdateSubscriptionSizeParams} from './UpdateSubscriptionSizeParams'; +export type {default as UpdateSageIntacctExporterParams} from './UpdateSageIntacctExporterParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index c5057d5c8d7c..442831cefb9e 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -227,6 +227,7 @@ const WRITE_COMMANDS = { UPDATE_SUBSCRIPTION_AUTO_RENEW: 'UpdateSubscriptionAutoRenew', UPDATE_SUBSCRIPTION_ADD_NEW_USERS_AUTOMATICALLY: 'UpdateSubscriptionAddNewUsersAutomatically', UPDATE_SUBSCRIPTION_SIZE: 'UpdateSubscriptionSize', + UPDATE_SAGE_INTACCT_EXPORTER: 'UpdateSageIntacctExporter', } as const; type WriteCommand = ValueOf; @@ -455,6 +456,8 @@ type WriteCommandParameters = { [WRITE_COMMANDS.UPDATE_SUBSCRIPTION_AUTO_RENEW]: Parameters.UpdateSubscriptionAutoRenewParams; [WRITE_COMMANDS.UPDATE_SUBSCRIPTION_ADD_NEW_USERS_AUTOMATICALLY]: Parameters.UpdateSubscriptionAddNewUsersAutomaticallyParams; [WRITE_COMMANDS.UPDATE_SUBSCRIPTION_SIZE]: Parameters.UpdateSubscriptionSizeParams; + + [WRITE_COMMANDS.UPDATE_SAGE_INTACCT_EXPORTER]: Parameters.UpdateSageIntacctExporterParams; }; const READ_COMMANDS = { diff --git a/src/libs/actions/connections/SageIntacct.ts b/src/libs/actions/connections/SageIntacct.ts index 5140ad1ef537..c253ab67718a 100644 --- a/src/libs/actions/connections/SageIntacct.ts +++ b/src/libs/actions/connections/SageIntacct.ts @@ -2,6 +2,7 @@ import type {OnyxUpdate} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; import * as API from '@libs/API'; +import type {UpdateSageIntacctExporterParams} from '@libs/API/parameters'; import {WRITE_COMMANDS} from '@libs/API/types'; import * as ErrorUtils from '@libs/ErrorUtils'; import CONST from '@src/CONST'; @@ -102,7 +103,13 @@ function updateSageIntacctExport(policyID: string, settingName: keyof Connection } function updateSageIntacctExporter(policyID: string, exporter: string) { - updateSageIntacctExport(policyID, CONST.SAGE_INTACCT_CONFIG.EXPORTER, exporter); + const {optimisticData, failureData, successData} = prepareOnyxData(policyID, CONST.SAGE_INTACCT_CONFIG.EXPORTER, exporter); + const parameters: UpdateSageIntacctExporterParams = { + policyID, + email: exporter, + }; + + API.write(WRITE_COMMANDS.UPDATE_SAGE_INTACCT_EXPORTER, parameters, {optimisticData, failureData, successData}); } function updateSageIntacctExportDate(policyID: string, date: ValueOf) { From e60b548ba151de73fdaf28e03fcf07966f39d197 Mon Sep 17 00:00:00 2001 From: war-in Date: Fri, 28 Jun 2024 15:39:38 +0200 Subject: [PATCH 27/50] update translations --- src/CONST.ts | 1 + src/languages/en.ts | 28 +++++----------------------- src/languages/es.ts | 26 +++++--------------------- 3 files changed, 11 insertions(+), 44 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index c0a8631e7dac..f06cb352aa75 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1827,6 +1827,7 @@ const CONST = { netsuite: 'NetSuite', quickbooksOnline: 'Quickbooks Online', xero: 'Xero', + intacct: 'Sage Intacct', }, SYNC_STAGE_NAME: { STARTING_IMPORT_QBO: 'startingImportQBO', diff --git a/src/languages/en.ts b/src/languages/en.ts index b31b415c14b5..1d46c41ff8c0 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -113,17 +113,8 @@ type States = Record; type AllCountries = Record; -function integrationName(integration: ConnectionName): string { - switch (integration) { - case CONST.POLICY.CONNECTIONS.NAME.QBO: - return 'Quickbooks Online'; - case CONST.POLICY.CONNECTIONS.NAME.XERO: - return 'Xero'; - case CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT: - return 'Sage Intacct'; - default: - return 'Integration'; - } +function integrationName(fallbackName: string, integration?: ConnectionName): string { + return integration && CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[integration] ? CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[integration] : fallbackName; } /* eslint-disable max-len */ @@ -2018,7 +2009,7 @@ export default { `You have been invited to ${workspaceName || 'a workspace'}! Download the Expensify mobile app at use.expensify.com/download to start tracking your expenses.`, subscription: 'Subscription', noAccountsFound: 'No accounts found', - noAccountsFoundDescription: (integration: ConnectionName) => `Add the account in ${integrationName(integration)} and sync the connection again.`, + noAccountsFoundDescription: (integration: ConnectionName) => `Add the account in ${integrationName('this integration', integration)} and sync the connection again.`, }, qbo: { importDescription: 'Choose which coding configurations to import from QuickBooks Online to Expensify.', @@ -2532,10 +2523,7 @@ export default { other: 'Other integrations', syncNow: 'Sync now', disconnect: 'Disconnect', - disconnectTitle: (integration?: ConnectionName): string => { - const integrationName = integration && CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[integration] ? CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[integration] : 'integration'; - return `Disconnect ${integrationName}`; - }, + disconnectTitle: (integration?: ConnectionName): string => `Disconnect ${integrationName('integration', integration)}`, connectTitle: (integrationToConnect: ConnectionName): string => `Connect ${CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[integrationToConnect] ?? 'accounting integration'}`, syncError: (integration?: ConnectionName): string => { @@ -2564,13 +2552,7 @@ export default { [CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE]: 'Not imported', [CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]: 'Imported as report fields', }, - disconnectPrompt: (currentIntegration?: ConnectionName): string => { - const integrationName = - currentIntegration && CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[currentIntegration] - ? CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[currentIntegration] - : 'this integration'; - return `Are you sure you want to disconnect ${integrationName}?`; - }, + disconnectPrompt: (currentIntegration?: ConnectionName): string => `Are you sure you want to disconnect ${integrationName('this integration', currentIntegration)}?`, connectPrompt: (integrationToConnect: ConnectionName): string => `Are you sure you want to connect ${ CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[integrationToConnect] ?? 'this accounting integration' diff --git a/src/languages/es.ts b/src/languages/es.ts index 3d3e61bec8cd..27bb9bcc516b 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -104,17 +104,8 @@ import type { ZipCodeExampleFormatParams, } from './types'; -function integrationName(integration: ConnectionName): string { - switch (integration) { - case CONST.POLICY.CONNECTIONS.NAME.QBO: - return 'Quickbooks Online'; - case CONST.POLICY.CONNECTIONS.NAME.XERO: - return 'Xero'; - case CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT: - return 'Sage Intacct'; - default: - return 'Integration'; - } +function integrationName(fallbackName: string, integration?: ConnectionName): string { + return integration && CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[integration] ? CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[integration] : fallbackName; } /* eslint-disable max-len */ @@ -2042,7 +2033,7 @@ export default { `¡Has sido invitado a ${workspaceName}! Descargue la aplicación móvil Expensify en use.expensify.com/download para comenzar a rastrear sus gastos.`, subscription: 'Suscripción', noAccountsFound: 'No se ha encontrado ninguna cuenta', - noAccountsFoundDescription: (integration: ConnectionName) => `Añade la cuenta en ${integrationName(integration)} y sincroniza de nuevo la conexión.`, + noAccountsFoundDescription: (integration: ConnectionName) => `Añade la cuenta en ${integrationName('esta integración', integration)} y sincroniza de nuevo la conexión.`, }, qbo: { importDescription: 'Elige que configuraciónes de codificación son importadas desde QuickBooks Online a Expensify.', @@ -2506,10 +2497,7 @@ export default { other: 'Otras integraciones', syncNow: 'Sincronizar ahora', disconnect: 'Desconectar', - disconnectTitle: (integration?: ConnectionName): string => { - const integrationName = integration && CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[integration] ? CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[integration] : 'integración'; - return `Desconectar ${integrationName}`; - }, + disconnectTitle: (integration?: ConnectionName): string => `Desconectar ${integrationName('integración', integration)}`, connectTitle: (integrationToConnect: ConnectionName): string => `Conectar ${CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[integrationToConnect] ?? 'accounting integration'}`, syncError: (integration?: ConnectionName): string => { switch (integration) { @@ -2537,11 +2525,7 @@ export default { [CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE]: 'No importado', [CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]: 'Importado como campos de informe', }, - disconnectPrompt: (currentIntegration?: ConnectionName): string => { - const integrationName = - currentIntegration && CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[currentIntegration] ? CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[currentIntegration] : 'integración'; - return `¿Estás seguro de que quieres desconectar ${integrationName}?`; - }, + disconnectPrompt: (currentIntegration?: ConnectionName): string => `¿Estás seguro de que quieres desconectar ${integrationName('integración', currentIntegration)}?`, connectPrompt: (integrationToConnect: ConnectionName): string => `¿Estás seguro de que quieres conectar a ${ CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[integrationToConnect] ?? 'esta integración contable' From f47a2185382fcc8be9192622e013bbfee1d6975f Mon Sep 17 00:00:00 2001 From: war-in Date: Mon, 1 Jul 2024 11:41:57 +0200 Subject: [PATCH 28/50] fix typecheck --- src/libs/Permissions.ts | 2 +- .../EnterSageIntacctCredentialsPage.tsx | 2 +- src/types/onyx/Policy.ts | 133 ++++++++---------- 3 files changed, 57 insertions(+), 80 deletions(-) diff --git a/src/libs/Permissions.ts b/src/libs/Permissions.ts index 79936d498280..c2d885083c44 100644 --- a/src/libs/Permissions.ts +++ b/src/libs/Permissions.ts @@ -41,7 +41,7 @@ function canUseSpotnanaTravel(betas: OnyxEntry): boolean { } function canUseNetSuiteIntegration(betas: OnyxEntry): boolean { - return !!betas?.includes(CONST.BETAS.NETSUITE_ON_NEW_EXPENSIFY) || canUseAllBetas(betas); + return true; } function canUseReportFieldsFeature(betas: OnyxEntry): boolean { diff --git a/src/pages/workspace/accounting/intacct/EnterSageIntacctCredentialsPage.tsx b/src/pages/workspace/accounting/intacct/EnterSageIntacctCredentialsPage.tsx index 75f4cab3783d..cc997123a412 100644 --- a/src/pages/workspace/accounting/intacct/EnterSageIntacctCredentialsPage.tsx +++ b/src/pages/workspace/accounting/intacct/EnterSageIntacctCredentialsPage.tsx @@ -10,7 +10,7 @@ import Text from '@components/Text'; import TextInput from '@components/TextInput'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; -import connectToSageIntacct from '@libs/actions/connections/SageIntacct'; +import {connectToSageIntacct} from '@libs/actions/connections/SageIntacct'; import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index d77205d55838..1188267bce88 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -594,82 +594,6 @@ type XeroConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ errorFields?: OnyxCommon.ErrorFields; }>; -/** One of the SageIntacctConnectionData object elements */ -type SageIntacctDataElement = { - /** Element ID */ - id: string; - - /** Element name */ - name: string; -}; - -/** One of the SageIntacctConnectionData object elements with value */ -type SageIntacctDataElementWithValue = SageIntacctDataElement & { - /** Element value */ - value: string; -}; - -/** - * Connection data for Sage Intacct - */ -type SageIntacctConnectionData = { - /** Collection of credit cards */ - creditCards: SageIntacctDataElement[]; - - /** Collection of bank accounts */ - bankAccounts: SageIntacctDataElement[]; - - /** Collection of vendors */ - vendors: SageIntacctDataElementWithValue[]; -}; - -/** - * Connection config for Sage Intacct - */ -type SageIntacctConnectiosConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ - /** Sage Intacct credentials */ - credentials: { - /** Sage Intacct companyID */ - companyID: string; - }; - - /** Sage Intacct export configs */ - export: OnyxCommon.OnyxValueWithOfflineFeedback<{ - /** Current export status */ - exportDate: ValueOf; - - /** The e-mail of the exporter */ - exporter: string; - - /** TODO: Will be handled in another issue */ - nonReimbursable: ValueOf; - - /** TODO: Will be handled in another issue */ - nonReimbursableAccount: string; - - /** */ - nonReimbursableCreditCardChargeDefaultVendor: string | null; - - /** */ - nonReimbursableVendor: string | null; - - /** TODO: Will be handled in another issue */ - reimbursable: ValueOf; - - /** */ - reimbursableExpenseReportDefaultVendor: string | null; - - /** Collection of mapping field errors, which will be triggered when update action fails */ - errorFields?: OnyxCommon.ErrorFields; - }>; - - /** Collection of Sage Intacct config errors */ - errors?: OnyxCommon.Errors; - - /** Collection of form field errors */ - errorFields?: OnyxCommon.ErrorFields; -}>; - /** Data stored about subsidiaries from NetSuite */ type NetSuiteSubsidiary = { /** ID of the subsidiary */ @@ -1025,11 +949,34 @@ type NetSuiteConnection = { tokenSecret: string; }; +/** One of the SageIntacctConnectionData object elements */ +type SageIntacctDataElement = { + /** Element ID */ + id: string; + + /** Element name */ + name: string; +}; + +/** One of the SageIntacctConnectionData object elements with value */ +type SageIntacctDataElementWithValue = SageIntacctDataElement & { + /** Element value */ + value: string; +}; + /** * Connection data for Sage Intacct */ -// eslint-disable-next-line @typescript-eslint/ban-types -type SageIntacctConnectionData = {}; +type SageIntacctConnectionData = { + /** Collection of credit cards */ + creditCards: SageIntacctDataElement[]; + + /** Collection of bank accounts */ + bankAccounts: SageIntacctDataElement[]; + + /** Collection of vendors */ + vendors: SageIntacctDataElementWithValue[]; +}; /** * Connection config for Sage Intacct @@ -1047,6 +994,36 @@ type SageIntacctConnectiosConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ userID: string; }; + /** Sage Intacct export configs */ + export: OnyxCommon.OnyxValueWithOfflineFeedback<{ + /** Current export status */ + exportDate: ValueOf; + + /** The e-mail of the exporter */ + exporter: string; + + /** TODO: Will be handled in another issue */ + nonReimbursable: ValueOf; + + /** TODO: Will be handled in another issue */ + nonReimbursableAccount: string; + + /** */ + nonReimbursableCreditCardChargeDefaultVendor: string | null; + + /** */ + nonReimbursableVendor: string | null; + + /** TODO: Will be handled in another issue */ + reimbursable: ValueOf; + + /** */ + reimbursableExpenseReportDefaultVendor: string | null; + + /** Collection of mapping field errors, which will be triggered when update action fails */ + errorFields?: OnyxCommon.ErrorFields; + }>; + /** Collection of Sage Intacct config errors */ errors?: OnyxCommon.Errors; From 3febffbdd20d83f4a95fdb2393163fa6c2952f7e Mon Sep 17 00:00:00 2001 From: war-in Date: Mon, 1 Jul 2024 13:11:23 +0200 Subject: [PATCH 29/50] use newly-created API calls --- .../UpdateSageIntacctExportDateParams.ts | 6 + ...editCardChargeExportDefaultVendorParams.ts | 6 + ...reimbursableExpensesExportAccountParams.ts | 6 + ...bursableExpensesExportDestinationParams.ts | 6 + ...nreimbursableExpensesExportVendorParams.ts | 6 + ...bursableExpensesExportDestinationParams.ts | 6 + ...ExpensesReportExportDefaultVendorParams.ts | 6 + src/libs/API/parameters/index.ts | 7 + src/libs/API/types.ts | 14 ++ src/libs/actions/connections/SageIntacct.ts | 224 +++++++++++------- ...ctNonReimbursableCreditCardAccountPage.tsx | 4 +- ...SageIntacctNonReimbursableExpensesPage.tsx | 4 +- .../SageIntacctReimbursableExpensesPage.tsx | 8 +- 13 files changed, 209 insertions(+), 94 deletions(-) create mode 100644 src/libs/API/parameters/UpdateSageIntacctExportDateParams.ts create mode 100644 src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams.ts create mode 100644 src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportAccountParams.ts create mode 100644 src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportDestinationParams.ts create mode 100644 src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportVendorParams.ts create mode 100644 src/libs/API/parameters/UpdateSageIntacctReimbursableExpensesExportDestinationParams.ts create mode 100644 src/libs/API/parameters/UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams.ts diff --git a/src/libs/API/parameters/UpdateSageIntacctExportDateParams.ts b/src/libs/API/parameters/UpdateSageIntacctExportDateParams.ts new file mode 100644 index 000000000000..acae666bbb1f --- /dev/null +++ b/src/libs/API/parameters/UpdateSageIntacctExportDateParams.ts @@ -0,0 +1,6 @@ +type UpdateSageIntacctExportDateParams = { + policyID: string; + value: string; +}; + +export default UpdateSageIntacctExportDateParams; diff --git a/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams.ts b/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams.ts new file mode 100644 index 000000000000..09e2ad2dfc41 --- /dev/null +++ b/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams.ts @@ -0,0 +1,6 @@ +type UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams = { + policyID: string; + vendorID: string | null; +}; + +export default UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams; diff --git a/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportAccountParams.ts b/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportAccountParams.ts new file mode 100644 index 000000000000..316308cbf67c --- /dev/null +++ b/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportAccountParams.ts @@ -0,0 +1,6 @@ +type UpdateSageIntacctNonreimbursableExpensesExportAccountParams = { + policyID: string; + bankAccountID: string; +}; + +export default UpdateSageIntacctNonreimbursableExpensesExportAccountParams; diff --git a/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportDestinationParams.ts b/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportDestinationParams.ts new file mode 100644 index 000000000000..1229afb776ec --- /dev/null +++ b/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportDestinationParams.ts @@ -0,0 +1,6 @@ +type UpdateSageIntacctNonreimbursableExpensesExportDestinationParams = { + policyID: string; + value: string; +}; + +export default UpdateSageIntacctNonreimbursableExpensesExportDestinationParams; diff --git a/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportVendorParams.ts b/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportVendorParams.ts new file mode 100644 index 000000000000..de2fc8c2f574 --- /dev/null +++ b/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportVendorParams.ts @@ -0,0 +1,6 @@ +type UpdateSageIntacctNonreimbursableExpensesExportVendorParams = { + policyID: string; + vendorID: string | null; +}; + +export default UpdateSageIntacctNonreimbursableExpensesExportVendorParams; diff --git a/src/libs/API/parameters/UpdateSageIntacctReimbursableExpensesExportDestinationParams.ts b/src/libs/API/parameters/UpdateSageIntacctReimbursableExpensesExportDestinationParams.ts new file mode 100644 index 000000000000..a31bfeb962f4 --- /dev/null +++ b/src/libs/API/parameters/UpdateSageIntacctReimbursableExpensesExportDestinationParams.ts @@ -0,0 +1,6 @@ +type UpdateSageIntacctReimbursableExpensesExportDestinationParams = { + policyID: string; + value: string; +}; + +export default UpdateSageIntacctReimbursableExpensesExportDestinationParams; diff --git a/src/libs/API/parameters/UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams.ts b/src/libs/API/parameters/UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams.ts new file mode 100644 index 000000000000..64d9c312a4b5 --- /dev/null +++ b/src/libs/API/parameters/UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams.ts @@ -0,0 +1,6 @@ +type UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams = { + policyID: string; + vendorID: string | null; +}; + +export default UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index f29c2b3c3e56..819260235bfd 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -236,3 +236,10 @@ export type {default as GenerateSpotnanaTokenParams} from './GenerateSpotnanaTok export type {default as UpdateSubscriptionSizeParams} from './UpdateSubscriptionSizeParams'; export type {default as UpdateNetSuiteSubsidiaryParams} from './UpdateNetSuiteSubsidiaryParams'; export type {default as UpdateSageIntacctExporterParams} from './UpdateSageIntacctExporterParams'; +export type {default as UpdateSageIntacctExportDateParams} from './UpdateSageIntacctExportDateParams'; +export type {default as UpdateSageIntacctReimbursableExpensesExportDestinationParams} from './UpdateSageIntacctReimbursableExpensesExportDestinationParams'; +export type {default as UpdateSageIntacctNonreimbursableExpensesExportDestinationParams} from './UpdateSageIntacctNonreimbursableExpensesExportDestinationParams'; +export type {default as UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams} from './UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams'; +export type {default as UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams} from './UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams'; +export type {default as UpdateSageIntacctNonreimbursableExpensesExportAccountParams} from './UpdateSageIntacctNonreimbursableExpensesExportAccountParams'; +export type {default as UpdateSageIntacctNonreimbursableExpensesExportVendorParams} from './UpdateSageIntacctNonreimbursableExpensesExportVendorParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index ef00d4da8077..b3d11cf6f6d0 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -231,6 +231,13 @@ const WRITE_COMMANDS = { UPDATE_NETSUITE_SUBSIDIARY: 'UpdateNetSuiteSubsidiary', CONNECT_POLICY_TO_SAGE_INTACCT: 'ConnectPolicyToSageIntacct', UPDATE_SAGE_INTACCT_EXPORTER: 'UpdateSageIntacctExporter', + UPDATE_SAGE_INTACCT_EXPORT_DATE: 'UpdateSageIntacctExportDate', + UPDATE_SAGE_INTACCT_REIMBURSABLE_EXPENSES_EXPORT_DESTINATION: 'UpdateSageIntacctReimbursableExpensesExportDestination', + UPDATE_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES_EXPORT_DESTINATION: 'UpdateSageIntacctNonreimbursableExpensesExportDestination', + UPDATE_SAGE_INTACCT_REIMBURSABLE_EXPENSES_REPORT_EXPORT_DEFAULT_VENDOR: 'UpdateSageIntacctReimbursableExpensesReportExportDefaultVendor', + UPDATE_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES_CREDIT_CARD_CHARGE_EXPORT_DEFAULT_VENDOR: 'UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendor', + UPDATE_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES_EXPORT_ACCOUNT: 'UpdateSageIntacctNonreimbursableExpensesExportAccount', + UPDATE_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES_EXPORT_VENDOR: 'UpdateSageIntacctNonreimbursableExpensesExportVendor', } as const; type WriteCommand = ValueOf; @@ -462,6 +469,13 @@ type WriteCommandParameters = { [WRITE_COMMANDS.UPDATE_SUBSCRIPTION_SIZE]: Parameters.UpdateSubscriptionSizeParams; [WRITE_COMMANDS.CONNECT_POLICY_TO_SAGE_INTACCT]: Parameters.ConnectPolicyToSageIntacctParams; [WRITE_COMMANDS.UPDATE_SAGE_INTACCT_EXPORTER]: Parameters.UpdateSageIntacctExporterParams; + [WRITE_COMMANDS.UPDATE_SAGE_INTACCT_EXPORT_DATE]: Parameters.UpdateSageIntacctExportDateParams; + [WRITE_COMMANDS.UPDATE_SAGE_INTACCT_REIMBURSABLE_EXPENSES_EXPORT_DESTINATION]: Parameters.UpdateSageIntacctReimbursableExpensesExportDestinationParams; + [WRITE_COMMANDS.UPDATE_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES_EXPORT_DESTINATION]: Parameters.UpdateSageIntacctNonreimbursableExpensesExportDestinationParams; + [WRITE_COMMANDS.UPDATE_SAGE_INTACCT_REIMBURSABLE_EXPENSES_REPORT_EXPORT_DEFAULT_VENDOR]: Parameters.UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams; + [WRITE_COMMANDS.UPDATE_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES_CREDIT_CARD_CHARGE_EXPORT_DEFAULT_VENDOR]: Parameters.UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams; + [WRITE_COMMANDS.UPDATE_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES_EXPORT_ACCOUNT]: Parameters.UpdateSageIntacctNonreimbursableExpensesExportAccountParams; + [WRITE_COMMANDS.UPDATE_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES_EXPORT_VENDOR]: Parameters.UpdateSageIntacctNonreimbursableExpensesExportVendorParams; // Netsuite parameters [WRITE_COMMANDS.UPDATE_NETSUITE_SUBSIDIARY]: Parameters.UpdateNetSuiteSubsidiaryParams; diff --git a/src/libs/actions/connections/SageIntacct.ts b/src/libs/actions/connections/SageIntacct.ts index ccd61412e654..5d56d8484fa3 100644 --- a/src/libs/actions/connections/SageIntacct.ts +++ b/src/libs/actions/connections/SageIntacct.ts @@ -2,8 +2,17 @@ import type {OnyxUpdate} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; import * as API from '@libs/API'; +import type { + UpdateSageIntacctExportDateParams, + UpdateSageIntacctExporterParams, + UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams, + UpdateSageIntacctNonreimbursableExpensesExportAccountParams, + UpdateSageIntacctNonreimbursableExpensesExportDestinationParams, + UpdateSageIntacctNonreimbursableExpensesExportVendorParams, + UpdateSageIntacctReimbursableExpensesExportDestinationParams, + UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams, +} from '@libs/API/parameters'; import type ConnectPolicyToSageIntacctParams from '@libs/API/parameters/ConnectPolicyToSageIntacctParams'; -import type {UpdateSageIntacctExporterParams} from '@libs/API/parameters'; import {WRITE_COMMANDS} from '@libs/API/types'; import * as ErrorUtils from '@libs/ErrorUtils'; import CONST from '@src/CONST'; @@ -13,13 +22,13 @@ import type {Connections} from '@src/types/onyx/Policy'; type SageIntacctCredentials = {companyID: string; userID: string; password: string}; function connectToSageIntacct(policyID: string, credentials: SageIntacctCredentials) { - const parameters: ConnectPolicyToSageIntacctParams = { - policyID, - intacctCompanyID: credentials.companyID, - intacctUserID: credentials.userID, - intacctPassword: credentials.password, - }; - API.write(WRITE_COMMANDS.CONNECT_POLICY_TO_SAGE_INTACCT, parameters, {}); + const parameters: ConnectPolicyToSageIntacctParams = { + policyID, + intacctCompanyID: credentials.companyID, + intacctUserID: credentials.userID, + intacctPassword: credentials.password, + }; + API.write(WRITE_COMMANDS.CONNECT_POLICY_TO_SAGE_INTACCT, parameters, {}); } function prepareOnyxData(policyID: string, settingName: keyof Connections['intacct']['config']['export'], settingValue: string | null) { @@ -47,110 +56,153 @@ function prepareOnyxData(policyID: string, settingName: keyof Connections['intac }, ]; - const failureData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - connections: { - intacct: { - config: { - export: { - [settingName]: settingValue, - pendingFields: { - [settingName]: null, - }, - errorFields: { - [settingName]: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), + const failureData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + connections: { + intacct: { + config: { + export: { + [settingName]: settingValue, + pendingFields: { + [settingName]: null, + }, + errorFields: { + [settingName]: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), + }, + }, + }, + }, }, - }, }, - }, }, - }, - }, - ]; - - const successData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - connections: { - intacct: { - config: { - export: { - [settingName]: settingValue, - pendingFields: { - [settingName]: null, - }, - errorFields: { - [settingName]: null, + ]; + + const successData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + connections: { + intacct: { + config: { + export: { + [settingName]: settingValue, + pendingFields: { + [settingName]: null, + }, + errorFields: { + [settingName]: null, + }, + }, + }, + }, }, - }, }, - }, }, - }, - }, - ]; + ]; - return {optimisticData, failureData, successData}; + return {optimisticData, failureData, successData}; } -function prepareParametersForExport(policyID: string, settingName: keyof Connections['intacct']['config']['export'], settingValue: string | null) { - return { - policyID, - connectionName: CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, - settingName: CONST.SAGE_INTACCT_CONFIG.EXPORT, - settingValue: JSON.stringify({[settingName]: settingValue}), - idempotencyKey: CONST.SAGE_INTACCT_CONFIG.EXPORT, - }; +function updateSageIntacctExporter(policyID: string, exporter: string) { + const {optimisticData, failureData, successData} = prepareOnyxData(policyID, CONST.SAGE_INTACCT_CONFIG.EXPORTER, exporter); + const parameters: UpdateSageIntacctExporterParams = { + policyID, + email: exporter, + }; + + API.write(WRITE_COMMANDS.UPDATE_SAGE_INTACCT_EXPORTER, parameters, {optimisticData, failureData, successData}); } -function updateSageIntacctExport(policyID: string, settingName: keyof Connections['intacct']['config']['export'], settingValue: string | null) { - const {optimisticData, failureData, successData} = prepareOnyxData(policyID, settingName, settingValue); - const parameters = prepareParametersForExport(policyID, settingName, settingValue); +function updateSageIntacctExportDate(policyID: string, date: ValueOf) { + const {optimisticData, failureData, successData} = prepareOnyxData(policyID, CONST.SAGE_INTACCT_CONFIG.EXPORT_DATE, date); + const parameters: UpdateSageIntacctExportDateParams = { + policyID, + value: date, + }; - API.write(WRITE_COMMANDS.UPDATE_POLICY_CONNECTION_CONFIG, parameters, {optimisticData, failureData, successData}); + API.write(WRITE_COMMANDS.UPDATE_SAGE_INTACCT_EXPORT_DATE, parameters, {optimisticData, failureData, successData}); } -function updateSageIntacctExporter(policyID: string, exporter: string) { - const {optimisticData, failureData, successData} = prepareOnyxData(policyID, CONST.SAGE_INTACCT_CONFIG.EXPORTER, exporter); - const parameters: UpdateSageIntacctExporterParams = { - policyID, - email: exporter, - }; +function updateSageIntacctReimbursableExpensesExportDestination(policyID: string, reimbursable: ValueOf) { + const {optimisticData, failureData, successData} = prepareOnyxData(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE, reimbursable); + const parameters: UpdateSageIntacctReimbursableExpensesExportDestinationParams = { + policyID, + value: reimbursable, + }; - API.write(WRITE_COMMANDS.UPDATE_SAGE_INTACCT_EXPORTER, parameters, {optimisticData, failureData, successData}); + API.write(WRITE_COMMANDS.UPDATE_SAGE_INTACCT_REIMBURSABLE_EXPENSES_EXPORT_DESTINATION, parameters, {optimisticData, failureData, successData}); } -function updateSageIntacctExportDate(policyID: string, date: ValueOf) { - updateSageIntacctExport(policyID, CONST.SAGE_INTACCT_CONFIG.EXPORT_DATE, date); +function updateSageIntacctNonreimbursableExpensesExportDestination(policyID: string, nonReimbursable: ValueOf) { + const {optimisticData, failureData, successData} = prepareOnyxData(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE, nonReimbursable); + const parameters: UpdateSageIntacctNonreimbursableExpensesExportDestinationParams = { + policyID, + value: nonReimbursable, + }; + + API.write(WRITE_COMMANDS.UPDATE_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES_EXPORT_DESTINATION, parameters, {optimisticData, failureData, successData}); } -function updateSageIntacctExportReimbursableExpense(policyID: string, reimbursable: ValueOf) { - updateSageIntacctExport(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE, reimbursable); +function updateSageIntacctReimbursableExpensesReportExportDefaultVendor(policyID: string, vendor: string | null) { + const {optimisticData, failureData, successData} = prepareOnyxData(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE_VENDOR, vendor); + const parameters: UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams = { + policyID, + vendorID: vendor, + }; + + API.write(WRITE_COMMANDS.UPDATE_SAGE_INTACCT_REIMBURSABLE_EXPENSES_REPORT_EXPORT_DEFAULT_VENDOR, parameters, {optimisticData, failureData, successData}); +} + +function updateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendor(policyID: string, vendor: string | null) { + const {optimisticData, failureData, successData} = prepareOnyxData(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_CREDIT_CARD_VENDOR, vendor); + const parameters: UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams = { + policyID, + vendorID: vendor, + }; + + API.write(WRITE_COMMANDS.UPDATE_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES_CREDIT_CARD_CHARGE_EXPORT_DEFAULT_VENDOR, parameters, {optimisticData, failureData, successData}); } -function updateSageIntacctDefaultVendor(policyID: string, settingName: keyof Connections['intacct']['config']['export'], settingValue: string | null) { - updateSageIntacctExport(policyID, settingName, settingValue); +function updateSageIntacctNonreimbursableExpensesExportAccount(policyID: string, nonReimbursableAccount: string) { + const {optimisticData, failureData, successData} = prepareOnyxData(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_ACCOUNT, nonReimbursableAccount); + const parameters: UpdateSageIntacctNonreimbursableExpensesExportAccountParams = { + policyID, + bankAccountID: nonReimbursableAccount, + }; + + API.write(WRITE_COMMANDS.UPDATE_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES_EXPORT_ACCOUNT, parameters, {optimisticData, failureData, successData}); } -function updateSageIntacctExportNonReimbursableExpense(policyID: string, nonReimbursable: ValueOf) { - updateSageIntacctExport(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE, nonReimbursable); +function updateSageIntacctNonreimbursableExpensesExportVendor(policyID: string, vendor: string | null) { + const {optimisticData, failureData, successData} = prepareOnyxData(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_VENDOR, vendor); + const parameters: UpdateSageIntacctNonreimbursableExpensesExportVendorParams = { + policyID, + vendorID: vendor, + }; + + API.write(WRITE_COMMANDS.UPDATE_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES_EXPORT_VENDOR, parameters, {optimisticData, failureData, successData}); } -function updateSageIntacctExportNonReimbursableAccount(policyID: string, nonReimbursableAccount: string) { - updateSageIntacctExport(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_ACCOUNT, nonReimbursableAccount); +function updateSageIntacctDefaultVendor(policyID: string, settingName: keyof Connections['intacct']['config']['export'], vendor: string | null) { + if (settingName === CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE_VENDOR) { + updateSageIntacctReimbursableExpensesReportExportDefaultVendor(policyID, vendor); + } else if (settingName === CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_CREDIT_CARD_VENDOR) { + updateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendor(policyID, vendor); + } else if (settingName === CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_VENDOR) { + updateSageIntacctNonreimbursableExpensesExportVendor(policyID, vendor); + } } export { - connectToSageIntacct, - updateSageIntacctExporter, - updateSageIntacctExportDate, - updateSageIntacctExportReimbursableExpense, - updateSageIntacctDefaultVendor, - updateSageIntacctExportNonReimbursableExpense, - updateSageIntacctExportNonReimbursableAccount, + connectToSageIntacct, + updateSageIntacctExporter, + updateSageIntacctExportDate, + updateSageIntacctReimbursableExpensesExportDestination, + updateSageIntacctNonreimbursableExpensesExportDestination, + updateSageIntacctNonreimbursableExpensesExportAccount, + updateSageIntacctDefaultVendor, }; diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx index 93fceae77112..c751732737ae 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx @@ -15,7 +15,7 @@ import {getSageIntacctCreditCards} from '@libs/PolicyUtils'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import variables from '@styles/variables'; -import {updateSageIntacctExportNonReimbursableAccount} from '@userActions/connections/SageIntacct'; +import {updateSageIntacctNonreimbursableExpensesExportAccount} from '@userActions/connections/SageIntacct'; import * as Policy from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -42,7 +42,7 @@ function SageIntacctNonReimbursableCreditCardAccountPage({policy}: WithPolicyCon const updateCreditCardAccount = useCallback( ({value}: SelectorType) => { if (value !== exportConfig?.nonReimbursableAccount) { - updateSageIntacctExportNonReimbursableAccount(policyID, value); + updateSageIntacctNonreimbursableExpensesExportAccount(policyID, value); } Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID)); }, diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx index 0f313053c4e9..71f961f1960f 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx @@ -16,7 +16,7 @@ import Navigation from '@navigation/Navigation'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; -import {updateSageIntacctDefaultVendor, updateSageIntacctExportNonReimbursableExpense} from '@userActions/connections/SageIntacct'; +import {updateSageIntacctDefaultVendor, updateSageIntacctNonreimbursableExpensesExportDestination} from '@userActions/connections/SageIntacct'; import * as Policy from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -59,7 +59,7 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { if (row.value === config?.export.nonReimbursable) { return; } - updateSageIntacctExportNonReimbursableExpense(policyID, row.value); + updateSageIntacctNonreimbursableExpensesExportDestination(policyID, row.value); }, [config?.export.nonReimbursable, policyID], ); diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx index fd9633ed307a..e102e542980a 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx @@ -15,7 +15,7 @@ import Navigation from '@navigation/Navigation'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; -import {updateSageIntacctDefaultVendor, updateSageIntacctExportReimbursableExpense} from '@userActions/connections/SageIntacct'; +import {updateSageIntacctDefaultVendor, updateSageIntacctReimbursableExpensesExportDestination} from '@userActions/connections/SageIntacct'; import * as Policy from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -54,10 +54,10 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { [translate, styles.pb5, styles.ph5], ); - const selectExportDate = useCallback( + const selectReimbursableDestination = useCallback( (row: MenuListItem) => { if (row.value !== reimbursable) { - updateSageIntacctExportReimbursableExpense(policyID, row.value); + updateSageIntacctReimbursableExpensesExportDestination(policyID, row.value); } if (row.value === CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL) { Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID)); @@ -103,7 +103,7 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { headerContent={headerContent} sections={[{data}]} listItem={RadioListItem} - onSelectRow={(selection: SelectorType) => selectExportDate(selection as MenuListItem)} + onSelectRow={(selection: SelectorType) => selectReimbursableDestination(selection as MenuListItem)} initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} policyID={policyID} accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]} From a4fcd59d8e87ce20ec22fdee4c64efd34ef1c628 Mon Sep 17 00:00:00 2001 From: war-in Date: Mon, 1 Jul 2024 16:06:39 +0200 Subject: [PATCH 30/50] remove offline with feedback usages --- .../intacct/export/SageIntacctDatePage.tsx | 37 +++++--------- .../export/SageIntacctDefaultVendorPage.tsx | 51 ++++++++----------- ...ctNonReimbursableCreditCardAccountPage.tsx | 37 +++++--------- ...SageIntacctNonReimbursableExpensesPage.tsx | 10 +--- .../SageIntacctPreferredExporterPage.tsx | 37 +++++--------- .../SageIntacctReimbursableExpensesPage.tsx | 10 +--- 6 files changed, 66 insertions(+), 116 deletions(-) diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx index 2a138d25360e..20850119d828 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx @@ -1,7 +1,6 @@ import React, {useCallback, useMemo} from 'react'; import {View} from 'react-native'; import type {ValueOf} from 'type-fest'; -import OfflineWithFeedback from '@components/OfflineWithFeedback'; import RadioListItem from '@components/SelectionList/RadioListItem'; import type {ListItem} from '@components/SelectionList/types'; import SelectionScreen from '@components/SelectionScreen'; @@ -9,12 +8,10 @@ import type {SelectorType} from '@components/SelectionScreen'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; -import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@navigation/Navigation'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import {updateSageIntacctExportDate} from '@userActions/connections/SageIntacct'; -import * as Policy from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -55,26 +52,20 @@ function SageIntacctDatePage({policy}: WithPolicyProps) { ); return ( - Policy.clearSageIntacctExportErrorField(policyID, CONST.SAGE_INTACCT_CONFIG.EXPORT_DATE)} - > - selectExportDate(selection as MenuListItem)} - initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} - policyID={policyID} - accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]} - featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} - onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID))} - connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} - /> - + selectExportDate(selection as MenuListItem)} + initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} + policyID={policyID} + accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]} + featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} + onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID))} + connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} + /> ); } diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx index b55858ef78ef..63f1399cc8af 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx @@ -4,20 +4,17 @@ import {View} from 'react-native'; import {useOnyx} from 'react-native-onyx'; import BlockingView from '@components/BlockingViews/BlockingView'; import * as Illustrations from '@components/Icon/Illustrations'; -import OfflineWithFeedback from '@components/OfflineWithFeedback'; import RadioListItem from '@components/SelectionList/RadioListItem'; import type {SelectorType} from '@components/SelectionScreen'; import SelectionScreen from '@components/SelectionScreen'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; -import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; import {getSageIntacctNonReimbursableActiveDefaultVendor, getSageIntacctVendors} from '@libs/PolicyUtils'; import type {SettingsNavigatorParamList} from '@navigation/types'; import variables from '@styles/variables'; import {updateSageIntacctDefaultVendor} from '@userActions/connections/SageIntacct'; -import * as Policy from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; @@ -32,7 +29,6 @@ function SageIntacctDefaultVendorPage({route}: SageIntacctDefaultVendorPageProps const policyID = route.params.policyID ?? '-1'; const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); - const {export: exportConfig} = policy?.connections?.intacct?.config ?? {}; const isReimbursable = route.params.reimbursable === 'reimbursable'; @@ -87,33 +83,26 @@ function SageIntacctDefaultVendorPage({route}: SageIntacctDefaultVendorPageProps ); return ( - // TODO: add scroll here - Policy.clearSageIntacctExportErrorField(policyID, settingName)} - > - mode.isSelected)?.keyForList} - headerContent={listHeaderComponent} - onBackButtonPress={() => - Navigation.goBack( - isReimbursable - ? ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_REIMBURSABLE_EXPENSES.getRoute(policyID) - : ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID), - ) - } - title="workspace.sageIntacct.defaultVendor" - listEmptyContent={listEmptyContent} - connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} - /> - + mode.isSelected)?.keyForList} + headerContent={listHeaderComponent} + onBackButtonPress={() => + Navigation.goBack( + isReimbursable + ? ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_REIMBURSABLE_EXPENSES.getRoute(policyID) + : ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID), + ) + } + title="workspace.sageIntacct.defaultVendor" + listEmptyContent={listEmptyContent} + connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} + /> ); } diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx index c751732737ae..a3d60f3d560e 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx @@ -2,21 +2,18 @@ import React, {useCallback, useMemo} from 'react'; import {View} from 'react-native'; import BlockingView from '@components/BlockingViews/BlockingView'; import * as Illustrations from '@components/Icon/Illustrations'; -import OfflineWithFeedback from '@components/OfflineWithFeedback'; import RadioListItem from '@components/SelectionList/RadioListItem'; import type {SelectorType} from '@components/SelectionScreen'; import SelectionScreen from '@components/SelectionScreen'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; -import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; import {getSageIntacctCreditCards} from '@libs/PolicyUtils'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import variables from '@styles/variables'; import {updateSageIntacctNonreimbursableExpensesExportAccount} from '@userActions/connections/SageIntacct'; -import * as Policy from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -64,26 +61,20 @@ function SageIntacctNonReimbursableCreditCardAccountPage({policy}: WithPolicyCon ); return ( - Policy.clearSageIntacctExportErrorField(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_ACCOUNT)} - > - mode.isSelected)?.keyForList} - headerContent={listHeaderComponent} - onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID))} - title="workspace.sageIntacct.creditCardAccount" - listEmptyContent={listEmptyContent} - connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} - /> - + mode.isSelected)?.keyForList} + headerContent={listHeaderComponent} + onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID))} + title="workspace.sageIntacct.creditCardAccount" + listEmptyContent={listEmptyContent} + connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} + /> ); } diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx index 71f961f1960f..7298dad76e06 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx @@ -10,14 +10,12 @@ import SelectionScreen from '@components/SelectionScreen'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; -import * as ErrorUtils from '@libs/ErrorUtils'; import {getSageIntacctNonReimbursableActiveDefaultVendor} from '@libs/PolicyUtils'; import Navigation from '@navigation/Navigation'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; import {updateSageIntacctDefaultVendor, updateSageIntacctNonreimbursableExpensesExportDestination} from '@userActions/connections/SageIntacct'; -import * as Policy from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import type {SageIntacctDataElementWithValue} from '@src/types/onyx/Policy'; @@ -118,11 +116,7 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { ); return ( - Policy.clearSageIntacctExportErrorField(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE)} - > + <> )} - + ); } diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx index 91b89ed1076c..3558835b3314 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx @@ -1,7 +1,6 @@ import {isEmpty} from 'lodash'; import React, {useCallback, useMemo} from 'react'; import {View} from 'react-native'; -import OfflineWithFeedback from '@components/OfflineWithFeedback'; import RadioListItem from '@components/SelectionList/RadioListItem'; import type {ListItem} from '@components/SelectionList/types'; import SelectionScreen from '@components/SelectionScreen'; @@ -9,13 +8,11 @@ import Text from '@components/Text'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; -import * as ErrorUtils from '@libs/ErrorUtils'; import {getAdminEmployees, isExpensifyTeam} from '@libs/PolicyUtils'; import Navigation from '@navigation/Navigation'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import {updateSageIntacctExporter} from '@userActions/connections/SageIntacct'; -import * as Policy from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -85,26 +82,20 @@ function SageIntacctPreferredExporterPage({policy}: WithPolicyProps) { ); return ( - Policy.clearSageIntacctExportErrorField(policyID, CONST.SAGE_INTACCT_CONFIG.EXPORTER)} - > - mode.isSelected)?.keyForList} - onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID))} - title="workspace.sageIntacct.preferredExporter" - connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} - /> - + mode.isSelected)?.keyForList} + onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID))} + title="workspace.sageIntacct.preferredExporter" + connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} + /> ); } diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx index e102e542980a..93dd8898b3c5 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx @@ -10,13 +10,11 @@ import SelectionScreen from '@components/SelectionScreen'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; -import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@navigation/Navigation'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; import {updateSageIntacctDefaultVendor, updateSageIntacctReimbursableExpensesExportDestination} from '@userActions/connections/SageIntacct'; -import * as Policy from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import type {SageIntacctDataElementWithValue} from '@src/types/onyx/Policy'; @@ -92,11 +90,7 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { ); return ( - Policy.clearSageIntacctExportErrorField(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE)} - > + <> )} - + ); } From 66e30d5240df41ca6d179335f4048c56946bb3aa Mon Sep 17 00:00:00 2001 From: war-in Date: Mon, 1 Jul 2024 16:23:58 +0200 Subject: [PATCH 31/50] remove unused functions and add descriptions --- src/libs/actions/Policy/Policy.ts | 5 ----- .../SageIntacctNonReimbursableExpensesPage.tsx | 4 ++-- .../SageIntacctReimbursableExpensesPage.tsx | 4 ++-- src/types/onyx/Policy.ts | 17 +++++++---------- 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index 968312651470..069ff5682552 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -531,10 +531,6 @@ function clearNetSuiteErrorField(policyID: string, fieldName: string) { Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {connections: {netsuite: {options: {config: {errorFields: {[fieldName]: null}}}}}}); } -function clearSageIntacctExportErrorField(policyID: string, fieldName: string) { - Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {connections: {intacct: {config: {export: {errorFields: {[fieldName]: null}}}}}}); -} - function setWorkspaceReimbursement(policyID: string, reimbursementChoice: ValueOf, reimburserEmail: string) { const policy = getPolicy(policyID); @@ -2999,7 +2995,6 @@ export { generateCustomUnitID, clearQBOErrorField, clearXeroErrorField, - clearSageIntacctExportErrorField, clearWorkspaceReimbursementErrors, setWorkspaceCurrencyDefault, setForeignCurrencyDefault, diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx index 7298dad76e06..2f78d7147f9a 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx @@ -116,7 +116,7 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { ); return ( - <> + )} - + ); } diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx index 93dd8898b3c5..848cdd043ea4 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx @@ -90,7 +90,7 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { ); return ( - <> + )} - + ); } diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 1188267bce88..8075d8ec6dc0 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -971,9 +971,6 @@ type SageIntacctConnectionData = { /** Collection of credit cards */ creditCards: SageIntacctDataElement[]; - /** Collection of bank accounts */ - bankAccounts: SageIntacctDataElement[]; - /** Collection of vendors */ vendors: SageIntacctDataElementWithValue[]; }; @@ -996,28 +993,28 @@ type SageIntacctConnectiosConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Sage Intacct export configs */ export: OnyxCommon.OnyxValueWithOfflineFeedback<{ - /** Current export status */ + /** Export date type */ exportDate: ValueOf; /** The e-mail of the exporter */ exporter: string; - /** TODO: Will be handled in another issue */ + /** Defines how non-reimbursable expenses are exported */ nonReimbursable: ValueOf; - /** TODO: Will be handled in another issue */ + /** Account that receives the non-reimbursable expenses */ nonReimbursableAccount: string; - /** */ + /** Default vendor used for credit card transactions of non-reimbursable bill */ nonReimbursableCreditCardChargeDefaultVendor: string | null; - /** */ + /** Default vendor of non-reimbursable bill */ nonReimbursableVendor: string | null; - /** TODO: Will be handled in another issue */ + /** Defines how reimbursable expenses are exported */ reimbursable: ValueOf; - /** */ + /** Default vendor of reimbursable bill */ reimbursableExpenseReportDefaultVendor: string | null; /** Collection of mapping field errors, which will be triggered when update action fails */ From 3bc6586c0e5b4228054c30df0ddac2948ffe2dad Mon Sep 17 00:00:00 2001 From: war-in Date: Mon, 1 Jul 2024 16:42:06 +0200 Subject: [PATCH 32/50] set default vendor when enabling toggle --- .../SageIntacctNonReimbursableExpensesPage.tsx | 15 ++++++--------- .../SageIntacctReimbursableExpensesPage.tsx | 15 ++++++--------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx index 2f78d7147f9a..bd244a56f705 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useMemo, useState} from 'react'; +import React, {useCallback, useMemo} from 'react'; import {View} from 'react-native'; import type {ValueOf} from 'type-fest'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; @@ -34,8 +34,6 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); const {data: intacctData, config} = policy?.connections?.intacct ?? {}; - const [isSwitchOn, setIsSwitchOn] = useState(!!config?.export.nonReimbursableCreditCardChargeDefaultVendor); - const data: MenuListItem[] = Object.values(CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE).map((expenseType) => ({ value: expenseType, text: translate(`workspace.sageIntacct.nonReimbursableExpenses.values.${expenseType}`), @@ -140,16 +138,15 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { subtitle={translate('workspace.sageIntacct.defaultVendorDescription', false)} shouldPlaceSubtitleBelowSwitch switchAccessibilityLabel={translate('workspace.sageIntacct.defaultVendor')} - isActive={isSwitchOn} - onToggle={() => { - // TODO: should we set default vendor to first on the list? (it works this way in old dot) - updateSageIntacctDefaultVendor(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_CREDIT_CARD_VENDOR, null); - setIsSwitchOn(!isSwitchOn); + isActive={!!config?.export.nonReimbursableCreditCardChargeDefaultVendor} + onToggle={(enabled) => { + const vendor = enabled ? policy?.connections?.intacct?.data?.vendors?.[0].id ?? null : null; + updateSageIntacctDefaultVendor(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_CREDIT_CARD_VENDOR, vendor); }} wrapperStyle={[styles.ph5, styles.pv3]} pendingAction={config?.export?.pendingFields?.nonReimbursableCreditCardChargeDefaultVendor} /> - {isSwitchOn && defaultVendor} + {!!config?.export.nonReimbursableCreditCardChargeDefaultVendor && defaultVendor} )} diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx index 848cdd043ea4..c55dea3b1e77 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useMemo, useState} from 'react'; +import React, {useCallback, useMemo} from 'react'; import {View} from 'react-native'; import type {ValueOf} from 'type-fest'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; @@ -34,8 +34,6 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { const {data: intacctData, config} = policy?.connections?.intacct ?? {}; const {reimbursable, reimbursableExpenseReportDefaultVendor} = policy?.connections?.intacct?.config?.export ?? {}; - const [isSwitchOn, setIsSwitchOn] = useState(!!reimbursableExpenseReportDefaultVendor); - const data: MenuListItem[] = Object.values(CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE).map((expenseType) => ({ value: expenseType, text: translate(`workspace.sageIntacct.reimbursableExpenses.values.${expenseType}`), @@ -112,16 +110,15 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { subtitle={translate('workspace.sageIntacct.defaultVendorDescription', true)} shouldPlaceSubtitleBelowSwitch switchAccessibilityLabel={translate('workspace.sageIntacct.defaultVendor')} - isActive={isSwitchOn} - onToggle={() => { - // TODO: should we set default vendor to first on the list? (it works this way in old dot) - updateSageIntacctDefaultVendor(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE_VENDOR, null); - setIsSwitchOn(!isSwitchOn); + isActive={!!reimbursableExpenseReportDefaultVendor} + onToggle={(enabled) => { + const vendor = enabled ? policy?.connections?.intacct?.data?.vendors?.[0].id ?? null : null; + updateSageIntacctDefaultVendor(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE_VENDOR, vendor); }} wrapperStyle={[styles.ph5, styles.pv3]} pendingAction={config?.export?.pendingFields?.reimbursableExpenseReportDefaultVendor} /> - {isSwitchOn && defaultVendor} + {!!reimbursableExpenseReportDefaultVendor && defaultVendor} )} From 7f01d4d51996d0ac6ee234c2816bfb19ce430a72 Mon Sep 17 00:00:00 2001 From: war-in Date: Mon, 1 Jul 2024 17:52:35 +0200 Subject: [PATCH 33/50] do not use SelectionScreen where additional components needed --- ...SageIntacctNonReimbursableExpensesPage.tsx | 74 ++++++++++--------- .../SageIntacctReimbursableExpensesPage.tsx | 68 +++++++++-------- 2 files changed, 78 insertions(+), 64 deletions(-) diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx index bd244a56f705..89e64eaace81 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx @@ -1,12 +1,14 @@ import React, {useCallback, useMemo} from 'react'; import {View} from 'react-native'; import type {ValueOf} from 'type-fest'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; +import ScreenWrapper from '@components/ScreenWrapper'; +import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; import type {ListItem} from '@components/SelectionList/types'; import type {SelectorType} from '@components/SelectionScreen'; -import SelectionScreen from '@components/SelectionScreen'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -114,42 +116,48 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { ); return ( - - + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID))} + /> + selectNonReimbursableExpense(selection as MenuListItem)} headerContent={headerContent} sections={[{data}]} - listItem={RadioListItem} - onSelectRow={(selection: SelectorType) => selectNonReimbursableExpense(selection as MenuListItem)} + ListItem={RadioListItem} + showScrollIndicator + shouldShowTooltips={false} initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} - policyID={policyID} - accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]} - featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} - onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID))} - connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} + listFooterContent={ + + {config?.export.nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL && defaultVendor} + {config?.export.nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE && ( + + {creditCardAccount} + { + const vendor = enabled ? policy?.connections?.intacct?.data?.vendors?.[0].id ?? null : null; + updateSageIntacctDefaultVendor(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_CREDIT_CARD_VENDOR, vendor); + }} + wrapperStyle={[styles.ph5, styles.pv3]} + pendingAction={config?.export?.pendingFields?.nonReimbursableCreditCardChargeDefaultVendor} + /> + {!!config?.export.nonReimbursableCreditCardChargeDefaultVendor && defaultVendor} + + )} + + } /> - {config?.export.nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL && defaultVendor} - {config?.export.nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE && ( - - {creditCardAccount} - { - const vendor = enabled ? policy?.connections?.intacct?.data?.vendors?.[0].id ?? null : null; - updateSageIntacctDefaultVendor(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_CREDIT_CARD_VENDOR, vendor); - }} - wrapperStyle={[styles.ph5, styles.pv3]} - pendingAction={config?.export?.pendingFields?.nonReimbursableCreditCardChargeDefaultVendor} - /> - {!!config?.export.nonReimbursableCreditCardChargeDefaultVendor && defaultVendor} - - )} - + ); } diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx index c55dea3b1e77..e6a2f5e8744f 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx @@ -1,12 +1,14 @@ import React, {useCallback, useMemo} from 'react'; import {View} from 'react-native'; import type {ValueOf} from 'type-fest'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; +import ScreenWrapper from '@components/ScreenWrapper'; +import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; import type {ListItem} from '@components/SelectionList/types'; import type {SelectorType} from '@components/SelectionScreen'; -import SelectionScreen from '@components/SelectionScreen'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -88,40 +90,44 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { ); return ( - - + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID))} + /> + selectReimbursableDestination(selection as MenuListItem)} headerContent={headerContent} sections={[{data}]} - listItem={RadioListItem} - onSelectRow={(selection: SelectorType) => selectReimbursableDestination(selection as MenuListItem)} + ListItem={RadioListItem} + showScrollIndicator + shouldShowTooltips={false} initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} - policyID={policyID} - accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]} - featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} - onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID))} - connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} + listFooterContent={ + reimbursable === CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE.EXPENSE_REPORT ? ( + + { + const vendor = enabled ? policy?.connections?.intacct?.data?.vendors?.[0].id ?? null : null; + updateSageIntacctDefaultVendor(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE_VENDOR, vendor); + }} + wrapperStyle={[styles.ph5, styles.pv3]} + pendingAction={config?.export?.pendingFields?.reimbursableExpenseReportDefaultVendor} + /> + {!!reimbursableExpenseReportDefaultVendor && defaultVendor} + + ) : undefined + } /> - {reimbursable === CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE.EXPENSE_REPORT && ( - - { - const vendor = enabled ? policy?.connections?.intacct?.data?.vendors?.[0].id ?? null : null; - updateSageIntacctDefaultVendor(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE_VENDOR, vendor); - }} - wrapperStyle={[styles.ph5, styles.pv3]} - pendingAction={config?.export?.pendingFields?.reimbursableExpenseReportDefaultVendor} - /> - {!!reimbursableExpenseReportDefaultVendor && defaultVendor} - - )} - + ); } From f3e5bc8698e150ecd8a9c7dcc742c195f1a2ddee Mon Sep 17 00:00:00 2001 From: war-in Date: Mon, 1 Jul 2024 18:15:42 +0200 Subject: [PATCH 34/50] bring permissions back --- src/libs/Permissions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/Permissions.ts b/src/libs/Permissions.ts index c2d885083c44..79936d498280 100644 --- a/src/libs/Permissions.ts +++ b/src/libs/Permissions.ts @@ -41,7 +41,7 @@ function canUseSpotnanaTravel(betas: OnyxEntry): boolean { } function canUseNetSuiteIntegration(betas: OnyxEntry): boolean { - return true; + return !!betas?.includes(CONST.BETAS.NETSUITE_ON_NEW_EXPENSIFY) || canUseAllBetas(betas); } function canUseReportFieldsFeature(betas: OnyxEntry): boolean { From 592c1f29b20d82af7a27c50f8ef479e85ccb820a Mon Sep 17 00:00:00 2001 From: war-in Date: Tue, 2 Jul 2024 11:42:21 +0200 Subject: [PATCH 35/50] fix translations --- src/languages/en.ts | 104 +++++++++--------- src/languages/es.ts | 92 ++++++++-------- ...ExportExpensesPayableAccountSelectPage.tsx | 4 +- ...eProvincialTaxPostingAccountSelectPage.tsx | 4 +- .../NetSuiteReceivableAccountSelectPage.tsx | 4 +- .../NetSuiteTaxPostingAccountSelectPage.tsx | 4 +- 6 files changed, 103 insertions(+), 109 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index ca0b55885a34..9b53729fbfcb 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2203,58 +2203,56 @@ export default { [CONST.XERO_CONFIG.INVOICE_STATUS.AWAITING_PAYMENT]: 'Awaiting payment', }, }, - noAccountsFound: 'No accounts found', - noAccountsFoundDescription: 'Add the account in Xero and sync the connection again.', - }, - sageIntacct: { - preferredExporter: 'Preferred exporter', - notConfigured: 'Not configured', - exportDate: { - label: 'Export date', - description: 'Use this date when exporting reports to Sage Intacct.', - values: { - [CONST.SAGE_INTACCT_EXPORT_DATE.LAST_EXPENSE]: { - label: 'Date of last expense', - description: 'Date of the most recent expense on the report.', - }, - [CONST.SAGE_INTACCT_EXPORT_DATE.REPORT_EXPORTED]: { - label: 'Export date', - description: 'Date the report was exported to Sage Intacct.', - }, - [CONST.SAGE_INTACCT_EXPORT_DATE.REPORT_SUBMITTED]: { - label: 'Submitted date', - description: 'Date the report was submitted for approval.', - }, - }, - }, - reimbursableExpenses: { - label: 'Export reimbursable expenses as', - description: 'Reimbursable expenses will export as expense reports to Sage Intacct. Bills will export as vendor bills.', - values: { - [CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE.EXPENSE_REPORT]: 'Expense reports', - [CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL]: 'Vendor bills', - }, - }, - nonReimbursableExpenses: { - label: 'Export non-reimbursable expenses as', - description: - 'Non-reimbursable expenses will export to Sage Intacct as either credit card transactions or vendor bills and credit the account selected below. Learn more about assigning cards to individual accounts.', - values: { - [CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE]: 'Credit card transactions', - [CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL]: 'Vendor bills', - }, - }, - creditCardAccount: 'Credit card account', - // TODO: verify if we need description - creditCardAccountDescription: 'We should have some description here, right?', - defaultVendor: 'Default vendor', - defaultVendorDescription: (isReimbursable: boolean): string => - `Set a default vendor that will apply to ${isReimbursable ? '' : 'non-'}reimbursable expenses that don't have a matching vendor in Sage Intacct.`, - exportDescription: 'Configure how data in Expensify gets exported to Sage Inacct.', - exportPreferredExporterNote: - 'The preferred exporter can be any workspace admin, but must also be a Domain Admin if you set different export accounts for individual company cards in Domain Settings.', - exportPreferredExporterSubNote: 'Once set, the preferred exporter will see reports for export in their account.', - }, + }, + sageIntacct: { + preferredExporter: 'Preferred exporter', + notConfigured: 'Not configured', + exportDate: { + label: 'Export date', + description: 'Use this date when exporting reports to Sage Intacct.', + values: { + [CONST.SAGE_INTACCT_EXPORT_DATE.LAST_EXPENSE]: { + label: 'Date of last expense', + description: 'Date of the most recent expense on the report.', + }, + [CONST.SAGE_INTACCT_EXPORT_DATE.REPORT_EXPORTED]: { + label: 'Export date', + description: 'Date the report was exported to Sage Intacct.', + }, + [CONST.SAGE_INTACCT_EXPORT_DATE.REPORT_SUBMITTED]: { + label: 'Submitted date', + description: 'Date the report was submitted for approval.', + }, + }, + }, + reimbursableExpenses: { + label: 'Export reimbursable expenses as', + description: 'Reimbursable expenses will export as expense reports to Sage Intacct. Bills will export as vendor bills.', + values: { + [CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE.EXPENSE_REPORT]: 'Expense reports', + [CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL]: 'Vendor bills', + }, + }, + nonReimbursableExpenses: { + label: 'Export non-reimbursable expenses as', + description: + 'Non-reimbursable expenses will export to Sage Intacct as either credit card transactions or vendor bills and credit the account selected below. Learn more about assigning cards to individual accounts.', + values: { + [CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE]: 'Credit card transactions', + [CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL]: 'Vendor bills', + }, + }, + creditCardAccount: 'Credit card account', + // TODO: verify if we need description + creditCardAccountDescription: 'We should have some description here, right?', + defaultVendor: 'Default vendor', + defaultVendorDescription: (isReimbursable: boolean): string => + `Set a default vendor that will apply to ${isReimbursable ? '' : 'non-'}reimbursable expenses that don't have a matching vendor in Sage Intacct.`, + exportDescription: 'Configure how data in Expensify gets exported to Sage Inacct.', + exportPreferredExporterNote: + 'The preferred exporter can be any workspace admin, but must also be a Domain Admin if you set different export accounts for individual company cards in Domain Settings.', + exportPreferredExporterSubNote: 'Once set, the preferred exporter will see reports for export in their account.', + }, netsuite: { subsidiary: 'Subsidiary', subsidiarySelectDescription: "Choose the subsidiary in NetSuite that you'd like to import data from.", @@ -2337,8 +2335,6 @@ export default { }, }, }, - noAccountsFound: 'No accounts found', - noAccountsFoundDescription: 'Add the account in NetSuite and sync the connection again.', noVendorsFound: 'No vendors found', noVendorsFoundDescription: 'Add vendors in NetSuite and sync the connection again.', noItemsFound: 'No invoice items found', diff --git a/src/languages/es.ts b/src/languages/es.ts index acd2c719dbe4..358e92a1106d 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2238,54 +2238,54 @@ export default { }, }, - sageIntacct: { - preferredExporter: 'Exportador preferido', - notConfigured: 'No configurado', - exportDate: { - label: 'Fecha de exportación', - description: 'Utilice esta fecha cuando exporte informes a Sage Intacct.', - values: { - [CONST.SAGE_INTACCT_EXPORT_DATE.LAST_EXPENSE]: { - label: 'Fecha del último gasto', - description: 'Fecha del gasto más reciente del informe.', + sageIntacct: { + preferredExporter: 'Exportador preferido', + notConfigured: 'No configurado', + exportDate: { + label: 'Fecha de exportación', + description: 'Utilice esta fecha cuando exporte informes a Sage Intacct.', + values: { + [CONST.SAGE_INTACCT_EXPORT_DATE.LAST_EXPENSE]: { + label: 'Fecha del último gasto', + description: 'Fecha del gasto más reciente del informe.', + }, + [CONST.SAGE_INTACCT_EXPORT_DATE.REPORT_EXPORTED]: { + label: 'Fecha de exportación', + description: 'Fecha en la que se exportó el informe a Sage Intacct.', + }, + [CONST.SAGE_INTACCT_EXPORT_DATE.REPORT_SUBMITTED]: { + label: 'Fecha de envío', + description: 'Fecha de presentación del informe para su aprobación.', + }, + }, }, - [CONST.SAGE_INTACCT_EXPORT_DATE.REPORT_EXPORTED]: { - label: 'Fecha de exportación', - description: 'Fecha en la que se exportó el informe a Sage Intacct.', + reimbursableExpenses: { + label: 'Gastos reembolsables de exportación como', + description: 'Los gastos reembolsables se exportarán como informes de gastos a Sage Intacct. Las facturas se exportarán como facturas de proveedores.', + values: { + [CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE.EXPENSE_REPORT]: 'Informes de gastos', + [CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL]: 'Facturas de proveedores', + }, }, - [CONST.SAGE_INTACCT_EXPORT_DATE.REPORT_SUBMITTED]: { - label: 'Fecha de envío', - description: 'Fecha de presentación del informe para su aprobación.', + nonReimbursableExpenses: { + label: 'Exportar gastos no reembolsables como', + description: + 'Los gastos no reembolsables se exportarán a Sage Intacct como transacciones de tarjetas de crédito o facturas de proveedores y se abonarán en la cuenta seleccionada a continuación. Más información sobre la asignación de tarjetas a cuentas individuales.', + values: { + [CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE]: 'Transacciones con tarjeta de crédito', + [CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL]: 'Facturas de proveedores', + }, }, - }, - }, - reimbursableExpenses: { - label: 'Gastos reembolsables de exportación como', - description: 'Los gastos reembolsables se exportarán como informes de gastos a Sage Intacct. Las facturas se exportarán como facturas de proveedores.', - values: { - [CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE.EXPENSE_REPORT]: 'Informes de gastos', - [CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL]: 'Facturas de proveedores', - }, - }, - nonReimbursableExpenses: { - label: 'Exportar gastos no reembolsables como', - description: - 'Los gastos no reembolsables se exportarán a Sage Intacct como transacciones de tarjetas de crédito o facturas de proveedores y se abonarán en la cuenta seleccionada a continuación. Más información sobre la asignación de tarjetas a cuentas individuales.', - values: { - [CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE]: 'Transacciones con tarjeta de crédito', - [CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL]: 'Facturas de proveedores', - }, - }, - creditCardAccount: 'Cuenta de tarjeta de crédito', - creditCardAccountDescription: '!!!!!!!!', - defaultVendor: 'Proveedor por defecto', - defaultVendorDescription: (isReimbursable: boolean): string => - `Establezca un proveedor predeterminado que se aplicará a los gastos ${isReimbursable ? '' : 'no '}reembolsables que no tienen un proveedor coincidente en Sage Intacct.`, - exportDescription: 'Configure cómo se exportan los datos de Expensify a Sage Inacct.', - exportPreferredExporterNote: - 'El exportador preferido puede ser cualquier administrador del área de trabajo, pero también debe ser un administrador del dominio si establece diferentes cuentas de exportación para tarjetas de empresa individuales en Configuración del dominio.', - exportPreferredExporterSubNote: 'Una vez configurado, el exportador preferido verá los informes para exportar en su cuenta.', - }, + creditCardAccount: 'Cuenta de tarjeta de crédito', + creditCardAccountDescription: '!!!!!!!!', + defaultVendor: 'Proveedor por defecto', + defaultVendorDescription: (isReimbursable: boolean): string => + `Establezca un proveedor predeterminado que se aplicará a los gastos ${isReimbursable ? '' : 'no '}reembolsables que no tienen un proveedor coincidente en Sage Intacct.`, + exportDescription: 'Configure cómo se exportan los datos de Expensify a Sage Inacct.', + exportPreferredExporterNote: + 'El exportador preferido puede ser cualquier administrador del área de trabajo, pero también debe ser un administrador del dominio si establece diferentes cuentas de exportación para tarjetas de empresa individuales en Configuración del dominio.', + exportPreferredExporterSubNote: 'Una vez configurado, el exportador preferido verá los informes para exportar en su cuenta.', + }, netsuite: { subsidiary: 'Subsidiaria', subsidiarySelectDescription: 'Elige la subsidiaria de NetSuite de la que deseas importar datos.', @@ -2368,8 +2368,6 @@ export default { }, }, }, - noAccountsFound: 'No se han encontrado cuentas', - noAccountsFoundDescription: 'Añade la cuenta en NetSuite y sincroniza la conexión de nuevo.', noVendorsFound: 'No se han encontrado proveedores', noVendorsFoundDescription: 'Añade proveedores en NetSuite y sincroniza la conexión de nuevo.', noItemsFound: 'No se han encontrado artículos de factura', diff --git a/src/pages/workspace/accounting/netsuite/export/NetSuiteExportExpensesPayableAccountSelectPage.tsx b/src/pages/workspace/accounting/netsuite/export/NetSuiteExportExpensesPayableAccountSelectPage.tsx index c640e183bc99..9de86a57f95c 100644 --- a/src/pages/workspace/accounting/netsuite/export/NetSuiteExportExpensesPayableAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/netsuite/export/NetSuiteExportExpensesPayableAccountSelectPage.tsx @@ -53,8 +53,8 @@ function NetSuiteExportExpensesPayableAccountSelectPage({policy}: WithPolicyConn icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.netsuite.noAccountsFound')} - subtitle={translate('workspace.netsuite.noAccountsFoundDescription')} + title={translate('workspace.common.noAccountsFound')} + subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.NETSUITE)} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/netsuite/export/NetSuiteProvincialTaxPostingAccountSelectPage.tsx b/src/pages/workspace/accounting/netsuite/export/NetSuiteProvincialTaxPostingAccountSelectPage.tsx index d5a5ca8f73a1..92d20ce33164 100644 --- a/src/pages/workspace/accounting/netsuite/export/NetSuiteProvincialTaxPostingAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/netsuite/export/NetSuiteProvincialTaxPostingAccountSelectPage.tsx @@ -48,8 +48,8 @@ function NetSuiteProvincialTaxPostingAccountSelectPage({policy}: WithPolicyConne icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.netsuite.noAccountsFound')} - subtitle={translate('workspace.netsuite.noAccountsFoundDescription')} + title={translate('workspace.common.noAccountsFound')} + subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.NETSUITE)} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/netsuite/export/NetSuiteReceivableAccountSelectPage.tsx b/src/pages/workspace/accounting/netsuite/export/NetSuiteReceivableAccountSelectPage.tsx index 3f5066d6cc71..7141744a0069 100644 --- a/src/pages/workspace/accounting/netsuite/export/NetSuiteReceivableAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/netsuite/export/NetSuiteReceivableAccountSelectPage.tsx @@ -45,8 +45,8 @@ function NetSuiteReceivableAccountSelectPage({policy}: WithPolicyConnectionsProp icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.netsuite.noAccountsFound')} - subtitle={translate('workspace.netsuite.noAccountsFoundDescription')} + title={translate('workspace.common.noAccountsFound')} + subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.NETSUITE)} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/netsuite/export/NetSuiteTaxPostingAccountSelectPage.tsx b/src/pages/workspace/accounting/netsuite/export/NetSuiteTaxPostingAccountSelectPage.tsx index c9f52b4994ae..d369cffe12d5 100644 --- a/src/pages/workspace/accounting/netsuite/export/NetSuiteTaxPostingAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/netsuite/export/NetSuiteTaxPostingAccountSelectPage.tsx @@ -50,8 +50,8 @@ function NetSuiteTaxPostingAccountSelectPage({policy}: WithPolicyConnectionsProp icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.netsuite.noAccountsFound')} - subtitle={translate('workspace.netsuite.noAccountsFoundDescription')} + title={translate('workspace.common.noAccountsFound')} + subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.NETSUITE)} containerStyle={styles.pb10} /> ), From 811e7b92e7f705a1f1008f903d6ea71984861ebb Mon Sep 17 00:00:00 2001 From: war-in Date: Tue, 2 Jul 2024 13:12:15 +0200 Subject: [PATCH 36/50] get rid of focused key --- src/CONST.ts | 4 ++-- src/languages/en.ts | 4 ++-- src/languages/es.ts | 4 ++-- .../intacct/export/SageIntacctNonReimbursableExpensesPage.tsx | 1 - .../intacct/export/SageIntacctReimbursableExpensesPage.tsx | 1 - 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index c9c6ed6e9a62..5cbf8fa65ef5 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1374,8 +1374,8 @@ const CONST = { SAGE_INTACCT_EXPORT_DATE: { LAST_EXPENSE: 'LAST_EXPENSE', - REPORT_EXPORTED: 'REPORT_EXPORTED', - REPORT_SUBMITTED: 'REPORT_SUBMITTED', + EXPORTED: 'EXPORTED', + SUBMITTED: 'SUBMITTED', }, NETSUITE_CONFIG: { diff --git a/src/languages/en.ts b/src/languages/en.ts index 9b53729fbfcb..61c929c7bd06 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2215,11 +2215,11 @@ export default { label: 'Date of last expense', description: 'Date of the most recent expense on the report.', }, - [CONST.SAGE_INTACCT_EXPORT_DATE.REPORT_EXPORTED]: { + [CONST.SAGE_INTACCT_EXPORT_DATE.EXPORTED]: { label: 'Export date', description: 'Date the report was exported to Sage Intacct.', }, - [CONST.SAGE_INTACCT_EXPORT_DATE.REPORT_SUBMITTED]: { + [CONST.SAGE_INTACCT_EXPORT_DATE.SUBMITTED]: { label: 'Submitted date', description: 'Date the report was submitted for approval.', }, diff --git a/src/languages/es.ts b/src/languages/es.ts index 358e92a1106d..e9e01625dd3e 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2249,11 +2249,11 @@ export default { label: 'Fecha del último gasto', description: 'Fecha del gasto más reciente del informe.', }, - [CONST.SAGE_INTACCT_EXPORT_DATE.REPORT_EXPORTED]: { + [CONST.SAGE_INTACCT_EXPORT_DATE.EXPORTED]: { label: 'Fecha de exportación', description: 'Fecha en la que se exportó el informe a Sage Intacct.', }, - [CONST.SAGE_INTACCT_EXPORT_DATE.REPORT_SUBMITTED]: { + [CONST.SAGE_INTACCT_EXPORT_DATE.SUBMITTED]: { label: 'Fecha de envío', description: 'Fecha de presentación del informe para su aprobación.', }, diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx index 89e64eaace81..c95b79a2c22c 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx @@ -131,7 +131,6 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { ListItem={RadioListItem} showScrollIndicator shouldShowTooltips={false} - initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} listFooterContent={ {config?.export.nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL && defaultVendor} diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx index e6a2f5e8744f..84f08125fe95 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx @@ -105,7 +105,6 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { ListItem={RadioListItem} showScrollIndicator shouldShowTooltips={false} - initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} listFooterContent={ reimbursable === CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE.EXPENSE_REPORT ? ( From cd3aa6a48028ea7d3d69e15a624875af9cfb89e2 Mon Sep 17 00:00:00 2001 From: war-in Date: Tue, 2 Jul 2024 13:30:51 +0200 Subject: [PATCH 37/50] use const for the reimbursable route --- src/ROUTES.ts | 24 +++++++++---------- .../export/SageIntacctDefaultVendorPage.tsx | 2 +- ...SageIntacctNonReimbursableExpensesPage.tsx | 2 +- .../SageIntacctReimbursableExpensesPage.tsx | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 3072ecc6889e..83202af0e069 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -1014,28 +1014,28 @@ const ROUTES = { getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/sage-intacct/export` as const, }, POLICY_ACCOUNTING_SAGE_INTACCT_PREFERRED_EXPORTER: { - route: 'settings/workspaces/:policyID/connections/sage-intacct/export/preferred-exporter', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/sage-intacct/export/preferred-exporter` as const, + route: 'settings/workspaces/:policyID/accounting/sage-intacct/export/preferred-exporter', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/sage-intacct/export/preferred-exporter` as const, }, POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT_DATE: { - route: 'settings/workspaces/:policyID/connections/sage-intacct/export/date', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/sage-intacct/export/date` as const, + route: 'settings/workspaces/:policyID/accounting/sage-intacct/export/date', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/sage-intacct/export/date` as const, }, POLICY_ACCOUNTING_SAGE_INTACCT_REIMBURSABLE_EXPENSES: { - route: 'settings/workspaces/:policyID/connections/sage-intacct/export/reimbursable', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/sage-intacct/export/reimbursable` as const, + route: 'settings/workspaces/:policyID/accounting/sage-intacct/export/reimbursable', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/sage-intacct/export/reimbursable` as const, }, POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES: { - route: 'settings/workspaces/:policyID/connections/sage-intacct/export/non-reimbursable', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/sage-intacct/export/non-reimbursable` as const, + route: 'settings/workspaces/:policyID/accounting/sage-intacct/export/nonreimbursable', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/sage-intacct/export/nonreimbursable` as const, }, POLICY_ACCOUNTING_SAGE_INTACCT_DEFAULT_VENDOR: { - route: 'settings/workspaces/:policyID/connections/sage-intacct/export/:reimbursable/default-vendor', - getRoute: (policyID: string, reimbursable: string) => `settings/workspaces/${policyID}/connections/sage-intacct/export/${reimbursable}/default-vendor` as const, + route: 'settings/workspaces/:policyID/accounting/sage-intacct/export/:reimbursable/default-vendor', + getRoute: (policyID: string, reimbursable: string) => `settings/workspaces/${policyID}/accounting/sage-intacct/export/${reimbursable}/default-vendor` as const, }, POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT: { - route: 'settings/workspaces/:policyID/connections/sage-intacct/export/non-reimbursable/credit-card-account', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/sage-intacct/export/non-reimbursable/credit-card-account` as const, + route: 'settings/workspaces/:policyID/accounting/sage-intacct/export/nonreimbursable/credit-card-account', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/sage-intacct/export/nonreimbursable/credit-card-account` as const, }, } as const; diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx index 63f1399cc8af..f2e95ab22c28 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx @@ -30,7 +30,7 @@ function SageIntacctDefaultVendorPage({route}: SageIntacctDefaultVendorPageProps const policyID = route.params.policyID ?? '-1'; const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); - const isReimbursable = route.params.reimbursable === 'reimbursable'; + const isReimbursable = route.params.reimbursable === CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE; let defaultVendor; let settingName: keyof Connections['intacct']['config']['export']; diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx index c95b79a2c22c..6b27bb31b275 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx @@ -65,7 +65,7 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { const activeDefaultVendor = getSageIntacctNonReimbursableActiveDefaultVendor(policy); const defaultVendorSection = { description: translate('workspace.sageIntacct.defaultVendor'), - action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_DEFAULT_VENDOR.getRoute(policyID, 'non-reimbursable')), + action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_DEFAULT_VENDOR.getRoute(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE.toLowerCase())), title: activeDefaultVendor ? getDefaultVendorName(activeDefaultVendor, intacctData?.vendors ?? []) : translate('workspace.sageIntacct.notConfigured'), hasError: config?.export.nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx index 84f08125fe95..70d30d9a0bff 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx @@ -66,7 +66,7 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { const defaultVendorSection = { description: translate('workspace.sageIntacct.defaultVendor'), - action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_DEFAULT_VENDOR.getRoute(policyID, 'reimbursable')), + action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_DEFAULT_VENDOR.getRoute(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE)), title: reimbursableExpenseReportDefaultVendor ? getDefaultVendorName(reimbursableExpenseReportDefaultVendor, intacctData?.vendors ?? []) : translate('workspace.sageIntacct.notConfigured'), From 2a669757b9522c03fe50307f8308667be2d4a03e Mon Sep 17 00:00:00 2001 From: war-in Date: Tue, 2 Jul 2024 13:33:03 +0200 Subject: [PATCH 38/50] update pages default names --- .../workspace/accounting/intacct/export/SageIntacctDatePage.tsx | 2 +- .../accounting/intacct/export/SageIntacctDefaultVendorPage.tsx | 2 +- .../accounting/intacct/export/SageIntacctExportPage.tsx | 2 +- .../export/SageIntacctNonReimbursableCreditCardAccountPage.tsx | 2 +- .../intacct/export/SageIntacctNonReimbursableExpensesPage.tsx | 2 +- .../intacct/export/SageIntacctPreferredExporterPage.tsx | 2 +- .../intacct/export/SageIntacctReimbursableExpensesPage.tsx | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx index 20850119d828..62f102f664a3 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx @@ -69,6 +69,6 @@ function SageIntacctDatePage({policy}: WithPolicyProps) { ); } -SageIntacctDatePage.displayName = 'PolicySageIntacctDatePage'; +SageIntacctDatePage.displayName = 'SageIntacctDatePage'; export default withPolicyConnections(SageIntacctDatePage); diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx index f2e95ab22c28..f3739f191e93 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx @@ -106,6 +106,6 @@ function SageIntacctDefaultVendorPage({route}: SageIntacctDefaultVendorPageProps ); } -SageIntacctDefaultVendorPage.displayName = 'PolicySageIntacctDefaultVendorPage'; +SageIntacctDefaultVendorPage.displayName = 'SageIntacctDefaultVendorPage'; export default SageIntacctDefaultVendorPage; diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx index 565aeacc185a..b6aceb56b6ce 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctExportPage.tsx @@ -86,6 +86,6 @@ function SageIntacctExportPage({policy}: WithPolicyProps) { ); } -SageIntacctExportPage.displayName = 'PolicySageIntacctExportPage'; +SageIntacctExportPage.displayName = 'SageIntacctExportPage'; export default withPolicyConnections(SageIntacctExportPage); diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx index a3d60f3d560e..2d298d24eee3 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx @@ -78,6 +78,6 @@ function SageIntacctNonReimbursableCreditCardAccountPage({policy}: WithPolicyCon ); } -SageIntacctNonReimbursableCreditCardAccountPage.displayName = 'PolicySageIntacctNonReimbursableCreditCardAccountPage'; +SageIntacctNonReimbursableCreditCardAccountPage.displayName = 'SageIntacctNonReimbursableCreditCardAccountPage'; export default withPolicyConnections(SageIntacctNonReimbursableCreditCardAccountPage); diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx index 6b27bb31b275..0c4ce1a8441f 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx @@ -160,6 +160,6 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { ); } -SageIntacctNonReimbursableExpensesPage.displayName = 'PolicySageIntacctNonReimbursableExpensesPage'; +SageIntacctNonReimbursableExpensesPage.displayName = 'SageIntacctNonReimbursableExpensesPage'; export default withPolicyConnections(SageIntacctNonReimbursableExpensesPage); diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx index 3558835b3314..abbb87982a5e 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage.tsx @@ -99,6 +99,6 @@ function SageIntacctPreferredExporterPage({policy}: WithPolicyProps) { ); } -SageIntacctPreferredExporterPage.displayName = 'PolicySageIntacctPreferredExporterPage'; +SageIntacctPreferredExporterPage.displayName = 'SageIntacctPreferredExporterPage'; export default withPolicyConnections(SageIntacctPreferredExporterPage); diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx index 70d30d9a0bff..b1aa6d752886 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx @@ -130,6 +130,6 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { ); } -SageIntacctReimbursableExpensesPage.displayName = 'PolicySageIntacctReimbursableExpensesPage'; +SageIntacctReimbursableExpensesPage.displayName = 'SageIntacctReimbursableExpensesPage'; export default withPolicyConnections(SageIntacctReimbursableExpensesPage); From c091bfe0f9c1672597b080713ad0837b4413f3ee Mon Sep 17 00:00:00 2001 From: war-in Date: Tue, 2 Jul 2024 13:51:45 +0200 Subject: [PATCH 39/50] add proper access variants to all pages --- .../intacct/export/SageIntacctDatePage.tsx | 2 +- .../export/SageIntacctDefaultVendorPage.tsx | 1 + ...ctNonReimbursableCreditCardAccountPage.tsx | 1 + ...SageIntacctNonReimbursableExpensesPage.tsx | 35 +++++++------------ .../SageIntacctReimbursableExpensesPage.tsx | 35 +++++++------------ 5 files changed, 29 insertions(+), 45 deletions(-) diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx index 62f102f664a3..51d08423e530 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDatePage.tsx @@ -61,7 +61,7 @@ function SageIntacctDatePage({policy}: WithPolicyProps) { onSelectRow={(selection: SelectorType) => selectExportDate(selection as MenuListItem)} initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} policyID={policyID} - accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]} + accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]} featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID))} connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx index f3739f191e93..d32c8472f944 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx @@ -101,6 +101,7 @@ function SageIntacctDefaultVendorPage({route}: SageIntacctDefaultVendorPageProps } title="workspace.sageIntacct.defaultVendor" listEmptyContent={listEmptyContent} + accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]} connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} /> ); diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx index 2d298d24eee3..1da1627189d5 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx @@ -73,6 +73,7 @@ function SageIntacctNonReimbursableCreditCardAccountPage({policy}: WithPolicyCon onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID))} title="workspace.sageIntacct.creditCardAccount" listEmptyContent={listEmptyContent} + accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]} connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} /> ); diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx index 0c4ce1a8441f..ff1ca7a36634 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx @@ -1,15 +1,13 @@ -import React, {useCallback, useMemo} from 'react'; +import React, {useCallback} from 'react'; import {View} from 'react-native'; import type {ValueOf} from 'type-fest'; -import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import ConnectionLayout from '@components/ConnectionLayout'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; -import ScreenWrapper from '@components/ScreenWrapper'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; import type {ListItem} from '@components/SelectionList/types'; import type {SelectorType} from '@components/SelectionScreen'; -import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import {getSageIntacctNonReimbursableActiveDefaultVendor} from '@libs/PolicyUtils'; @@ -43,15 +41,6 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { isSelected: config?.export.nonReimbursable === expenseType, })); - const headerContent = useMemo( - () => ( - - {translate('workspace.sageIntacct.nonReimbursableExpenses.description')} - - ), - [translate, styles.pb5, styles.ph5], - ); - const selectNonReimbursableExpense = useCallback( (row: MenuListItem) => { if (row.value === config?.export.nonReimbursable) { @@ -116,17 +105,19 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { ); return ( - - Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID))} - /> selectNonReimbursableExpense(selection as MenuListItem)} - headerContent={headerContent} sections={[{data}]} ListItem={RadioListItem} showScrollIndicator @@ -156,7 +147,7 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { } /> - + ); } diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx index b1aa6d752886..1bdac2b3eb62 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx @@ -1,15 +1,13 @@ -import React, {useCallback, useMemo} from 'react'; +import React, {useCallback} from 'react'; import {View} from 'react-native'; import type {ValueOf} from 'type-fest'; -import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import ConnectionLayout from '@components/ConnectionLayout'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; -import ScreenWrapper from '@components/ScreenWrapper'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; import type {ListItem} from '@components/SelectionList/types'; import type {SelectorType} from '@components/SelectionScreen'; -import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@navigation/Navigation'; @@ -43,15 +41,6 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { isSelected: reimbursable === expenseType, })); - const headerContent = useMemo( - () => ( - - {translate('workspace.sageIntacct.reimbursableExpenses.description')} - - ), - [translate, styles.pb5, styles.ph5], - ); - const selectReimbursableDestination = useCallback( (row: MenuListItem) => { if (row.value !== reimbursable) { @@ -90,17 +79,19 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { ); return ( - - Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID))} - /> selectReimbursableDestination(selection as MenuListItem)} - headerContent={headerContent} sections={[{data}]} ListItem={RadioListItem} showScrollIndicator @@ -126,7 +117,7 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { ) : undefined } /> - + ); } From 24fe201420fb07e1a1d99de14a8414cce75d9dc3 Mon Sep 17 00:00:00 2001 From: war-in Date: Tue, 2 Jul 2024 14:13:27 +0200 Subject: [PATCH 40/50] prettier --- .../AppNavigator/ModalStackNavigators/index.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 064395aeff5b..c6ae9cd9ec8b 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -350,15 +350,16 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/intacct/ExistingConnectionsPage').default, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_EXPORT]: () => require('../../../../pages/workspace/accounting/intacct/export/SageIntacctExportPage').default, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREFERRED_EXPORTER]: () => - require('../../../../pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage').default, + require('../../../../pages/workspace/accounting/intacct/export/SageIntacctPreferredExporterPage').default, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_EXPORT_DATE]: () => require('../../../../pages/workspace/accounting/intacct/export/SageIntacctDatePage').default, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_REIMBURSABLE_EXPENSES]: () => - require('../../../../pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage').default, + require('../../../../pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage').default, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES]: () => - require('../../../../pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage').default, - [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_DEFAULT_VENDOR]: () => require('../../../../pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage').default, + require('../../../../pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage').default, + [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_DEFAULT_VENDOR]: () => + require('../../../../pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage').default, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT]: () => - require('../../../../pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage').default, + require('../../../../pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage').default, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_FREQUENCY]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage').default, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingMonthlyOffsetPage').default, [SCREENS.WORKSPACE.TAX_EDIT]: () => require('../../../../pages/workspace/taxes/WorkspaceEditTaxPage').default, From 47884d6edc852beebb0971d64727d119c81d69a4 Mon Sep 17 00:00:00 2001 From: war-in Date: Wed, 3 Jul 2024 10:57:09 +0200 Subject: [PATCH 41/50] set `shouldUseScrollView` prop in ConnectionLayout --- .../intacct/export/SageIntacctNonReimbursableExpensesPage.tsx | 2 ++ .../intacct/export/SageIntacctReimbursableExpensesPage.tsx | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx index ff1ca7a36634..48814300fa75 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx @@ -115,6 +115,8 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { displayName={SageIntacctNonReimbursableExpensesPage.displayName} policyID={policyID} connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} + contentContainerStyle={[styles.flex1]} + shouldUseScrollView={false} > selectNonReimbursableExpense(selection as MenuListItem)} diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx index 1bdac2b3eb62..afa6afc90ee8 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx @@ -89,6 +89,8 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { displayName={SageIntacctReimbursableExpensesPage.displayName} policyID={policyID} connectionName={CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT} + contentContainerStyle={[styles.flex1]} + shouldUseScrollView={false} > selectReimbursableDestination(selection as MenuListItem)} From d89ae009f67c86499b72c0ebc0852d929fd8f2ee Mon Sep 17 00:00:00 2001 From: war-in Date: Thu, 4 Jul 2024 15:43:48 +0200 Subject: [PATCH 42/50] address comments --- src/libs/actions/connections/SageIntacct.ts | 18 +-- ...SageIntacctNonReimbursableExpensesPage.tsx | 114 ++++++++++-------- 2 files changed, 73 insertions(+), 59 deletions(-) diff --git a/src/libs/actions/connections/SageIntacct.ts b/src/libs/actions/connections/SageIntacct.ts index 5d56d8484fa3..ce3cfdc69ec9 100644 --- a/src/libs/actions/connections/SageIntacct.ts +++ b/src/libs/actions/connections/SageIntacct.ts @@ -31,7 +31,7 @@ function connectToSageIntacct(policyID: string, credentials: SageIntacctCredenti API.write(WRITE_COMMANDS.CONNECT_POLICY_TO_SAGE_INTACCT, parameters, {}); } -function prepareOnyxData(policyID: string, settingName: keyof Connections['intacct']['config']['export'], settingValue: string | null) { +function prepareOnyxDataForExportUpdate(policyID: string, settingName: keyof Connections['intacct']['config']['export'], settingValue: string | null) { const optimisticData: OnyxUpdate[] = [ { onyxMethod: Onyx.METHOD.MERGE, @@ -108,7 +108,7 @@ function prepareOnyxData(policyID: string, settingName: keyof Connections['intac } function updateSageIntacctExporter(policyID: string, exporter: string) { - const {optimisticData, failureData, successData} = prepareOnyxData(policyID, CONST.SAGE_INTACCT_CONFIG.EXPORTER, exporter); + const {optimisticData, failureData, successData} = prepareOnyxDataForExportUpdate(policyID, CONST.SAGE_INTACCT_CONFIG.EXPORTER, exporter); const parameters: UpdateSageIntacctExporterParams = { policyID, email: exporter, @@ -118,7 +118,7 @@ function updateSageIntacctExporter(policyID: string, exporter: string) { } function updateSageIntacctExportDate(policyID: string, date: ValueOf) { - const {optimisticData, failureData, successData} = prepareOnyxData(policyID, CONST.SAGE_INTACCT_CONFIG.EXPORT_DATE, date); + const {optimisticData, failureData, successData} = prepareOnyxDataForExportUpdate(policyID, CONST.SAGE_INTACCT_CONFIG.EXPORT_DATE, date); const parameters: UpdateSageIntacctExportDateParams = { policyID, value: date, @@ -128,7 +128,7 @@ function updateSageIntacctExportDate(policyID: string, date: ValueOf) { - const {optimisticData, failureData, successData} = prepareOnyxData(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE, reimbursable); + const {optimisticData, failureData, successData} = prepareOnyxDataForExportUpdate(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE, reimbursable); const parameters: UpdateSageIntacctReimbursableExpensesExportDestinationParams = { policyID, value: reimbursable, @@ -138,7 +138,7 @@ function updateSageIntacctReimbursableExpensesExportDestination(policyID: string } function updateSageIntacctNonreimbursableExpensesExportDestination(policyID: string, nonReimbursable: ValueOf) { - const {optimisticData, failureData, successData} = prepareOnyxData(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE, nonReimbursable); + const {optimisticData, failureData, successData} = prepareOnyxDataForExportUpdate(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE, nonReimbursable); const parameters: UpdateSageIntacctNonreimbursableExpensesExportDestinationParams = { policyID, value: nonReimbursable, @@ -148,7 +148,7 @@ function updateSageIntacctNonreimbursableExpensesExportDestination(policyID: str } function updateSageIntacctReimbursableExpensesReportExportDefaultVendor(policyID: string, vendor: string | null) { - const {optimisticData, failureData, successData} = prepareOnyxData(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE_VENDOR, vendor); + const {optimisticData, failureData, successData} = prepareOnyxDataForExportUpdate(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE_VENDOR, vendor); const parameters: UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams = { policyID, vendorID: vendor, @@ -158,7 +158,7 @@ function updateSageIntacctReimbursableExpensesReportExportDefaultVendor(policyID } function updateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendor(policyID: string, vendor: string | null) { - const {optimisticData, failureData, successData} = prepareOnyxData(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_CREDIT_CARD_VENDOR, vendor); + const {optimisticData, failureData, successData} = prepareOnyxDataForExportUpdate(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_CREDIT_CARD_VENDOR, vendor); const parameters: UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams = { policyID, vendorID: vendor, @@ -168,7 +168,7 @@ function updateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVe } function updateSageIntacctNonreimbursableExpensesExportAccount(policyID: string, nonReimbursableAccount: string) { - const {optimisticData, failureData, successData} = prepareOnyxData(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_ACCOUNT, nonReimbursableAccount); + const {optimisticData, failureData, successData} = prepareOnyxDataForExportUpdate(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_ACCOUNT, nonReimbursableAccount); const parameters: UpdateSageIntacctNonreimbursableExpensesExportAccountParams = { policyID, bankAccountID: nonReimbursableAccount, @@ -178,7 +178,7 @@ function updateSageIntacctNonreimbursableExpensesExportAccount(policyID: string, } function updateSageIntacctNonreimbursableExpensesExportVendor(policyID: string, vendor: string | null) { - const {optimisticData, failureData, successData} = prepareOnyxData(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_VENDOR, vendor); + const {optimisticData, failureData, successData} = prepareOnyxDataForExportUpdate(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_VENDOR, vendor); const parameters: UpdateSageIntacctNonreimbursableExpensesExportVendorParams = { policyID, vendorID: vendor, diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx index 48814300fa75..5c7e52bc03fe 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx @@ -1,4 +1,4 @@ -import React, {useCallback} from 'react'; +import React, {useCallback, useMemo} from 'react'; import {View} from 'react-native'; import type {ValueOf} from 'type-fest'; import ConnectionLayout from '@components/ConnectionLayout'; @@ -51,58 +51,72 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { [config?.export.nonReimbursable, policyID], ); - const activeDefaultVendor = getSageIntacctNonReimbursableActiveDefaultVendor(policy); - const defaultVendorSection = { - description: translate('workspace.sageIntacct.defaultVendor'), - action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_DEFAULT_VENDOR.getRoute(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE.toLowerCase())), - title: activeDefaultVendor ? getDefaultVendorName(activeDefaultVendor, intacctData?.vendors ?? []) : translate('workspace.sageIntacct.notConfigured'), - hasError: - config?.export.nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL - ? !!config?.export?.errorFields?.nonReimbursableVendor - : !!config?.export?.errorFields?.nonReimbursableCreditCardChargeDefaultVendor, - pendingAction: - config?.export.nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL - ? config?.export?.pendingFields?.nonReimbursableVendor - : config?.export?.pendingFields?.nonReimbursableCreditCardChargeDefaultVendor, - }; + const defaultVendor = useMemo(() => { + const activeDefaultVendor = getSageIntacctNonReimbursableActiveDefaultVendor(policy); + const defaultVendorSection = { + description: translate('workspace.sageIntacct.defaultVendor'), + action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_DEFAULT_VENDOR.getRoute(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE.toLowerCase())), + title: activeDefaultVendor ? getDefaultVendorName(activeDefaultVendor, intacctData?.vendors ?? []) : translate('workspace.sageIntacct.notConfigured'), + hasError: + config?.export.nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL + ? !!config?.export?.errorFields?.nonReimbursableVendor + : !!config?.export?.errorFields?.nonReimbursableCreditCardChargeDefaultVendor, + pendingAction: + config?.export.nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL + ? config?.export?.pendingFields?.nonReimbursableVendor + : config?.export?.pendingFields?.nonReimbursableCreditCardChargeDefaultVendor, + }; - const defaultVendor = ( - - - - ); + return ( + + + + ); + }, [ + config?.export?.errorFields?.nonReimbursableCreditCardChargeDefaultVendor, + config?.export?.errorFields?.nonReimbursableVendor, + config?.export.nonReimbursable, + config?.export?.pendingFields?.nonReimbursableCreditCardChargeDefaultVendor, + config?.export?.pendingFields?.nonReimbursableVendor, + intacctData?.vendors, + policy, + policyID, + translate, + ]); - const creditCardAccountSection = { - description: translate('workspace.sageIntacct.creditCardAccount'), - action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT.getRoute(policyID)), - title: config?.export.nonReimbursableAccount ? config.export.nonReimbursableAccount : translate('workspace.sageIntacct.notConfigured'), - hasError: !!config?.export?.errorFields?.nonReimbursableAccount, - pendingAction: config?.export?.pendingFields?.nonReimbursableAccount, - }; + const creditCardAccount = useMemo(() => { + const creditCardAccountSection = { + description: translate('workspace.sageIntacct.creditCardAccount'), + action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT.getRoute(policyID)), + title: config?.export.nonReimbursableAccount ? config.export.nonReimbursableAccount : translate('workspace.sageIntacct.notConfigured'), + hasError: !!config?.export?.errorFields?.nonReimbursableAccount, + pendingAction: config?.export?.pendingFields?.nonReimbursableAccount, + }; - const creditCardAccount = ( - - - - ); + return ( + + + + ); + }, [config?.export?.errorFields?.nonReimbursableAccount, config?.export.nonReimbursableAccount, config?.export?.pendingFields?.nonReimbursableAccount, policyID, translate]); return ( Date: Fri, 5 Jul 2024 08:39:40 +0200 Subject: [PATCH 43/50] after merge fixes --- src/languages/en.ts | 2 -- .../intacct/export/SageIntacctNonReimbursableExpensesPage.tsx | 2 +- .../intacct/export/SageIntacctReimbursableExpensesPage.tsx | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index eaeec7313208..18ef73c1ec61 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2384,8 +2384,6 @@ export default { }, }, }, - noAccountsFound: 'No accounts found', - noAccountsFoundDescription: 'Add the account in NetSuite and sync the connection again.', noVendorsFound: 'No vendors found', noVendorsFoundDescription: 'Add vendors in NetSuite and sync the connection again.', noItemsFound: 'No invoice items found', diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx index 5c7e52bc03fe..3badf3e5d400 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx @@ -123,7 +123,7 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { headerTitle="workspace.sageIntacct.nonReimbursableExpenses.label" title="workspace.sageIntacct.nonReimbursableExpenses.description" titleStyle={[styles.ph5, styles.pb5]} - onBackButtonPressRoute={ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID)} + onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID))} accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]} featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} displayName={SageIntacctNonReimbursableExpensesPage.displayName} diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx index afa6afc90ee8..83e901c9433f 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx @@ -83,7 +83,7 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { headerTitle="workspace.sageIntacct.reimbursableExpenses.label" title="workspace.sageIntacct.reimbursableExpenses.description" titleStyle={[styles.ph5, styles.pb5]} - onBackButtonPressRoute={ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID)} + onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID))} accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]} featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} displayName={SageIntacctReimbursableExpensesPage.displayName} From 3068bc7e6c4e9d8e2c30ad24f7dfc0691abe37a3 Mon Sep 17 00:00:00 2001 From: war-in Date: Mon, 8 Jul 2024 09:28:21 +0200 Subject: [PATCH 44/50] address review comments --- src/languages/en.ts | 4 +--- src/languages/es.ts | 3 +-- src/libs/PolicyUtils.ts | 6 +++--- .../intacct/export/SageIntacctDefaultVendorPage.tsx | 2 +- ...geIntacctNonReimbursableCreditCardAccountPage.tsx | 12 ------------ 5 files changed, 6 insertions(+), 21 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 18ef73c1ec61..ecb5f03cd94d 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2249,12 +2249,10 @@ export default { }, }, creditCardAccount: 'Credit card account', - // TODO: verify if we need description - creditCardAccountDescription: 'We should have some description here, right?', defaultVendor: 'Default vendor', defaultVendorDescription: (isReimbursable: boolean): string => `Set a default vendor that will apply to ${isReimbursable ? '' : 'non-'}reimbursable expenses that don't have a matching vendor in Sage Intacct.`, - exportDescription: 'Configure how data in Expensify gets exported to Sage Inacct.', + exportDescription: 'Configure how data in Expensify gets exported to Sage Intacct.', exportPreferredExporterNote: 'The preferred exporter can be any workspace admin, but must also be a Domain Admin if you set different export accounts for individual company cards in Domain Settings.', exportPreferredExporterSubNote: 'Once set, the preferred exporter will see reports for export in their account.', diff --git a/src/languages/es.ts b/src/languages/es.ts index 33e4dc625244..c9ba918677cf 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2290,11 +2290,10 @@ export default { }, }, creditCardAccount: 'Cuenta de tarjeta de crédito', - creditCardAccountDescription: '!!!!!!!!', defaultVendor: 'Proveedor por defecto', defaultVendorDescription: (isReimbursable: boolean): string => `Establezca un proveedor predeterminado que se aplicará a los gastos ${isReimbursable ? '' : 'no '}reembolsables que no tienen un proveedor coincidente en Sage Intacct.`, - exportDescription: 'Configure cómo se exportan los datos de Expensify a Sage Inacct.', + exportDescription: 'Configure cómo se exportan los datos de Expensify a Sage Intacct.', exportPreferredExporterNote: 'El exportador preferido puede ser cualquier administrador del área de trabajo, pero también debe ser un administrador del dominio si establece diferentes cuentas de exportación para tarjetas de empresa individuales en Configuración del dominio.', exportPreferredExporterSubNote: 'Una vez configurado, el exportador preferido verá los informes para exportar en su cuenta.', diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 58527c541837..60d44830713e 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -575,11 +575,11 @@ function getIntegrationLastSuccessfulDate(connection?: Connections[keyof Connect return (connection as ConnectionWithLastSyncData)?.lastSync?.successfulDate; } -function getSageIntacctVendors(policy: Policy | undefined, selectedVendorId: string | null | undefined): SelectorType[] { +function getSageIntacctVendors(policy?: Policy, selectedVendorId?: string | null): SelectorType[] { const vendors = policy?.connections?.intacct?.data?.vendors ?? []; const isMatchFound = vendors?.some(({id}) => id === selectedVendorId); - return (vendors ?? []).map(({id, value}) => ({ + return vendors.map(({id, value}) => ({ value: id, text: value, keyForList: id, @@ -601,7 +601,7 @@ function getSageIntacctCreditCards(policy?: Policy, selectedAccount?: string): S const creditCards = policy?.connections?.intacct?.data?.creditCards ?? []; const isMatchFound = creditCards?.some(({name}) => name === selectedAccount); - return (creditCards ?? []).map(({name}) => ({ + return creditCards.map(({name}) => ({ value: name, text: name, keyForList: name, diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx index d32c8472f944..1e5a439d1475 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx @@ -47,7 +47,7 @@ function SageIntacctDefaultVendorPage({route}: SageIntacctDefaultVendorPageProps settingName = CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE_VENDOR; } - const vendorSelectorOptions = useMemo(() => getSageIntacctVendors(policy ?? undefined, defaultVendor), [defaultVendor, policy]); + const vendorSelectorOptions = useMemo(() => getSageIntacctVendors(policy, defaultVendor), [defaultVendor, policy]); const listHeaderComponent = useMemo( () => ( diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx index 1da1627189d5..5030ac039065 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx @@ -1,11 +1,9 @@ import React, {useCallback, useMemo} from 'react'; -import {View} from 'react-native'; import BlockingView from '@components/BlockingViews/BlockingView'; import * as Illustrations from '@components/Icon/Illustrations'; import RadioListItem from '@components/SelectionList/RadioListItem'; import type {SelectorType} from '@components/SelectionScreen'; import SelectionScreen from '@components/SelectionScreen'; -import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; @@ -27,15 +25,6 @@ function SageIntacctNonReimbursableCreditCardAccountPage({policy}: WithPolicyCon const creditCardSelectorOptions = useMemo(() => getSageIntacctCreditCards(policy, exportConfig?.nonReimbursableAccount), [exportConfig?.nonReimbursableAccount, policy]); - const listHeaderComponent = useMemo( - () => ( - - {translate('workspace.sageIntacct.creditCardAccountDescription')} - - ), - [translate, styles.pb2, styles.ph5, styles.pb5, styles.textNormal], - ); - const updateCreditCardAccount = useCallback( ({value}: SelectorType) => { if (value !== exportConfig?.nonReimbursableAccount) { @@ -69,7 +58,6 @@ function SageIntacctNonReimbursableCreditCardAccountPage({policy}: WithPolicyCon listItem={RadioListItem} onSelectRow={updateCreditCardAccount} initiallyFocusedOptionKey={creditCardSelectorOptions.find((mode) => mode.isSelected)?.keyForList} - headerContent={listHeaderComponent} onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID))} title="workspace.sageIntacct.creditCardAccount" listEmptyContent={listEmptyContent} From 126fd2da18063dfb070f55162be702fe0416d808 Mon Sep 17 00:00:00 2001 From: war-in Date: Tue, 9 Jul 2024 11:37:44 +0200 Subject: [PATCH 45/50] revert integrationName in translations --- src/languages/en.ts | 27 +++++++++++++------ src/languages/es.ts | 25 +++++++++++------ src/libs/Permissions.ts | 2 +- .../export/SageIntacctDefaultVendorPage.tsx | 4 +-- ...ctNonReimbursableCreditCardAccountPage.tsx | 4 +-- ...ExportExpensesPayableAccountSelectPage.tsx | 4 +-- ...eProvincialTaxPostingAccountSelectPage.tsx | 4 +-- .../NetSuiteReceivableAccountSelectPage.tsx | 4 +-- .../NetSuiteTaxPostingAccountSelectPage.tsx | 4 +-- .../advanced/QuickbooksAccountSelectPage.tsx | 4 +-- .../QuickbooksInvoiceAccountSelectPage.tsx | 4 +-- ...oksCompanyCardExpenseAccountSelectPage.tsx | 4 +-- ...ickbooksExportInvoiceAccountSelectPage.tsx | 4 +-- ...NonReimbursableDefaultVendorSelectPage.tsx | 4 +-- ...oksOutOfPocketExpenseAccountSelectPage.tsx | 4 +-- .../XeroBillPaymentAccountSelectorPage.tsx | 4 +-- .../XeroInvoiceAccountSelectorPage.tsx | 4 +-- .../xero/export/XeroBankAccountSelectPage.tsx | 4 +-- 18 files changed, 67 insertions(+), 47 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 2e4fcfcbd80a..e0e96c4f856b 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -127,10 +127,6 @@ type States = Record; type AllCountries = Record; -function integrationName(fallbackName: string, integration?: ConnectionName): string { - return integration && CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[integration] ? CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[integration] : fallbackName; -} - /* eslint-disable max-len */ export default { common: { @@ -2041,8 +2037,6 @@ export default { welcomeNote: ({workspaceName}: WelcomeNoteParams) => `You have been invited to ${workspaceName || 'a workspace'}! Download the Expensify mobile app at use.expensify.com/download to start tracking your expenses.`, subscription: 'Subscription', - noAccountsFound: 'No accounts found', - noAccountsFoundDescription: (integration: ConnectionName) => `Add the account in ${integrationName('this integration', integration)} and sync the connection again.`, }, qbo: { importDescription: 'Choose which coding configurations to import from QuickBooks Online to Expensify.', @@ -2144,6 +2138,8 @@ export default { [`${CONST.QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE.VENDOR_BILL}Error`]: 'Vendor bills are unavailable when locations are enabled. Please choose a different export option.', [`${CONST.QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE.CHECK}Error`]: 'Checks are unavailable when locations are enabled. Please choose a different export option.', [`${CONST.QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE.JOURNAL_ENTRY}Error`]: 'Journal entries are unavailable when taxes are enabled. Please choose a different export option.', + noAccountsFound: 'No accounts found', + noAccountsFoundDescription: 'Add the account in Quickbooks Online and sync the connection again.', }, }, xero: { @@ -2214,6 +2210,8 @@ export default { [CONST.XERO_CONFIG.INVOICE_STATUS.AWAITING_PAYMENT]: 'Awaiting payment', }, }, + noAccountsFound: 'No accounts found', + noAccountsFoundDescription: 'Add the account in Xero and sync the connection again.', }, sageIntacct: { preferredExporter: 'Preferred exporter', @@ -2261,6 +2259,8 @@ export default { exportPreferredExporterNote: 'The preferred exporter can be any workspace admin, but must also be a Domain Admin if you set different export accounts for individual company cards in Domain Settings.', exportPreferredExporterSubNote: 'Once set, the preferred exporter will see reports for export in their account.', + noAccountsFound: 'No accounts found', + noAccountsFoundDescription: `Add the account in Sage Intacct and sync the connection again.`, }, netsuite: { subsidiary: 'Subsidiary', @@ -2397,6 +2397,8 @@ export default { customFormID: 'Please enter a valid numeric custom form ID.', }, }, + noAccountsFound: 'No accounts found', + noAccountsFoundDescription: 'Add the account in NetSuite and sync the connection again.', noVendorsFound: 'No vendors found', noVendorsFoundDescription: 'Add vendors in NetSuite and sync the connection again.', noItemsFound: 'No invoice items found', @@ -2844,7 +2846,10 @@ export default { other: 'Other integrations', syncNow: 'Sync now', disconnect: 'Disconnect', - disconnectTitle: (integration?: ConnectionName): string => `Disconnect ${integrationName('integration', integration)}`, + disconnectTitle: (integration?: ConnectionName): string => { + const integrationName = integration && CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[integration] ? CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[integration] : 'integration'; + return `Disconnect ${integrationName}`; + }, connectTitle: (integrationToConnect: ConnectionName): string => `Connect ${CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[integrationToConnect] ?? 'accounting integration'}`, syncError: (integration?: ConnectionName): string => { @@ -2874,7 +2879,13 @@ export default { [CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]: 'Imported as report fields', [CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT]: 'NetSuite employee default', }, - disconnectPrompt: (currentIntegration?: ConnectionName): string => `Are you sure you want to disconnect ${integrationName('this integration', currentIntegration)}?`, + disconnectPrompt: (currentIntegration?: ConnectionName): string => { + const integrationName = + currentIntegration && CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[currentIntegration] + ? CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[currentIntegration] + : 'this integration'; + return `Are you sure you want to disconnect ${integrationName}?`; + }, connectPrompt: (integrationToConnect: ConnectionName): string => `Are you sure you want to connect ${ CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[integrationToConnect] ?? 'this accounting integration' diff --git a/src/languages/es.ts b/src/languages/es.ts index 36e825d56098..32221fb7c0c3 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -117,10 +117,6 @@ import type { ZipCodeExampleFormatParams, } from './types'; -function integrationName(fallbackName: string, integration?: ConnectionName): string { - return integration && CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[integration] ? CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[integration] : fallbackName; -} - /* eslint-disable max-len */ export default { common: { @@ -2072,8 +2068,6 @@ export default { welcomeNote: ({workspaceName}: WelcomeNoteParams) => `¡Has sido invitado a ${workspaceName}! Descargue la aplicación móvil Expensify en use.expensify.com/download para comenzar a rastrear sus gastos.`, subscription: 'Suscripción', - noAccountsFound: 'No se ha encontrado ninguna cuenta', - noAccountsFoundDescription: (integration: ConnectionName) => `Añade la cuenta en ${integrationName('esta integración', integration)} y sincroniza de nuevo la conexión.`, }, qbo: { importDescription: 'Elige que configuraciónes de codificación son importadas desde QuickBooks Online a Expensify.', @@ -2181,6 +2175,8 @@ export default { 'La verificación no está disponible cuando las ubicaciones están habilitadas. Por favor, selecciona otra opción de exportación diferente.', [`${CONST.QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE.JOURNAL_ENTRY}Error`]: 'El asiento de diario no está disponible cuando los impuestos están habilitados. Por favor, selecciona otra opción de exportación diferente.', + noAccountsFound: 'No se ha encontrado ninguna cuenta', + noAccountsFoundDescription: 'Añade la cuenta en Quickbooks Online y sincroniza de nuevo la conexión.', }, }, xero: { @@ -2254,6 +2250,8 @@ export default { [CONST.XERO_CONFIG.INVOICE_STATUS.AWAITING_PAYMENT]: 'Pendiente de pago', }, }, + noAccountsFound: 'No se ha encontrado ninguna cuenta', + noAccountsFoundDescription: 'Añade la cuenta en Xero y sincroniza de nuevo la conexión.', }, sageIntacct: { @@ -2302,6 +2300,8 @@ export default { exportPreferredExporterNote: 'El exportador preferido puede ser cualquier administrador del área de trabajo, pero también debe ser un administrador del dominio si establece diferentes cuentas de exportación para tarjetas de empresa individuales en Configuración del dominio.', exportPreferredExporterSubNote: 'Una vez configurado, el exportador preferido verá los informes para exportar en su cuenta.', + noAccountsFound: 'No se ha encontrado ninguna cuenta', + noAccountsFoundDescription: 'Añade la cuenta en Sage Intacct y sincroniza de nuevo la conexión.', }, netsuite: { subsidiary: 'Subsidiaria', @@ -2441,6 +2441,8 @@ export default { customFormID: 'Introduzca un ID numérico válido para el formulario personalizado.', }, }, + noAccountsFound: 'No se han encontrado cuentas', + noAccountsFoundDescription: 'Añade la cuenta en NetSuite y sincroniza la conexión de nuevo.', noVendorsFound: 'No se han encontrado proveedores', noVendorsFoundDescription: 'Añade proveedores en NetSuite y sincroniza la conexión de nuevo.', noItemsFound: 'No se han encontrado artículos de factura', @@ -2829,7 +2831,10 @@ export default { other: 'Otras integraciones', syncNow: 'Sincronizar ahora', disconnect: 'Desconectar', - disconnectTitle: (integration?: ConnectionName): string => `Desconectar ${integrationName('integración', integration)}`, + disconnectTitle: (integration?: ConnectionName): string => { + const integrationName = integration && CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[integration] ? CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[integration] : 'integración'; + return `Desconectar ${integrationName}`; + }, connectTitle: (integrationToConnect: ConnectionName): string => `Conectar ${CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[integrationToConnect] ?? 'accounting integration'}`, syncError: (integration?: ConnectionName): string => { switch (integration) { @@ -2858,7 +2863,11 @@ export default { [CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]: 'Importado como campos de informe', [CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT]: 'Predeterminado del empleado NetSuite', }, - disconnectPrompt: (currentIntegration?: ConnectionName): string => `¿Estás seguro de que quieres desconectar ${integrationName('integración', currentIntegration)}?`, + disconnectPrompt: (currentIntegration?: ConnectionName): string => { + const integrationName = + currentIntegration && CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[currentIntegration] ? CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[currentIntegration] : 'integración'; + return `¿Estás seguro de que quieres desconectar ${integrationName}?`; + }, connectPrompt: (integrationToConnect: ConnectionName): string => `¿Estás seguro de que quieres conectar a ${ CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[integrationToConnect] ?? 'esta integración contable' diff --git a/src/libs/Permissions.ts b/src/libs/Permissions.ts index faea5965fee4..4896441ba192 100644 --- a/src/libs/Permissions.ts +++ b/src/libs/Permissions.ts @@ -45,7 +45,7 @@ function canUseNetSuiteIntegration(betas: OnyxEntry): boolean { } function canUseSageIntacctIntegration(betas: OnyxEntry): boolean { - return !!betas?.includes(CONST.BETAS.INTACCT_ON_NEW_EXPENSIFY) || canUseAllBetas(betas); + return true; } function canUseReportFieldsFeature(betas: OnyxEntry): boolean { diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx index 1e5a439d1475..4782cfba9e97 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage.tsx @@ -74,8 +74,8 @@ function SageIntacctDefaultVendorPage({route}: SageIntacctDefaultVendorPageProps icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.common.noAccountsFound')} - subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT)} + title={translate('workspace.sageIntacct.noAccountsFound')} + subtitle={translate('workspace.sageIntacct.noAccountsFoundDescription')} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx index 5030ac039065..f22b653b26f9 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage.tsx @@ -41,8 +41,8 @@ function SageIntacctNonReimbursableCreditCardAccountPage({policy}: WithPolicyCon icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.common.noAccountsFound')} - subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT)} + title={translate('workspace.sageIntacct.noAccountsFound')} + subtitle={translate('workspace.sageIntacct.noAccountsFoundDescription')} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/netsuite/export/NetSuiteExportExpensesPayableAccountSelectPage.tsx b/src/pages/workspace/accounting/netsuite/export/NetSuiteExportExpensesPayableAccountSelectPage.tsx index 9de86a57f95c..c640e183bc99 100644 --- a/src/pages/workspace/accounting/netsuite/export/NetSuiteExportExpensesPayableAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/netsuite/export/NetSuiteExportExpensesPayableAccountSelectPage.tsx @@ -53,8 +53,8 @@ function NetSuiteExportExpensesPayableAccountSelectPage({policy}: WithPolicyConn icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.common.noAccountsFound')} - subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.NETSUITE)} + title={translate('workspace.netsuite.noAccountsFound')} + subtitle={translate('workspace.netsuite.noAccountsFoundDescription')} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/netsuite/export/NetSuiteProvincialTaxPostingAccountSelectPage.tsx b/src/pages/workspace/accounting/netsuite/export/NetSuiteProvincialTaxPostingAccountSelectPage.tsx index 92d20ce33164..d5a5ca8f73a1 100644 --- a/src/pages/workspace/accounting/netsuite/export/NetSuiteProvincialTaxPostingAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/netsuite/export/NetSuiteProvincialTaxPostingAccountSelectPage.tsx @@ -48,8 +48,8 @@ function NetSuiteProvincialTaxPostingAccountSelectPage({policy}: WithPolicyConne icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.common.noAccountsFound')} - subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.NETSUITE)} + title={translate('workspace.netsuite.noAccountsFound')} + subtitle={translate('workspace.netsuite.noAccountsFoundDescription')} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/netsuite/export/NetSuiteReceivableAccountSelectPage.tsx b/src/pages/workspace/accounting/netsuite/export/NetSuiteReceivableAccountSelectPage.tsx index 7141744a0069..3f5066d6cc71 100644 --- a/src/pages/workspace/accounting/netsuite/export/NetSuiteReceivableAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/netsuite/export/NetSuiteReceivableAccountSelectPage.tsx @@ -45,8 +45,8 @@ function NetSuiteReceivableAccountSelectPage({policy}: WithPolicyConnectionsProp icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.common.noAccountsFound')} - subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.NETSUITE)} + title={translate('workspace.netsuite.noAccountsFound')} + subtitle={translate('workspace.netsuite.noAccountsFoundDescription')} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/netsuite/export/NetSuiteTaxPostingAccountSelectPage.tsx b/src/pages/workspace/accounting/netsuite/export/NetSuiteTaxPostingAccountSelectPage.tsx index d369cffe12d5..c9f52b4994ae 100644 --- a/src/pages/workspace/accounting/netsuite/export/NetSuiteTaxPostingAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/netsuite/export/NetSuiteTaxPostingAccountSelectPage.tsx @@ -50,8 +50,8 @@ function NetSuiteTaxPostingAccountSelectPage({policy}: WithPolicyConnectionsProp icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.common.noAccountsFound')} - subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.NETSUITE)} + title={translate('workspace.netsuite.noAccountsFound')} + subtitle={translate('workspace.netsuite.noAccountsFoundDescription')} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx index 4d2c3a2e00b4..01f11e9f376f 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx @@ -67,8 +67,8 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyConnectionsProps) { icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.common.noAccountsFound')} - subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.QBO)} + title={translate('workspace.qbo.accounts.noAccountsFound')} + subtitle={translate('workspace.qbo.accounts.noAccountsFoundDescription')} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx index b4425751dc35..c255ff5f4ed7 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx @@ -68,8 +68,8 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyConnectionsProps icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.common.noAccountsFound')} - subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.QBO)} + title={translate('workspace.qbo.accounts.noAccountsFound')} + subtitle={translate('workspace.qbo.accounts.noAccountsFoundDescription')} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx index 6da3d4cdf934..135609e8da00 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx @@ -72,8 +72,8 @@ function QuickbooksCompanyCardExpenseAccountSelectPage({policy}: WithPolicyConne icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.common.noAccountsFound')} - subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.QBO)} + title={translate('workspace.qbo.accounts.noAccountsFound')} + subtitle={translate('workspace.qbo.accounts.noAccountsFoundDescription')} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx index a07fe1c6deb9..9b439880638e 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx @@ -57,8 +57,8 @@ function QuickbooksExportInvoiceAccountSelectPage({policy}: WithPolicyConnection icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.common.noAccountsFound')} - subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.QBO)} + title={translate('workspace.qbo.accounts.noAccountsFound')} + subtitle={translate('workspace.qbo.accounts.noAccountsFoundDescription')} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksNonReimbursableDefaultVendorSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksNonReimbursableDefaultVendorSelectPage.tsx index 2cdbc650b811..433f3a0bb51a 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksNonReimbursableDefaultVendorSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksNonReimbursableDefaultVendorSelectPage.tsx @@ -55,8 +55,8 @@ function QuickbooksNonReimbursableDefaultVendorSelectPage({policy}: WithPolicyCo icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.common.noAccountsFound')} - subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.QBO)} + title={translate('workspace.qbo.accounts.noAccountsFound')} + subtitle={translate('workspace.qbo.accounts.noAccountsFoundDescription')} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx index 12594947619b..33d3a89e1aa7 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx @@ -95,8 +95,8 @@ function QuickbooksOutOfPocketExpenseAccountSelectPage({policy}: WithPolicyConne icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.common.noAccountsFound')} - subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.QBO)} + title={translate('workspace.qbo.accounts.noAccountsFound')} + subtitle={translate('workspace.qbo.accounts.noAccountsFoundDescription')} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/xero/advanced/XeroBillPaymentAccountSelectorPage.tsx b/src/pages/workspace/accounting/xero/advanced/XeroBillPaymentAccountSelectorPage.tsx index 5b5bf3e92baa..05b7cf877d33 100644 --- a/src/pages/workspace/accounting/xero/advanced/XeroBillPaymentAccountSelectorPage.tsx +++ b/src/pages/workspace/accounting/xero/advanced/XeroBillPaymentAccountSelectorPage.tsx @@ -53,8 +53,8 @@ function XeroBillPaymentAccountSelectorPage({policy}: WithPolicyConnectionsProps icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.common.noAccountsFound')} - subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.XERO)} + title={translate('workspace.xero.noAccountsFound')} + subtitle={translate('workspace.xero.noAccountsFoundDescription')} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/xero/advanced/XeroInvoiceAccountSelectorPage.tsx b/src/pages/workspace/accounting/xero/advanced/XeroInvoiceAccountSelectorPage.tsx index c5ec54bc3859..49fac2e38a9b 100644 --- a/src/pages/workspace/accounting/xero/advanced/XeroInvoiceAccountSelectorPage.tsx +++ b/src/pages/workspace/accounting/xero/advanced/XeroInvoiceAccountSelectorPage.tsx @@ -53,8 +53,8 @@ function XeroInvoiceAccountSelectorPage({policy}: WithPolicyConnectionsProps) { icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.common.noAccountsFound')} - subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.XERO)} + title={translate('workspace.xero.noAccountsFound')} + subtitle={translate('workspace.xero.noAccountsFoundDescription')} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/xero/export/XeroBankAccountSelectPage.tsx b/src/pages/workspace/accounting/xero/export/XeroBankAccountSelectPage.tsx index ff2a484205a5..76a6c9cabed1 100644 --- a/src/pages/workspace/accounting/xero/export/XeroBankAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/xero/export/XeroBankAccountSelectPage.tsx @@ -55,8 +55,8 @@ function XeroBankAccountSelectPage({policy}: WithPolicyConnectionsProps) { icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.common.noAccountsFound')} - subtitle={translate('workspace.common.noAccountsFoundDescription', CONST.POLICY.CONNECTIONS.NAME.XERO)} + title={translate('workspace.xero.noAccountsFound')} + subtitle={translate('workspace.xero.noAccountsFoundDescription')} containerStyle={styles.pb10} /> ), From 473139ac69182e3caac458edb6a2ff7a88d3161d Mon Sep 17 00:00:00 2001 From: war-in Date: Tue, 9 Jul 2024 11:43:09 +0200 Subject: [PATCH 46/50] revert integrationName in translations pt. 2 --- src/languages/en.ts | 4 ++-- src/languages/es.ts | 4 ++-- .../accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx | 4 ++-- .../qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx | 4 ++-- .../export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx | 4 ++-- .../qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx | 4 ++-- .../QuickbooksNonReimbursableDefaultVendorSelectPage.tsx | 4 ++-- .../export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index e0e96c4f856b..6e75212a7347 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2138,9 +2138,9 @@ export default { [`${CONST.QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE.VENDOR_BILL}Error`]: 'Vendor bills are unavailable when locations are enabled. Please choose a different export option.', [`${CONST.QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE.CHECK}Error`]: 'Checks are unavailable when locations are enabled. Please choose a different export option.', [`${CONST.QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE.JOURNAL_ENTRY}Error`]: 'Journal entries are unavailable when taxes are enabled. Please choose a different export option.', - noAccountsFound: 'No accounts found', - noAccountsFoundDescription: 'Add the account in Quickbooks Online and sync the connection again.', }, + noAccountsFound: 'No accounts found', + noAccountsFoundDescription: 'Add the account in Quickbooks Online and sync the connection again.', }, xero: { organization: 'Xero organization', diff --git a/src/languages/es.ts b/src/languages/es.ts index 32221fb7c0c3..9d395077c1bf 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2175,9 +2175,9 @@ export default { 'La verificación no está disponible cuando las ubicaciones están habilitadas. Por favor, selecciona otra opción de exportación diferente.', [`${CONST.QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE.JOURNAL_ENTRY}Error`]: 'El asiento de diario no está disponible cuando los impuestos están habilitados. Por favor, selecciona otra opción de exportación diferente.', - noAccountsFound: 'No se ha encontrado ninguna cuenta', - noAccountsFoundDescription: 'Añade la cuenta en Quickbooks Online y sincroniza de nuevo la conexión.', }, + noAccountsFound: 'No se ha encontrado ninguna cuenta', + noAccountsFoundDescription: 'Añade la cuenta en Quickbooks Online y sincroniza de nuevo la conexión.', }, xero: { organization: 'Organización Xero', diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx index 01f11e9f376f..a02c0b76809f 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx @@ -67,8 +67,8 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyConnectionsProps) { icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.qbo.accounts.noAccountsFound')} - subtitle={translate('workspace.qbo.accounts.noAccountsFoundDescription')} + title={translate('workspace.qbo.noAccountsFound')} + subtitle={translate('workspace.qbo.noAccountsFoundDescription')} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx index c255ff5f4ed7..0459f61b88d6 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx @@ -68,8 +68,8 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyConnectionsProps icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.qbo.accounts.noAccountsFound')} - subtitle={translate('workspace.qbo.accounts.noAccountsFoundDescription')} + title={translate('workspace.qbo.noAccountsFound')} + subtitle={translate('workspace.qbo.noAccountsFoundDescription')} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx index 135609e8da00..3c44888d782d 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx @@ -72,8 +72,8 @@ function QuickbooksCompanyCardExpenseAccountSelectPage({policy}: WithPolicyConne icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.qbo.accounts.noAccountsFound')} - subtitle={translate('workspace.qbo.accounts.noAccountsFoundDescription')} + title={translate('workspace.qbo.noAccountsFound')} + subtitle={translate('workspace.qbo.noAccountsFoundDescription')} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx index 9b439880638e..b95e70fe11dd 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx @@ -57,8 +57,8 @@ function QuickbooksExportInvoiceAccountSelectPage({policy}: WithPolicyConnection icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.qbo.accounts.noAccountsFound')} - subtitle={translate('workspace.qbo.accounts.noAccountsFoundDescription')} + title={translate('workspace.qbo.noAccountsFound')} + subtitle={translate('workspace.qbo.noAccountsFoundDescription')} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksNonReimbursableDefaultVendorSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksNonReimbursableDefaultVendorSelectPage.tsx index 433f3a0bb51a..3c9e7c085578 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksNonReimbursableDefaultVendorSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksNonReimbursableDefaultVendorSelectPage.tsx @@ -55,8 +55,8 @@ function QuickbooksNonReimbursableDefaultVendorSelectPage({policy}: WithPolicyCo icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.qbo.accounts.noAccountsFound')} - subtitle={translate('workspace.qbo.accounts.noAccountsFoundDescription')} + title={translate('workspace.qbo.noAccountsFound')} + subtitle={translate('workspace.qbo.noAccountsFoundDescription')} containerStyle={styles.pb10} /> ), diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx index 33d3a89e1aa7..50b44640642b 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx @@ -95,8 +95,8 @@ function QuickbooksOutOfPocketExpenseAccountSelectPage({policy}: WithPolicyConne icon={Illustrations.TeleScope} iconWidth={variables.emptyListIconWidth} iconHeight={variables.emptyListIconHeight} - title={translate('workspace.qbo.accounts.noAccountsFound')} - subtitle={translate('workspace.qbo.accounts.noAccountsFoundDescription')} + title={translate('workspace.qbo.noAccountsFound')} + subtitle={translate('workspace.qbo.noAccountsFoundDescription')} containerStyle={styles.pb10} /> ), From 97a6da715780bb668f5440e26be93c4fa25da32f Mon Sep 17 00:00:00 2001 From: war-in Date: Tue, 9 Jul 2024 11:47:17 +0200 Subject: [PATCH 47/50] revert permission --- src/libs/Permissions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/Permissions.ts b/src/libs/Permissions.ts index 4896441ba192..faea5965fee4 100644 --- a/src/libs/Permissions.ts +++ b/src/libs/Permissions.ts @@ -45,7 +45,7 @@ function canUseNetSuiteIntegration(betas: OnyxEntry): boolean { } function canUseSageIntacctIntegration(betas: OnyxEntry): boolean { - return true; + return !!betas?.includes(CONST.BETAS.INTACCT_ON_NEW_EXPENSIFY) || canUseAllBetas(betas); } function canUseReportFieldsFeature(betas: OnyxEntry): boolean { From 4f62db53c27aeed10292fd01df35927bac591b5c Mon Sep 17 00:00:00 2001 From: war-in Date: Tue, 9 Jul 2024 15:36:54 +0200 Subject: [PATCH 48/50] polish endpoints usages --- ...editCardChargeExportDefaultVendorParams.ts | 2 +- ...reimbursableExpensesExportAccountParams.ts | 2 +- ...nreimbursableExpensesExportVendorParams.ts | 2 +- ...ExpensesReportExportDefaultVendorParams.ts | 2 +- src/libs/PolicyUtils.ts | 7 +-- src/libs/actions/connections/SageIntacct.ts | 10 +-- ...SageIntacctNonReimbursableExpensesPage.tsx | 10 +-- .../SageIntacctReimbursableExpensesPage.tsx | 62 +++++++++++-------- src/types/onyx/Policy.ts | 6 +- 9 files changed, 56 insertions(+), 47 deletions(-) diff --git a/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams.ts b/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams.ts index 09e2ad2dfc41..76ff4820fc3b 100644 --- a/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams.ts +++ b/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams.ts @@ -1,6 +1,6 @@ type UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams = { policyID: string; - vendorID: string | null; + vendorID: string; }; export default UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams; diff --git a/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportAccountParams.ts b/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportAccountParams.ts index 316308cbf67c..2a260ad267b3 100644 --- a/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportAccountParams.ts +++ b/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportAccountParams.ts @@ -1,6 +1,6 @@ type UpdateSageIntacctNonreimbursableExpensesExportAccountParams = { policyID: string; - bankAccountID: string; + creditCardAccountID: string; }; export default UpdateSageIntacctNonreimbursableExpensesExportAccountParams; diff --git a/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportVendorParams.ts b/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportVendorParams.ts index de2fc8c2f574..97ae85a26a2c 100644 --- a/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportVendorParams.ts +++ b/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportVendorParams.ts @@ -1,6 +1,6 @@ type UpdateSageIntacctNonreimbursableExpensesExportVendorParams = { policyID: string; - vendorID: string | null; + vendorID: string; }; export default UpdateSageIntacctNonreimbursableExpensesExportVendorParams; diff --git a/src/libs/API/parameters/UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams.ts b/src/libs/API/parameters/UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams.ts index 64d9c312a4b5..c4973515d561 100644 --- a/src/libs/API/parameters/UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams.ts +++ b/src/libs/API/parameters/UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams.ts @@ -1,6 +1,6 @@ type UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams = { policyID: string; - vendorID: string | null; + vendorID: string; }; export default UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams; diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index d5570eb7c478..9f8f2dc9690f 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -617,19 +617,18 @@ function getIntegrationLastSuccessfulDate(connection?: Connections[keyof Connect return (connection as ConnectionWithLastSyncData)?.lastSync?.successfulDate; } -function getSageIntacctVendors(policy?: Policy, selectedVendorId?: string | null): SelectorType[] { +function getSageIntacctVendors(policy?: Policy, selectedVendorId?: string): SelectorType[] { const vendors = policy?.connections?.intacct?.data?.vendors ?? []; - const isMatchFound = vendors?.some(({id}) => id === selectedVendorId); return vendors.map(({id, value}) => ({ value: id, text: value, keyForList: id, - isSelected: isMatchFound && selectedVendorId === id, + isSelected: selectedVendorId === id, })); } -function getSageIntacctNonReimbursableActiveDefaultVendor(policy?: Policy): string | null | undefined { +function getSageIntacctNonReimbursableActiveDefaultVendor(policy?: Policy): string | undefined { const { nonReimbursableCreditCardChargeDefaultVendor: creditCardDefaultVendor, nonReimbursableVendor: expenseReportDefaultVendor, diff --git a/src/libs/actions/connections/SageIntacct.ts b/src/libs/actions/connections/SageIntacct.ts index ce3cfdc69ec9..383323e356d1 100644 --- a/src/libs/actions/connections/SageIntacct.ts +++ b/src/libs/actions/connections/SageIntacct.ts @@ -147,7 +147,7 @@ function updateSageIntacctNonreimbursableExpensesExportDestination(policyID: str API.write(WRITE_COMMANDS.UPDATE_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES_EXPORT_DESTINATION, parameters, {optimisticData, failureData, successData}); } -function updateSageIntacctReimbursableExpensesReportExportDefaultVendor(policyID: string, vendor: string | null) { +function updateSageIntacctReimbursableExpensesReportExportDefaultVendor(policyID: string, vendor: string) { const {optimisticData, failureData, successData} = prepareOnyxDataForExportUpdate(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE_VENDOR, vendor); const parameters: UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams = { policyID, @@ -157,7 +157,7 @@ function updateSageIntacctReimbursableExpensesReportExportDefaultVendor(policyID API.write(WRITE_COMMANDS.UPDATE_SAGE_INTACCT_REIMBURSABLE_EXPENSES_REPORT_EXPORT_DEFAULT_VENDOR, parameters, {optimisticData, failureData, successData}); } -function updateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendor(policyID: string, vendor: string | null) { +function updateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendor(policyID: string, vendor: string) { const {optimisticData, failureData, successData} = prepareOnyxDataForExportUpdate(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_CREDIT_CARD_VENDOR, vendor); const parameters: UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams = { policyID, @@ -171,13 +171,13 @@ function updateSageIntacctNonreimbursableExpensesExportAccount(policyID: string, const {optimisticData, failureData, successData} = prepareOnyxDataForExportUpdate(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_ACCOUNT, nonReimbursableAccount); const parameters: UpdateSageIntacctNonreimbursableExpensesExportAccountParams = { policyID, - bankAccountID: nonReimbursableAccount, + creditCardAccountID: nonReimbursableAccount, }; API.write(WRITE_COMMANDS.UPDATE_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES_EXPORT_ACCOUNT, parameters, {optimisticData, failureData, successData}); } -function updateSageIntacctNonreimbursableExpensesExportVendor(policyID: string, vendor: string | null) { +function updateSageIntacctNonreimbursableExpensesExportVendor(policyID: string, vendor: string) { const {optimisticData, failureData, successData} = prepareOnyxDataForExportUpdate(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_VENDOR, vendor); const parameters: UpdateSageIntacctNonreimbursableExpensesExportVendorParams = { policyID, @@ -187,7 +187,7 @@ function updateSageIntacctNonreimbursableExpensesExportVendor(policyID: string, API.write(WRITE_COMMANDS.UPDATE_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES_EXPORT_VENDOR, parameters, {optimisticData, failureData, successData}); } -function updateSageIntacctDefaultVendor(policyID: string, settingName: keyof Connections['intacct']['config']['export'], vendor: string | null) { +function updateSageIntacctDefaultVendor(policyID: string, settingName: keyof Connections['intacct']['config']['export'], vendor: string) { if (settingName === CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE_VENDOR) { updateSageIntacctReimbursableExpensesReportExportDefaultVendor(policyID, vendor); } else if (settingName === CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_CREDIT_CARD_VENDOR) { diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx index 3badf3e5d400..ba977cbba238 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableExpensesPage.tsx @@ -24,8 +24,8 @@ type MenuListItem = ListItem & { value: ValueOf; }; -function getDefaultVendorName(defaultVendor: string, vendors: SageIntacctDataElementWithValue[]): string { - return vendors.find((vendor) => vendor.id === defaultVendor)?.value ?? defaultVendor; +function getDefaultVendorName(defaultVendor?: string, vendors?: SageIntacctDataElementWithValue[]): string | undefined { + return (vendors ?? []).find((vendor) => vendor.id === defaultVendor)?.value ?? defaultVendor; } function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { @@ -53,10 +53,12 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { const defaultVendor = useMemo(() => { const activeDefaultVendor = getSageIntacctNonReimbursableActiveDefaultVendor(policy); + const defaultVendorName = getDefaultVendorName(activeDefaultVendor, intacctData?.vendors); + const defaultVendorSection = { description: translate('workspace.sageIntacct.defaultVendor'), action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_DEFAULT_VENDOR.getRoute(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE.toLowerCase())), - title: activeDefaultVendor ? getDefaultVendorName(activeDefaultVendor, intacctData?.vendors ?? []) : translate('workspace.sageIntacct.notConfigured'), + title: defaultVendorName && defaultVendorName !== '' ? defaultVendorName : translate('workspace.sageIntacct.notConfigured'), hasError: config?.export.nonReimbursable === CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL ? !!config?.export?.errorFields?.nonReimbursableVendor @@ -151,7 +153,7 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) { switchAccessibilityLabel={translate('workspace.sageIntacct.defaultVendor')} isActive={!!config?.export.nonReimbursableCreditCardChargeDefaultVendor} onToggle={(enabled) => { - const vendor = enabled ? policy?.connections?.intacct?.data?.vendors?.[0].id ?? null : null; + const vendor = enabled ? policy?.connections?.intacct?.data?.vendors?.[0].id ?? '' : ''; updateSageIntacctDefaultVendor(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_CREDIT_CARD_VENDOR, vendor); }} wrapperStyle={[styles.ph5, styles.pv3]} diff --git a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx index 83e901c9433f..b3a4a04a5582 100644 --- a/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx +++ b/src/pages/workspace/accounting/intacct/export/SageIntacctReimbursableExpensesPage.tsx @@ -1,4 +1,4 @@ -import React, {useCallback} from 'react'; +import React, {useCallback, useMemo} from 'react'; import {View} from 'react-native'; import type {ValueOf} from 'type-fest'; import ConnectionLayout from '@components/ConnectionLayout'; @@ -23,8 +23,8 @@ type MenuListItem = ListItem & { value: ValueOf; }; -function getDefaultVendorName(defaultVendor: string, vendors: SageIntacctDataElementWithValue[]): string { - return vendors.find((vendor) => vendor.id === defaultVendor)?.value ?? defaultVendor; +function getDefaultVendorName(defaultVendor?: string, vendors?: SageIntacctDataElementWithValue[]): string | undefined { + return (vendors ?? []).find((vendor) => vendor.id === defaultVendor)?.value ?? defaultVendor; } function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { @@ -53,30 +53,38 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) { [reimbursable, policyID], ); - const defaultVendorSection = { - description: translate('workspace.sageIntacct.defaultVendor'), - action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_DEFAULT_VENDOR.getRoute(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE)), - title: reimbursableExpenseReportDefaultVendor - ? getDefaultVendorName(reimbursableExpenseReportDefaultVendor, intacctData?.vendors ?? []) - : translate('workspace.sageIntacct.notConfigured'), - hasError: !!config?.export?.errorFields?.reimbursableExpenseReportDefaultVendor, - pendingAction: config?.export?.pendingFields?.reimbursableExpenseReportDefaultVendor, - }; + const defaultVendor = useMemo(() => { + const defaultVendorName = getDefaultVendorName(reimbursableExpenseReportDefaultVendor, intacctData?.vendors); + const defaultVendorSection = { + description: translate('workspace.sageIntacct.defaultVendor'), + action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_DEFAULT_VENDOR.getRoute(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE)), + title: defaultVendorName && defaultVendorName !== '' ? defaultVendorName : translate('workspace.sageIntacct.notConfigured'), + hasError: !!config?.export?.errorFields?.reimbursableExpenseReportDefaultVendor, + pendingAction: config?.export?.pendingFields?.reimbursableExpenseReportDefaultVendor, + }; - const defaultVendor = ( - - - - ); + return ( + + + + ); + }, [ + config?.export?.errorFields?.reimbursableExpenseReportDefaultVendor, + config?.export?.pendingFields?.reimbursableExpenseReportDefaultVendor, + intacctData?.vendors, + policyID, + reimbursableExpenseReportDefaultVendor, + translate, + ]); return ( { - const vendor = enabled ? policy?.connections?.intacct?.data?.vendors?.[0].id ?? null : null; + const vendor = enabled ? policy?.connections?.intacct?.data?.vendors?.[0].id ?? '' : ''; updateSageIntacctDefaultVendor(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE_VENDOR, vendor); }} wrapperStyle={[styles.ph5, styles.pv3]} diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index d89155f430e4..8e9cfe97a43d 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -1015,16 +1015,16 @@ type SageIntacctConnectiosConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ nonReimbursableAccount: string; /** Default vendor used for credit card transactions of non-reimbursable bill */ - nonReimbursableCreditCardChargeDefaultVendor: string | null; + nonReimbursableCreditCardChargeDefaultVendor: string; /** Default vendor of non-reimbursable bill */ - nonReimbursableVendor: string | null; + nonReimbursableVendor: string; /** Defines how reimbursable expenses are exported */ reimbursable: ValueOf; /** Default vendor of reimbursable bill */ - reimbursableExpenseReportDefaultVendor: string | null; + reimbursableExpenseReportDefaultVendor: string; /** Collection of mapping field errors, which will be triggered when update action fails */ errorFields?: OnyxCommon.ErrorFields; From c179052e5b4194eeb47805f134f4b732b1468d00 Mon Sep 17 00:00:00 2001 From: war-in Date: Tue, 9 Jul 2024 16:36:31 +0200 Subject: [PATCH 49/50] fix comments --- src/libs/PolicyUtils.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 9f8f2dc9690f..a70c254396e6 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -619,7 +619,6 @@ function getIntegrationLastSuccessfulDate(connection?: Connections[keyof Connect function getSageIntacctVendors(policy?: Policy, selectedVendorId?: string): SelectorType[] { const vendors = policy?.connections?.intacct?.data?.vendors ?? []; - return vendors.map(({id, value}) => ({ value: id, text: value, @@ -640,13 +639,11 @@ function getSageIntacctNonReimbursableActiveDefaultVendor(policy?: Policy): stri function getSageIntacctCreditCards(policy?: Policy, selectedAccount?: string): SelectorType[] { const creditCards = policy?.connections?.intacct?.data?.creditCards ?? []; - const isMatchFound = creditCards?.some(({name}) => name === selectedAccount); - return creditCards.map(({name}) => ({ value: name, text: name, keyForList: name, - isSelected: isMatchFound && name === selectedAccount, + isSelected: name === selectedAccount, })); } From 796129682b0c0d660732f484479472c1d26302eb Mon Sep 17 00:00:00 2001 From: war-in Date: Tue, 9 Jul 2024 17:05:54 +0200 Subject: [PATCH 50/50] use generic type params pattern --- .../UpdateSageIntacctExportDateParams.ts | 6 ----- .../UpdateSageIntacctExporterParams.ts | 6 ----- .../UpdateSageIntacctGenericTypeParams.ts | 7 +++++ ...editCardChargeExportDefaultVendorParams.ts | 6 ----- ...reimbursableExpensesExportAccountParams.ts | 6 ----- ...bursableExpensesExportDestinationParams.ts | 6 ----- ...nreimbursableExpensesExportVendorParams.ts | 6 ----- ...bursableExpensesExportDestinationParams.ts | 6 ----- ...ExpensesReportExportDefaultVendorParams.ts | 6 ----- src/libs/API/parameters/index.ts | 9 +------ src/libs/API/types.ts | 16 ++++++------ src/libs/actions/connections/SageIntacct.ts | 26 ++++++------------- 12 files changed, 24 insertions(+), 82 deletions(-) delete mode 100644 src/libs/API/parameters/UpdateSageIntacctExportDateParams.ts delete mode 100644 src/libs/API/parameters/UpdateSageIntacctExporterParams.ts create mode 100644 src/libs/API/parameters/UpdateSageIntacctGenericTypeParams.ts delete mode 100644 src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams.ts delete mode 100644 src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportAccountParams.ts delete mode 100644 src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportDestinationParams.ts delete mode 100644 src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportVendorParams.ts delete mode 100644 src/libs/API/parameters/UpdateSageIntacctReimbursableExpensesExportDestinationParams.ts delete mode 100644 src/libs/API/parameters/UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams.ts diff --git a/src/libs/API/parameters/UpdateSageIntacctExportDateParams.ts b/src/libs/API/parameters/UpdateSageIntacctExportDateParams.ts deleted file mode 100644 index acae666bbb1f..000000000000 --- a/src/libs/API/parameters/UpdateSageIntacctExportDateParams.ts +++ /dev/null @@ -1,6 +0,0 @@ -type UpdateSageIntacctExportDateParams = { - policyID: string; - value: string; -}; - -export default UpdateSageIntacctExportDateParams; diff --git a/src/libs/API/parameters/UpdateSageIntacctExporterParams.ts b/src/libs/API/parameters/UpdateSageIntacctExporterParams.ts deleted file mode 100644 index 152b124eb9bd..000000000000 --- a/src/libs/API/parameters/UpdateSageIntacctExporterParams.ts +++ /dev/null @@ -1,6 +0,0 @@ -type UpdateSageIntacctExporterParams = { - policyID: string; - email: string; -}; - -export default UpdateSageIntacctExporterParams; diff --git a/src/libs/API/parameters/UpdateSageIntacctGenericTypeParams.ts b/src/libs/API/parameters/UpdateSageIntacctGenericTypeParams.ts new file mode 100644 index 000000000000..509a06cadb2c --- /dev/null +++ b/src/libs/API/parameters/UpdateSageIntacctGenericTypeParams.ts @@ -0,0 +1,7 @@ +type UpdateSageIntacctGenericTypeParams = { + [K2 in K]: Type; +} & { + policyID: string; +}; + +export default UpdateSageIntacctGenericTypeParams; diff --git a/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams.ts b/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams.ts deleted file mode 100644 index 76ff4820fc3b..000000000000 --- a/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams.ts +++ /dev/null @@ -1,6 +0,0 @@ -type UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams = { - policyID: string; - vendorID: string; -}; - -export default UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams; diff --git a/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportAccountParams.ts b/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportAccountParams.ts deleted file mode 100644 index 2a260ad267b3..000000000000 --- a/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportAccountParams.ts +++ /dev/null @@ -1,6 +0,0 @@ -type UpdateSageIntacctNonreimbursableExpensesExportAccountParams = { - policyID: string; - creditCardAccountID: string; -}; - -export default UpdateSageIntacctNonreimbursableExpensesExportAccountParams; diff --git a/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportDestinationParams.ts b/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportDestinationParams.ts deleted file mode 100644 index 1229afb776ec..000000000000 --- a/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportDestinationParams.ts +++ /dev/null @@ -1,6 +0,0 @@ -type UpdateSageIntacctNonreimbursableExpensesExportDestinationParams = { - policyID: string; - value: string; -}; - -export default UpdateSageIntacctNonreimbursableExpensesExportDestinationParams; diff --git a/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportVendorParams.ts b/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportVendorParams.ts deleted file mode 100644 index 97ae85a26a2c..000000000000 --- a/src/libs/API/parameters/UpdateSageIntacctNonreimbursableExpensesExportVendorParams.ts +++ /dev/null @@ -1,6 +0,0 @@ -type UpdateSageIntacctNonreimbursableExpensesExportVendorParams = { - policyID: string; - vendorID: string; -}; - -export default UpdateSageIntacctNonreimbursableExpensesExportVendorParams; diff --git a/src/libs/API/parameters/UpdateSageIntacctReimbursableExpensesExportDestinationParams.ts b/src/libs/API/parameters/UpdateSageIntacctReimbursableExpensesExportDestinationParams.ts deleted file mode 100644 index a31bfeb962f4..000000000000 --- a/src/libs/API/parameters/UpdateSageIntacctReimbursableExpensesExportDestinationParams.ts +++ /dev/null @@ -1,6 +0,0 @@ -type UpdateSageIntacctReimbursableExpensesExportDestinationParams = { - policyID: string; - value: string; -}; - -export default UpdateSageIntacctReimbursableExpensesExportDestinationParams; diff --git a/src/libs/API/parameters/UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams.ts b/src/libs/API/parameters/UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams.ts deleted file mode 100644 index c4973515d561..000000000000 --- a/src/libs/API/parameters/UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams.ts +++ /dev/null @@ -1,6 +0,0 @@ -type UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams = { - policyID: string; - vendorID: string; -}; - -export default UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index 903d47a9a134..c2b6b90a4fc4 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -249,11 +249,4 @@ export type {default as OpenPolicyExpensifyCardsPageParams} from './OpenPolicyEx export type {default as RequestExpensifyCardLimitIncreaseParams} from './RequestExpensifyCardLimitIncreaseParams'; export type {default as UpdateNetSuiteGenericTypeParams} from './UpdateNetSuiteGenericTypeParams'; export type {default as UpdateNetSuiteCustomFormIDParams} from './UpdateNetSuiteCustomFormIDParams'; -export type {default as UpdateSageIntacctExporterParams} from './UpdateSageIntacctExporterParams'; -export type {default as UpdateSageIntacctExportDateParams} from './UpdateSageIntacctExportDateParams'; -export type {default as UpdateSageIntacctReimbursableExpensesExportDestinationParams} from './UpdateSageIntacctReimbursableExpensesExportDestinationParams'; -export type {default as UpdateSageIntacctNonreimbursableExpensesExportDestinationParams} from './UpdateSageIntacctNonreimbursableExpensesExportDestinationParams'; -export type {default as UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams} from './UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams'; -export type {default as UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams} from './UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams'; -export type {default as UpdateSageIntacctNonreimbursableExpensesExportAccountParams} from './UpdateSageIntacctNonreimbursableExpensesExportAccountParams'; -export type {default as UpdateSageIntacctNonreimbursableExpensesExportVendorParams} from './UpdateSageIntacctNonreimbursableExpensesExportVendorParams'; +export type {default as UpdateSageIntacctGenericTypeParams} from './UpdateSageIntacctGenericTypeParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index c8d20261b608..b83814d82a7e 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -525,14 +525,14 @@ type WriteCommandParameters = { [WRITE_COMMANDS.REQUEST_REFUND]: null; [WRITE_COMMANDS.CONNECT_POLICY_TO_SAGE_INTACCT]: Parameters.ConnectPolicyToSageIntacctParams; - [WRITE_COMMANDS.UPDATE_SAGE_INTACCT_EXPORTER]: Parameters.UpdateSageIntacctExporterParams; - [WRITE_COMMANDS.UPDATE_SAGE_INTACCT_EXPORT_DATE]: Parameters.UpdateSageIntacctExportDateParams; - [WRITE_COMMANDS.UPDATE_SAGE_INTACCT_REIMBURSABLE_EXPENSES_EXPORT_DESTINATION]: Parameters.UpdateSageIntacctReimbursableExpensesExportDestinationParams; - [WRITE_COMMANDS.UPDATE_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES_EXPORT_DESTINATION]: Parameters.UpdateSageIntacctNonreimbursableExpensesExportDestinationParams; - [WRITE_COMMANDS.UPDATE_SAGE_INTACCT_REIMBURSABLE_EXPENSES_REPORT_EXPORT_DEFAULT_VENDOR]: Parameters.UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams; - [WRITE_COMMANDS.UPDATE_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES_CREDIT_CARD_CHARGE_EXPORT_DEFAULT_VENDOR]: Parameters.UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams; - [WRITE_COMMANDS.UPDATE_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES_EXPORT_ACCOUNT]: Parameters.UpdateSageIntacctNonreimbursableExpensesExportAccountParams; - [WRITE_COMMANDS.UPDATE_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES_EXPORT_VENDOR]: Parameters.UpdateSageIntacctNonreimbursableExpensesExportVendorParams; + [WRITE_COMMANDS.UPDATE_SAGE_INTACCT_EXPORTER]: Parameters.UpdateSageIntacctGenericTypeParams<'email', string>; + [WRITE_COMMANDS.UPDATE_SAGE_INTACCT_EXPORT_DATE]: Parameters.UpdateSageIntacctGenericTypeParams<'value', string>; + [WRITE_COMMANDS.UPDATE_SAGE_INTACCT_REIMBURSABLE_EXPENSES_EXPORT_DESTINATION]: Parameters.UpdateSageIntacctGenericTypeParams<'value', string>; + [WRITE_COMMANDS.UPDATE_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES_EXPORT_DESTINATION]: Parameters.UpdateSageIntacctGenericTypeParams<'value', string>; + [WRITE_COMMANDS.UPDATE_SAGE_INTACCT_REIMBURSABLE_EXPENSES_REPORT_EXPORT_DEFAULT_VENDOR]: Parameters.UpdateSageIntacctGenericTypeParams<'vendorID', string>; + [WRITE_COMMANDS.UPDATE_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES_CREDIT_CARD_CHARGE_EXPORT_DEFAULT_VENDOR]: Parameters.UpdateSageIntacctGenericTypeParams<'vendorID', string>; + [WRITE_COMMANDS.UPDATE_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES_EXPORT_ACCOUNT]: Parameters.UpdateSageIntacctGenericTypeParams<'creditCardAccountID', string>; + [WRITE_COMMANDS.UPDATE_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES_EXPORT_VENDOR]: Parameters.UpdateSageIntacctGenericTypeParams<'vendorID', string>; [WRITE_COMMANDS.UPGRADE_TO_CORPORATE]: Parameters.UpgradeToCorporateParams; // Netsuite parameters diff --git a/src/libs/actions/connections/SageIntacct.ts b/src/libs/actions/connections/SageIntacct.ts index 383323e356d1..3dcb9726d0b9 100644 --- a/src/libs/actions/connections/SageIntacct.ts +++ b/src/libs/actions/connections/SageIntacct.ts @@ -2,16 +2,6 @@ import type {OnyxUpdate} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; import * as API from '@libs/API'; -import type { - UpdateSageIntacctExportDateParams, - UpdateSageIntacctExporterParams, - UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams, - UpdateSageIntacctNonreimbursableExpensesExportAccountParams, - UpdateSageIntacctNonreimbursableExpensesExportDestinationParams, - UpdateSageIntacctNonreimbursableExpensesExportVendorParams, - UpdateSageIntacctReimbursableExpensesExportDestinationParams, - UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams, -} from '@libs/API/parameters'; import type ConnectPolicyToSageIntacctParams from '@libs/API/parameters/ConnectPolicyToSageIntacctParams'; import {WRITE_COMMANDS} from '@libs/API/types'; import * as ErrorUtils from '@libs/ErrorUtils'; @@ -109,7 +99,7 @@ function prepareOnyxDataForExportUpdate(policyID: string, settingName: keyof Con function updateSageIntacctExporter(policyID: string, exporter: string) { const {optimisticData, failureData, successData} = prepareOnyxDataForExportUpdate(policyID, CONST.SAGE_INTACCT_CONFIG.EXPORTER, exporter); - const parameters: UpdateSageIntacctExporterParams = { + const parameters = { policyID, email: exporter, }; @@ -119,7 +109,7 @@ function updateSageIntacctExporter(policyID: string, exporter: string) { function updateSageIntacctExportDate(policyID: string, date: ValueOf) { const {optimisticData, failureData, successData} = prepareOnyxDataForExportUpdate(policyID, CONST.SAGE_INTACCT_CONFIG.EXPORT_DATE, date); - const parameters: UpdateSageIntacctExportDateParams = { + const parameters = { policyID, value: date, }; @@ -129,7 +119,7 @@ function updateSageIntacctExportDate(policyID: string, date: ValueOf) { const {optimisticData, failureData, successData} = prepareOnyxDataForExportUpdate(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE, reimbursable); - const parameters: UpdateSageIntacctReimbursableExpensesExportDestinationParams = { + const parameters = { policyID, value: reimbursable, }; @@ -139,7 +129,7 @@ function updateSageIntacctReimbursableExpensesExportDestination(policyID: string function updateSageIntacctNonreimbursableExpensesExportDestination(policyID: string, nonReimbursable: ValueOf) { const {optimisticData, failureData, successData} = prepareOnyxDataForExportUpdate(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE, nonReimbursable); - const parameters: UpdateSageIntacctNonreimbursableExpensesExportDestinationParams = { + const parameters = { policyID, value: nonReimbursable, }; @@ -149,7 +139,7 @@ function updateSageIntacctNonreimbursableExpensesExportDestination(policyID: str function updateSageIntacctReimbursableExpensesReportExportDefaultVendor(policyID: string, vendor: string) { const {optimisticData, failureData, successData} = prepareOnyxDataForExportUpdate(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE_VENDOR, vendor); - const parameters: UpdateSageIntacctReimbursableExpensesReportExportDefaultVendorParams = { + const parameters = { policyID, vendorID: vendor, }; @@ -159,7 +149,7 @@ function updateSageIntacctReimbursableExpensesReportExportDefaultVendor(policyID function updateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendor(policyID: string, vendor: string) { const {optimisticData, failureData, successData} = prepareOnyxDataForExportUpdate(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_CREDIT_CARD_VENDOR, vendor); - const parameters: UpdateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVendorParams = { + const parameters = { policyID, vendorID: vendor, }; @@ -169,7 +159,7 @@ function updateSageIntacctNonreimbursableExpensesCreditCardChargeExportDefaultVe function updateSageIntacctNonreimbursableExpensesExportAccount(policyID: string, nonReimbursableAccount: string) { const {optimisticData, failureData, successData} = prepareOnyxDataForExportUpdate(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_ACCOUNT, nonReimbursableAccount); - const parameters: UpdateSageIntacctNonreimbursableExpensesExportAccountParams = { + const parameters = { policyID, creditCardAccountID: nonReimbursableAccount, }; @@ -179,7 +169,7 @@ function updateSageIntacctNonreimbursableExpensesExportAccount(policyID: string, function updateSageIntacctNonreimbursableExpensesExportVendor(policyID: string, vendor: string) { const {optimisticData, failureData, successData} = prepareOnyxDataForExportUpdate(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_VENDOR, vendor); - const parameters: UpdateSageIntacctNonreimbursableExpensesExportVendorParams = { + const parameters = { policyID, vendorID: vendor, };