diff --git a/src/CONST.ts b/src/CONST.ts index 4e873163cc95..aecc2c7d4829 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1817,6 +1817,7 @@ const CONST = { EXPORT_TO_NEXT_OPEN_PERIOD: 'exportToNextOpenPeriod', IMPORT_FIELDS: ['departments', 'classes', 'locations'], AUTO_SYNC: 'autoSync', + ACCOUNTING_METHOD: 'accountingMethod', REIMBURSEMENT_ACCOUNT_ID: 'reimbursementAccountID', COLLECTION_ACCOUNT: 'collectionAccount', AUTO_CREATE_ENTITIES: 'autoCreateEntities', diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 103c4b2c3125..9f9b4070ec1d 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -1632,6 +1632,14 @@ const ROUTES = { getRoute: (policyID: string, expenseType: ValueOf) => `settings/workspaces/${policyID}/connections/netsuite/advanced/custom-form-id/${expenseType}` as const, }, + POLICY_ACCOUNTING_NETSUITE_AUTO_SYNC: { + route: 'settings/workspaces/:policyID/connections/netsuite/advanced/autosync', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/netsuite/advanced/autosync` as const, + }, + POLICY_ACCOUNTING_NETSUITE_ACCOUNTING_METHOD: { + route: 'settings/workspaces/:policyID/connections/netsuite/advanced/autosync/accounting-method', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/netsuite/advanced/autosync/accounting-method` as const, + }, POLICY_ACCOUNTING_SAGE_INTACCT_PREREQUISITES: { route: 'settings/workspaces/:policyID/accounting/sage-intacct/prerequisites', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/sage-intacct/prerequisites` as const, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 9b8fe54111cf..81fc08775356 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -405,6 +405,8 @@ const SCREENS = { NETSUITE_JOURNAL_ENTRY_APPROVAL_LEVEL_SELECT: 'Policy_Accounting_NetSuite_Journal_Entry_Approval_Level_Select', NETSUITE_APPROVAL_ACCOUNT_SELECT: 'Policy_Accounting_NetSuite_Approval_Account_Select', NETSUITE_CUSTOM_FORM_ID: 'Policy_Accounting_NetSuite_Custom_Form_ID', + NETSUITE_AUTO_SYNC: 'Policy_Accounting_NetSuite_Auto_Sync', + NETSUITE_ACCOUNTING_METHOD: 'Policy_Accounting_NetSuite_Accounting_Method', SAGE_INTACCT_PREREQUISITES: 'Policy_Accounting_Sage_Intacct_Prerequisites', ENTER_SAGE_INTACCT_CREDENTIALS: 'Policy_Enter_Sage_Intacct_Credentials', EXISTING_SAGE_INTACCT_CONNECTIONS: 'Policy_Existing_Sage_Intacct_Connections', diff --git a/src/components/SelectionScreen.tsx b/src/components/SelectionScreen.tsx index 3538b04ed57f..020796085ba4 100644 --- a/src/components/SelectionScreen.tsx +++ b/src/components/SelectionScreen.tsx @@ -179,6 +179,7 @@ function SelectionScreen({ sectionListStyle={!!sections.length && [styles.flexGrow0]} shouldSingleExecuteRowSelect={shouldSingleExecuteRowSelect} shouldUpdateFocusedIndex={shouldUpdateFocusedIndex} + isAlternateTextMultilineSupported > ; +}; + +export default UpdateNetSuiteAccountingMethodParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index a6fca0ea19e8..681114fd3b08 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -19,6 +19,7 @@ export type {default as OpenPolicyInitialPageParams} from './OpenPolicyInitialPa export type {default as SyncPolicyToQuickbooksOnlineParams} from './SyncPolicyToQuickbooksOnlineParams'; export type {default as SyncPolicyToXeroParams} from './SyncPolicyToXeroParams'; export type {default as SyncPolicyToNetSuiteParams} from './SyncPolicyToNetSuiteParams'; +export type {default as UpdateNetSuiteAccountingMethodParams} from './UpdateNetSuiteAccountingMethodParams'; export type {default as SyncPolicyToQuickbooksDesktopParams} from './SyncPolicyToQuickbooksDesktopParams'; export type {default as DeleteContactMethodParams} from './DeleteContactMethodParams'; export type {default as DeletePaymentBankAccountParams} from './DeletePaymentBankAccountParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 855e0c26950f..bd8a58555617 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -359,6 +359,7 @@ const WRITE_COMMANDS = { UPDATE_NETSUITE_COLLECTION_ACCOUNT: 'UpdateNetSuiteCollectionAccount', UPDATE_NETSUITE_EXPORT_REPORTS_TO: 'UpdateNetSuiteExportReportsTo', UPDATE_NETSUITE_VENDOR_BILLS_TO: 'UpdateNetSuiteExportVendorBillsTo', + UPDATE_NETSUITE_ACCOUNTING_METHOD: 'UpdateNetSuiteAccountingMethod', UPDATE_NETSUITE_JOURNALS_TO: 'UpdateNetSuiteExportJournalsTo', UPDATE_NETSUITE_APPROVAL_ACCOUNT: 'UpdateNetSuiteApprovalAccount', UPDATE_NETSUITE_CUSTOM_FORM_ID_OPTIONS_REIMBURSABLE: 'UpdateNetSuiteCustomFormIDOptionsReimbursable', @@ -830,6 +831,7 @@ type WriteCommandParameters = { [WRITE_COMMANDS.UPDATE_NETSUITE_COLLECTION_ACCOUNT]: Parameters.UpdateNetSuiteGenericTypeParams<'bankAccountID', string>; [WRITE_COMMANDS.UPDATE_NETSUITE_EXPORT_REPORTS_TO]: Parameters.UpdateNetSuiteGenericTypeParams<'value', ValueOf>; [WRITE_COMMANDS.UPDATE_NETSUITE_VENDOR_BILLS_TO]: Parameters.UpdateNetSuiteGenericTypeParams<'value', ValueOf>; + [WRITE_COMMANDS.UPDATE_NETSUITE_ACCOUNTING_METHOD]: Parameters.UpdateNetSuiteAccountingMethodParams; [WRITE_COMMANDS.UPDATE_NETSUITE_JOURNALS_TO]: Parameters.UpdateNetSuiteGenericTypeParams<'value', ValueOf>; [WRITE_COMMANDS.UPDATE_NETSUITE_APPROVAL_ACCOUNT]: Parameters.UpdateNetSuiteGenericTypeParams<'value', string>; [WRITE_COMMANDS.UPDATE_NETSUITE_CUSTOM_FORM_ID_OPTIONS_REIMBURSABLE]: Parameters.UpdateNetSuiteCustomFormIDParams; diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 8a64424c8f7d..71de9bc420d6 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -475,6 +475,9 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/netsuite/advanced/NetSuiteApprovalAccountSelectPage').default, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_CUSTOM_FORM_ID]: () => require('../../../../pages/workspace/accounting/netsuite/advanced/NetSuiteCustomFormIDPage').default, + [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_AUTO_SYNC]: () => require('../../../../pages/workspace/accounting/netsuite/advanced/NetSuiteAutoSyncPage').default, + [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_ACCOUNTING_METHOD]: () => + require('../../../../pages/workspace/accounting/netsuite/advanced/NetSuiteAccountingMethodPage').default, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREREQUISITES]: () => require('../../../../pages/workspace/accounting/intacct/SageIntacctPrerequisitesPage').default, [SCREENS.WORKSPACE.ACCOUNTING.ENTER_SAGE_INTACCT_CREDENTIALS]: () => require('../../../../pages/workspace/accounting/intacct/EnterSageIntacctCredentialsPage').default, 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 d282bab770c6..d19b23f5c00c 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -124,6 +124,8 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_JOURNAL_ENTRY_APPROVAL_LEVEL_SELECT, SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_APPROVAL_ACCOUNT_SELECT, SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_CUSTOM_FORM_ID, + SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_AUTO_SYNC, + SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_ACCOUNTING_METHOD, SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREREQUISITES, SCREENS.WORKSPACE.ACCOUNTING.ENTER_SAGE_INTACCT_CREDENTIALS, SCREENS.WORKSPACE.ACCOUNTING.EXISTING_SAGE_INTACCT_CONNECTIONS, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 7a5b31489764..c7c9eb10d7d3 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -529,6 +529,12 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_CUSTOM_FORM_ID]: { path: ROUTES.POLICY_ACCOUNTING_NETSUITE_CUSTOM_FORM_ID.route, }, + [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_AUTO_SYNC]: { + path: ROUTES.POLICY_ACCOUNTING_NETSUITE_AUTO_SYNC.route, + }, + [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_ACCOUNTING_METHOD]: { + path: ROUTES.POLICY_ACCOUNTING_NETSUITE_ACCOUNTING_METHOD.route, + }, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREREQUISITES]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_PREREQUISITES.route}, [SCREENS.WORKSPACE.ACCOUNTING.ENTER_SAGE_INTACCT_CREDENTIALS]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_ENTER_CREDENTIALS.route}, [SCREENS.WORKSPACE.ACCOUNTING.EXISTING_SAGE_INTACCT_CONNECTIONS]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXISTING_CONNECTIONS.route}, diff --git a/src/libs/actions/connections/NetSuiteCommands.ts b/src/libs/actions/connections/NetSuiteCommands.ts index ad3693ef3654..bf5b2be4b4a0 100644 --- a/src/libs/actions/connections/NetSuiteCommands.ts +++ b/src/libs/actions/connections/NetSuiteCommands.ts @@ -1,3 +1,4 @@ +import type {CONST as COMMON_CONST} from 'expensify-common'; import isObject from 'lodash/isObject'; import type {OnyxUpdate} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; @@ -935,6 +936,21 @@ function updateNetSuiteExportReportsTo( API.write(WRITE_COMMANDS.UPDATE_NETSUITE_EXPORT_REPORTS_TO, parameters, onyxData); } +function updateNetSuiteAccountingMethod( + policyID: string, + accountingMethod: ValueOf, + oldAccountingMethod: ValueOf, +) { + const onyxData = updateNetSuiteOnyxData(policyID, CONST.NETSUITE_CONFIG.ACCOUNTING_METHOD, accountingMethod, oldAccountingMethod); + + const parameters = { + policyID, + accountingMethod, + }; + + API.write(WRITE_COMMANDS.UPDATE_NETSUITE_ACCOUNTING_METHOD, parameters, onyxData); +} + function updateNetSuiteExportVendorBillsTo( policyID: string, approvalLevel: ValueOf, @@ -1037,4 +1053,5 @@ export { updateNetSuiteApprovalAccount, updateNetSuiteCustomFormIDOptions, updateNetSuiteCustomersJobsMapping, + updateNetSuiteAccountingMethod, }; diff --git a/src/pages/workspace/accounting/netsuite/advanced/NetSuiteAccountingMethodPage.tsx b/src/pages/workspace/accounting/netsuite/advanced/NetSuiteAccountingMethodPage.tsx new file mode 100644 index 000000000000..a5c1872158e9 --- /dev/null +++ b/src/pages/workspace/accounting/netsuite/advanced/NetSuiteAccountingMethodPage.tsx @@ -0,0 +1,83 @@ +import {CONST as COMMON_CONST} from 'expensify-common'; +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/NetSuiteCommands'; +import {settingsPendingAction} from '@libs/PolicyUtils'; +import Navigation from '@navigation/Navigation'; +import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import CONST from '@src/CONST'; +import type {TranslationPaths} from '@src/languages/types'; +import ROUTES from '@src/ROUTES'; + +type MenuListItem = ListItem & { + value: ValueOf; +}; + +function NetSuiteAccountingMethodPage({policy}: WithPolicyConnectionsProps) { + const {translate} = useLocalize(); + const policyID = policy?.id ?? '-1'; + const styles = useThemeStyles(); + const config = policy?.connections?.netsuite?.options?.config; + const autoSyncConfig = policy?.connections?.netsuite?.config; + const accountingMethod = config?.accountingMethod ?? COMMON_CONST.INTEGRATIONS.ACCOUNTING_METHOD.CASH; + const data: MenuListItem[] = Object.values(COMMON_CONST.INTEGRATIONS.ACCOUNTING_METHOD).map((accountingMethodType) => ({ + value: accountingMethodType, + text: translate(`workspace.netsuite.advancedConfig.accountingMethods.values.${accountingMethodType}` as TranslationPaths), + alternateText: translate(`workspace.netsuite.advancedConfig.accountingMethods.alternateText.${accountingMethodType}` as TranslationPaths), + keyForList: accountingMethodType, + isSelected: accountingMethod === accountingMethodType, + })); + + const pendingAction = + settingsPendingAction([CONST.NETSUITE_CONFIG.AUTO_SYNC], autoSyncConfig?.pendingFields) ?? settingsPendingAction([CONST.NETSUITE_CONFIG.ACCOUNTING_METHOD], config?.pendingFields); + + const headerContent = useMemo( + () => ( + + {translate('workspace.netsuite.advancedConfig.accountingMethods.description')} + + ), + [translate, styles.pb5, styles.ph5], + ); + + const selectExpenseReportApprovalLevel = useCallback( + (row: MenuListItem) => { + if (row.value !== config?.accountingMethod) { + Connections.updateNetSuiteAccountingMethod(policyID, row.value, config?.accountingMethod ?? COMMON_CONST.INTEGRATIONS.ACCOUNTING_METHOD.CASH); + } + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_NETSUITE_AUTO_SYNC.getRoute(policyID)); + }, + [config?.accountingMethod, policyID], + ); + + return ( + selectExpenseReportApprovalLevel(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_NETSUITE_AUTO_SYNC.getRoute(policyID))} + connectionName={CONST.POLICY.CONNECTIONS.NAME.NETSUITE} + pendingAction={pendingAction} + /> + ); +} + +NetSuiteAccountingMethodPage.displayName = 'NetSuiteExpenseReportApprovalLevelSelectPage'; + +export default withPolicyConnections(NetSuiteAccountingMethodPage); diff --git a/src/pages/workspace/accounting/netsuite/advanced/NetSuiteAdvancedPage.tsx b/src/pages/workspace/accounting/netsuite/advanced/NetSuiteAdvancedPage.tsx index 50b2b966c73b..c6da14d9efd1 100644 --- a/src/pages/workspace/accounting/netsuite/advanced/NetSuiteAdvancedPage.tsx +++ b/src/pages/workspace/accounting/netsuite/advanced/NetSuiteAdvancedPage.tsx @@ -1,3 +1,4 @@ +import {CONST as COMMON_CONST} from 'expensify-common'; import React, {useMemo} from 'react'; import {View} from 'react-native'; import ConnectionLayout from '@components/ConnectionLayout'; @@ -29,18 +30,19 @@ import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; import * as Policy from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; +import type {TranslationPaths} from '@src/languages/types'; import ROUTES from '@src/ROUTES'; -type MenuItemWithSubscribedSettings = Pick & {subscribedSettings?: string[]}; +type MenuItemWithSubscribedSettings = Pick & {subscribedSettings?: string[]}; function NetSuiteAdvancedPage({policy}: WithPolicyConnectionsProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const policyID = policy?.id ?? '-1'; - const config = policy?.connections?.netsuite?.options.config; + const config = policy?.connections?.netsuite?.options?.config; const autoSyncConfig = policy?.connections?.netsuite?.config; - + const accountingMethod = policy?.connections?.netsuite?.options?.config?.accountingMethod; const {payableList} = policy?.connections?.netsuite?.options?.data ?? {}; const selectedReimbursementAccount = useMemo( @@ -63,16 +65,19 @@ function NetSuiteAdvancedPage({policy}: WithPolicyConnectionsProps) { const menuItems: Array = [ { - type: 'toggle', - title: translate('workspace.accounting.autoSync'), - subtitle: translate('workspace.netsuite.advancedConfig.autoSyncDescription'), - isActive: !!autoSyncConfig?.autoSync.enabled, - switchAccessibilityLabel: translate('workspace.netsuite.advancedConfig.autoSyncDescription'), - shouldPlaceSubtitleBelowSwitch: true, - onCloseError: () => Policy.clearNetSuiteAutoSyncErrorField(policyID), - onToggle: (isEnabled) => Connections.updateNetSuiteAutoSync(policyID, isEnabled), - pendingAction: settingsPendingAction([CONST.NETSUITE_CONFIG.AUTO_SYNC], autoSyncConfig?.pendingFields), - errors: ErrorUtils.getLatestErrorField(autoSyncConfig, CONST.NETSUITE_CONFIG.AUTO_SYNC), + type: 'menuitem', + title: autoSyncConfig?.autoSync?.enabled ? translate('common.enabled') : translate('common.disabled'), + description: translate('workspace.accounting.autoSync'), + onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_AUTO_SYNC.getRoute(policyID)), + hintText: (() => { + if (!autoSyncConfig?.autoSync?.enabled) { + return undefined; + } + return translate( + `workspace.netsuite.advancedConfig.accountingMethods.alternateText.${accountingMethod ?? COMMON_CONST.INTEGRATIONS.ACCOUNTING_METHOD.CASH}` as TranslationPaths, + ); + })(), + subscribedSettings: [CONST.NETSUITE_CONFIG.AUTO_SYNC, CONST.NETSUITE_CONFIG.ACCOUNTING_METHOD], }, { type: 'divider', @@ -256,7 +261,9 @@ function NetSuiteAdvancedPage({policy}: WithPolicyConnectionsProps) { return ( ); diff --git a/src/pages/workspace/accounting/netsuite/advanced/NetSuiteAutoSyncPage.tsx b/src/pages/workspace/accounting/netsuite/advanced/NetSuiteAutoSyncPage.tsx new file mode 100644 index 000000000000..e75496caa451 --- /dev/null +++ b/src/pages/workspace/accounting/netsuite/advanced/NetSuiteAutoSyncPage.tsx @@ -0,0 +1,81 @@ +import {CONST as COMMON_CONST} from 'expensify-common'; +import React from 'react'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; +import OfflineWithFeedback from '@components/OfflineWithFeedback'; +import ScreenWrapper from '@components/ScreenWrapper'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import * as Connections from '@libs/actions/connections/NetSuiteCommands'; +import * as ErrorUtils from '@libs/ErrorUtils'; +import Navigation from '@libs/Navigation/Navigation'; +import {settingsPendingAction} from '@libs/PolicyUtils'; +import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; +import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; +import * as Policy from '@userActions/Policy/Policy'; +import CONST from '@src/CONST'; +import type {TranslationPaths} from '@src/languages/types'; +import ROUTES from '@src/ROUTES'; + +function NetSuiteAutoSyncPage({policy, route}: WithPolicyConnectionsProps) { + const styles = useThemeStyles(); + const {translate} = useLocalize(); + const config = policy?.connections?.netsuite?.options?.config; + const autoSyncConfig = policy?.connections?.netsuite?.config; + const policyID = route.params.policyID ?? '-1'; + const accountingMethod = policy?.connections?.netsuite?.options?.config?.accountingMethod; + const pendingAction = + settingsPendingAction([CONST.NETSUITE_CONFIG.AUTO_SYNC], autoSyncConfig?.pendingFields) ?? settingsPendingAction([CONST.NETSUITE_CONFIG.ACCOUNTING_METHOD], config?.pendingFields); + + return ( + + + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_NETSUITE_ADVANCED.getRoute(policyID))} + /> + Policy.clearNetSuiteAutoSyncErrorField(policyID)} + onToggle={(isEnabled) => Connections.updateNetSuiteAutoSync(policyID, isEnabled)} + pendingAction={pendingAction} + errors={ErrorUtils.getLatestErrorField(autoSyncConfig, CONST.NETSUITE_CONFIG.AUTO_SYNC)} + /> + {!!autoSyncConfig?.autoSync?.enabled && ( + + Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_ACCOUNTING_METHOD.getRoute(policyID))} + /> + + )} + + + ); +} + +NetSuiteAutoSyncPage.displayName = 'NetSuiteAutoSyncPage'; + +export default withPolicyConnections(NetSuiteAutoSyncPage); diff --git a/src/pages/workspace/accounting/utils.tsx b/src/pages/workspace/accounting/utils.tsx index 5b20b522ac23..3ed4d6077417 100644 --- a/src/pages/workspace/accounting/utils.tsx +++ b/src/pages/workspace/accounting/utils.tsx @@ -186,6 +186,7 @@ function getAccountingIntegrationData( onAdvancedPagePress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_ADVANCED.getRoute(policyID)), subscribedAdvancedSettings: [ CONST.NETSUITE_CONFIG.AUTO_SYNC, + CONST.NETSUITE_CONFIG.ACCOUNTING_METHOD, ...(!shouldHideReimbursedReportsSection(netsuiteConfig) ? [CONST.NETSUITE_CONFIG.SYNC_OPTIONS.SYNC_REIMBURSED_REPORTS, CONST.NETSUITE_CONFIG.REIMBURSEMENT_ACCOUNT_ID, CONST.NETSUITE_CONFIG.COLLECTION_ACCOUNT] : []), @@ -207,8 +208,8 @@ function getAccountingIntegrationData( ? ROUTES.POLICY_ACCOUNTING.getRoute(policyID, connectionName, integrationToDisconnect, shouldDisconnectIntegrationBeforeConnecting) : ROUTES.POLICY_ACCOUNTING_NETSUITE_TOKEN_INPUT.getRoute(policyID), }, - pendingFields: {...netsuiteConfig?.pendingFields, ...policy?.connections?.netsuite?.config?.pendingFields}, - errorFields: {...netsuiteConfig?.errorFields, ...policy?.connections?.netsuite?.config?.errorFields}, + pendingFields: {...netsuiteConfig?.pendingFields, ...policy?.connections?.netsuite?.config?.pendingFields, ...policy?.connections?.netsuite?.options?.config?.pendingFields}, + errorFields: {...netsuiteConfig?.errorFields, ...policy?.connections?.netsuite?.config?.errorFields, ...policy?.connections?.netsuite?.options?.config?.errorFields}, }; case CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT: return { diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 1057e21d394f..88e41aed5bb4 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -1,3 +1,4 @@ +import type {CONST as COMMON_CONST} from 'expensify-common'; import type {ValueOf} from 'type-fest'; import type CONST from '@src/CONST'; import type {Country} from '@src/CONST'; @@ -1008,6 +1009,9 @@ type NetSuiteConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback< /** Whether this account is using the newer version of tax in NetSuite, SuiteTax */ suiteTaxEnabled?: boolean; + /** The accounting Method for NetSuite conenction config */ + accountingMethod?: ValueOf; + /** Collection of errors coming from BE */ errors?: OnyxCommon.Errors;