From 1b9a19d3e2a46cbfad7ac0a89ef80f8d5db7e231 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Sun, 30 Jun 2024 05:11:38 +0530 Subject: [PATCH 01/19] feat: added import route --- src/ROUTES.ts | 4 ++++ src/SCREENS.ts | 1 + .../Navigation/AppNavigator/ModalStackNavigators/index.tsx | 2 ++ .../Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts | 1 + src/libs/Navigation/linkingConfig/config.ts | 1 + src/libs/Navigation/types.ts | 3 +++ src/pages/workspace/accounting/PolicyAccountingPage.tsx | 2 +- .../accounting/netsuite/import/NetSuiteImportPage.tsx | 7 +++++++ 8 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 33eb78dc300d..010a8c611cfc 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -936,6 +936,10 @@ const ROUTES = { route: 'settings/workspaces/:policyID/accounting/net-suite/subsidiary-selector', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/net-suite/subsidiary-selector` as const, }, + POLICY_ACCOUNTING_NETSUITE_IMPORT: { + route: 'settings/workspaces/:policyID/accounting/netsuite/import', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/netsuite/import` as const, + }, RESTRICTED_ACTION: { route: 'restricted-action/workspace/:policyID', getRoute: (policyID: string) => `restricted-action/workspace/${policyID}` as const, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 1807c9bb0bab..d4b631f6d0fa 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -273,6 +273,7 @@ const SCREENS = { XERO_BILL_PAYMENT_ACCOUNT_SELECTOR: 'Policy_Accounting_Xero_Bill_Payment_Account_Selector', XERO_EXPORT_BANK_ACCOUNT_SELECT: 'Policy_Accounting_Xero_Export_Bank_Account_Select', NETSUITE_SUBSIDIARY_SELECTOR: 'Policy_Accounting_Net_Suite_Subsidiary_Selector', + NETSUITE_IMPORT: 'Policy_Accounting_Net_Suite_Import', 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/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 81ecb85299da..89a70abead2a 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -319,6 +319,8 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/xero/advanced/XeroBillPaymentAccountSelectorPage').default, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_SUBSIDIARY_SELECTOR]: () => require('../../../../pages/workspace/accounting/netsuite/NetSuiteSubsidiarySelector').default, + [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT]: () => + require('../../../../pages/workspace/accounting/netsuite/import/NetSuiteImportPage').default, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREREQUISITES]: () => require('../../../../pages/workspace/accounting/intacct/IntacctPrerequisitesPage').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 1adb302bac15..622aa61fb699 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_BILL_PAYMENT_ACCOUNT_SELECTOR, SCREENS.WORKSPACE.ACCOUNTING.XERO_EXPORT_BANK_ACCOUNT_SELECT, SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_SUBSIDIARY_SELECTOR, + SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT, 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 a67b90beb04e..b89f106edb1b 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -354,6 +354,7 @@ const config: LinkingOptions['config'] = { [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.NETSUITE_SUBSIDIARY_SELECTOR]: {path: ROUTES.POLICY_ACCOUNTING_NETSUITE_SUBSIDIARY_SELECTOR.route}, + [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT]: {path: ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT.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/Navigation/types.ts b/src/libs/Navigation/types.ts index 7e50712d3bf5..79e05b0ebc7d 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -399,6 +399,9 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_SUBSIDIARY_SELECTOR]: { policyID: string; }; + [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT]: { + policyID: string; + }; [SCREENS.GET_ASSISTANCE]: { backTo: Routes; }; diff --git a/src/pages/workspace/accounting/PolicyAccountingPage.tsx b/src/pages/workspace/accounting/PolicyAccountingPage.tsx index 518a8720c7fc..06edb55b7cf9 100644 --- a/src/pages/workspace/accounting/PolicyAccountingPage.tsx +++ b/src/pages/workspace/accounting/PolicyAccountingPage.tsx @@ -113,7 +113,7 @@ function accountingIntegrationData( integrationToDisconnect={integrationToDisconnect} /> ), - onImportPagePress: () => {}, + onImportPagePress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT.getRoute(policyID)), onExportPagePress: () => {}, onAdvancedPagePress: () => {}, }; diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx new file mode 100644 index 000000000000..5bd4dead769e --- /dev/null +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx @@ -0,0 +1,7 @@ +import React from 'react'; +function NetSuiteImportPage() { + return <>Importp page; +} + +NetSuiteImportPage.displayName = 'NetSuiteImportPage'; +export default NetSuiteImportPage; \ No newline at end of file From 2d782fdc8cece10b4f7d0e48338e357991f0c3a8 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Sun, 30 Jun 2024 05:53:44 +0530 Subject: [PATCH 02/19] feat: import fields and expense categories list added --- src/CONST.ts | 1 + .../netsuite/import/NetSuiteImportPage.tsx | 70 ++++++++++++++++++- 2 files changed, 68 insertions(+), 3 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 233b35e6ac4b..97e7bc187401 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1339,6 +1339,7 @@ const CONST = { NETSUITE_CONFIG: { SUBSIDIARY: 'subsidiary', + IMPORT_FIELDS: ['departments', 'classes', 'locations', 'customers', 'jobs'], }, QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE: { diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx index 5bd4dead769e..51f998ab88ac 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx @@ -1,7 +1,71 @@ import React from 'react'; -function NetSuiteImportPage() { - return <>Importp page; +import {View} from 'react-native'; +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 * as ErrorUtils from '@libs/ErrorUtils'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; +import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; +import * as Policy from '@userActions/Policy/Policy'; +import CONST from '@src/CONST'; + +function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { + const {translate} = useLocalize(); + const styles = useThemeStyles(); + const policyID = policy?.id ?? '-1'; + const config = policy?.connections?.netsuite?.options.config; + const importFields = CONST.NETSUITE_CONFIG.IMPORT_FIELDS; + + return ( + + + + {}} + /> + + + + + {importFields.map((importField) => ( + Policy.clearNetSuiteErrorField(policyID, importField)} + > + {}} + brickRoadIndicator={config?.errorFields?.[importField] ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} + /> + + ))} + + + ); } NetSuiteImportPage.displayName = 'NetSuiteImportPage'; -export default NetSuiteImportPage; \ No newline at end of file +export default withPolicyConnections(NetSuiteImportPage); From 9b865aa752c691f7ab3cbda206bc820a33593163 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Sun, 30 Jun 2024 06:30:08 +0530 Subject: [PATCH 03/19] feat: custom list and tax options --- src/CONST.ts | 2 + src/languages/en.ts | 17 +++++ src/languages/es.ts | 17 +++++ .../netsuite/import/NetSuiteImportPage.tsx | 63 ++++++++++++++----- 4 files changed, 84 insertions(+), 15 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 97e7bc187401..8fe2c2506be3 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1287,6 +1287,7 @@ const CONST = { REPORT_FIELD: 'REPORT_FIELD', NOT_IMPORTED: 'NOT_IMPORTED', IMPORTED: 'IMPORTED', + NETSUITE_DEFAULT: 'NETSUITE_DEFAULT', }, QUICKBOOKS_ONLINE: 'quickbooksOnline', @@ -1340,6 +1341,7 @@ const CONST = { NETSUITE_CONFIG: { SUBSIDIARY: 'subsidiary', IMPORT_FIELDS: ['departments', 'classes', 'locations', 'customers', 'jobs'], + IMPORT_CUSTOM_FIELDS: ['customSegments', 'customLists'], }, QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE: { diff --git a/src/languages/en.ts b/src/languages/en.ts index 095cc12a3896..74176e4cc599 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2204,6 +2204,22 @@ export default { subsidiarySelectDescription: "Choose the subsidiary in NetSuite that you'd like to import data from.", noSubsidiariesFound: 'No subsidiaries found', noSubsidiariesFoundDescription: 'Add the subsidiary in NetSuite and sync the connection again.', + import: { + expenseCategories: `Expense categories`, + expenseCategoriesDescription: `NetSuite expense categories import into Expensify as categories.`, + importFields: { + departments: 'Departments', + classes: 'Classes', + locations: 'Locations', + customers: 'Customers', + jobs: 'Projects(jobs)', + }, + importTaxDescription: 'Import tax groups from NetSuite', + importCustomFields: { + customSegments: 'Custom segments/records', + customLists: 'Custom lists', + }, + }, }, intacct: { sageIntacctSetup: 'Sage Intacct setup', @@ -2515,6 +2531,7 @@ export default { [CONST.INTEGRATION_ENTITY_MAP_TYPES.NOT_IMPORTED]: 'Not imported', [CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE]: 'Not imported', [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 => { const integrationName = diff --git a/src/languages/es.ts b/src/languages/es.ts index e2a00222c62a..e761089fe179 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2237,6 +2237,22 @@ export default { subsidiarySelectDescription: 'Elige la subsidiaria de NetSuite de la que deseas importar datos.', noSubsidiariesFound: 'No se ha encontrado subsidiarias', noSubsidiariesFoundDescription: 'Añade la subsidiaria en NetSuite y sincroniza de nuevo la conexión.', + import: { + expenseCategories: `Expense categories`, + expenseCategoriesDescription: `NetSuite expense categories import into Expensify as categories.`, + importFields: { + departments: 'Departments', + classes: 'Classes', + locations: 'Locations', + customers: 'Customers', + jobs: 'Projects(jobs)', + }, + importTaxDescription: 'Import tax groups from NetSuite', + importCustomFields: { + customSegments: 'Custom segments/records', + customLists: 'Custom lists', + }, + }, }, intacct: { sageIntacctSetup: 'Sage Intacct configuración', @@ -2487,6 +2503,7 @@ export default { [CONST.INTEGRATION_ENTITY_MAP_TYPES.NOT_IMPORTED]: 'No importado', [CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE]: 'No importado', [CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]: 'Importado como campos de informe', + [CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT]: 'NetSuite employee default', }, disconnectPrompt: (currentIntegration?: ConnectionName): string => { const integrationName = diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx index 51f998ab88ac..cbaea123ac0b 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx @@ -18,6 +18,7 @@ function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { const policyID = policy?.id ?? '-1'; const config = policy?.connections?.netsuite?.options.config; const importFields = CONST.NETSUITE_CONFIG.IMPORT_FIELDS; + const importCustomFields = CONST.NETSUITE_CONFIG.IMPORT_CUSTOM_FIELDS; return ( - - - {}} - /> - + + {}} + /> - + {importFields.map((importField) => ( {}} + onPress={() => { + // TODO: Navigation will be handled in future PRs + }} + brickRoadIndicator={config?.errorFields?.[importField] ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} + /> + + ))} + + + + {}} + /> + + + + {importCustomFields.map((importField) => ( + Policy.clearNetSuiteErrorField(policyID, importField)} + > + { + // TODO: Navigation will be handled in future PRs + }} brickRoadIndicator={config?.errorFields?.[importField] ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} /> From ef9426f3f6a5376fea972ac61abcc17b022beeef Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Sun, 30 Jun 2024 06:50:42 +0530 Subject: [PATCH 04/19] feat: added api setup --- ...pdateNetSuiteSyncTaxConfigurationParams.ts | 6 ++ src/libs/API/parameters/index.ts | 1 + src/libs/API/types.ts | 2 + .../actions/connections/NetSuiteCommands.ts | 88 ++++++++++++++++++- 4 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 src/libs/API/parameters/UpdateNetSuiteSyncTaxConfigurationParams.ts diff --git a/src/libs/API/parameters/UpdateNetSuiteSyncTaxConfigurationParams.ts b/src/libs/API/parameters/UpdateNetSuiteSyncTaxConfigurationParams.ts new file mode 100644 index 000000000000..6cbf5f08d3bb --- /dev/null +++ b/src/libs/API/parameters/UpdateNetSuiteSyncTaxConfigurationParams.ts @@ -0,0 +1,6 @@ +type UpdateNetSuiteSyncTaxConfigurationParams = { + policyID: string; + enabled: boolean; +}; + +export default UpdateNetSuiteSyncTaxConfigurationParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index 7cd9454bbcff..312bef5a0302 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -235,3 +235,4 @@ export type {default as UpdateSubscriptionAddNewUsersAutomaticallyParams} from ' export type {default as GenerateSpotnanaTokenParams} from './GenerateSpotnanaTokenParams'; export type {default as UpdateSubscriptionSizeParams} from './UpdateSubscriptionSizeParams'; export type {default as UpdateNetSuiteSubsidiaryParams} from './UpdateNetSuiteSubsidiaryParams'; +export type {default as UpdateNetSuiteSyncTaxConfigurationParams} from './UpdateNetSuiteSyncTaxConfigurationParams'; \ No newline at end of file diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 644c77630c14..cd8574a3922f 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -229,6 +229,7 @@ const WRITE_COMMANDS = { UPDATE_SUBSCRIPTION_ADD_NEW_USERS_AUTOMATICALLY: 'UpdateSubscriptionAddNewUsersAutomatically', UPDATE_SUBSCRIPTION_SIZE: 'UpdateSubscriptionSize', UPDATE_NETSUITE_SUBSIDIARY: 'UpdateNetSuiteSubsidiary', + UPDATE_NETSUITE_SYNC_TAX_CONFIGURATION: 'UpdateNetSuiteSyncTaxConfiguration', CONNECT_POLICY_TO_SAGE_INTACCT: 'ConnectPolicyToSageIntacct', } as const; @@ -463,6 +464,7 @@ type WriteCommandParameters = { // Netsuite parameters [WRITE_COMMANDS.UPDATE_NETSUITE_SUBSIDIARY]: Parameters.UpdateNetSuiteSubsidiaryParams; + [WRITE_COMMANDS.UPDATE_NETSUITE_SYNC_TAX_CONFIGURATION]: Parameters.UpdateNetSuiteSyncTaxConfigurationParams; }; const READ_COMMANDS = { diff --git a/src/libs/actions/connections/NetSuiteCommands.ts b/src/libs/actions/connections/NetSuiteCommands.ts index 49c42a95542e..2c7b2c0331f6 100644 --- a/src/libs/actions/connections/NetSuiteCommands.ts +++ b/src/libs/actions/connections/NetSuiteCommands.ts @@ -94,6 +94,92 @@ function updateNetSuiteSubsidiary(policyID: string, newSubsidiary: SubsidiaryPar API.write(WRITE_COMMANDS.UPDATE_NETSUITE_SUBSIDIARY, params, onyxData); } +function updateNetSuiteSyncTaxConfiguration(policyID: string, isSyncTaxEnabled: boolean) { + const onyxData: OnyxData = { + optimisticData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + connections: { + netsuite: { + options: { + config: { + syncOptions: { + syncTax: isSyncTaxEnabled, + }, + pendingFields: { + syncTax: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + errorFields: { + syncTax: null, + }, + }, + }, + }, + }, + }, + }, + ], + successData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + connections: { + netsuite: { + options: { + config: { + syncOptions: { + syncTax: isSyncTaxEnabled, + }, + pendingFields: { + syncTax: null + }, + errorFields: { + syncTax: null, + }, + }, + }, + }, + }, + }, + }, + ], + failureData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + connections: { + netsuite: { + options: { + config: { + syncOptions: { + syncTax: !isSyncTaxEnabled, + }, + pendingFields: { + syncTax: null, + }, + errorFields: { + syncTax: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), + }, + }, + }, + }, + }, + }, + }, + ], + }; + + const params = { + policyID, + enabled: isSyncTaxEnabled, + }; + API.write(WRITE_COMMANDS.UPDATE_NETSUITE_SYNC_TAX_CONFIGURATION, params, onyxData); +} + // We'll have more API calls in upcoming PRs // eslint-disable-next-line import/prefer-default-export -export {updateNetSuiteSubsidiary}; +export {updateNetSuiteSubsidiary, updateNetSuiteSyncTaxConfiguration}; From 1e49875bbd36d1f4857606e1ee28b69fe5dca0c9 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Sun, 30 Jun 2024 07:19:32 +0530 Subject: [PATCH 05/19] feat: api call without pending action --- src/CONST.ts | 1 + src/languages/en.ts | 2 +- .../actions/connections/NetSuiteCommands.ts | 18 +++++++++--------- .../netsuite/import/NetSuiteImportPage.tsx | 8 ++++++-- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 8fe2c2506be3..7e33790759b6 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1342,6 +1342,7 @@ const CONST = { SUBSIDIARY: 'subsidiary', IMPORT_FIELDS: ['departments', 'classes', 'locations', 'customers', 'jobs'], IMPORT_CUSTOM_FIELDS: ['customSegments', 'customLists'], + SYNC_TAX: 'syncTax' }, QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE: { diff --git a/src/languages/en.ts b/src/languages/en.ts index 74176e4cc599..299faadbd64e 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2212,7 +2212,7 @@ export default { classes: 'Classes', locations: 'Locations', customers: 'Customers', - jobs: 'Projects(jobs)', + jobs: 'Projects (jobs)', }, importTaxDescription: 'Import tax groups from NetSuite', importCustomFields: { diff --git a/src/libs/actions/connections/NetSuiteCommands.ts b/src/libs/actions/connections/NetSuiteCommands.ts index 2c7b2c0331f6..e159805017ae 100644 --- a/src/libs/actions/connections/NetSuiteCommands.ts +++ b/src/libs/actions/connections/NetSuiteCommands.ts @@ -108,9 +108,9 @@ function updateNetSuiteSyncTaxConfiguration(policyID: string, isSyncTaxEnabled: syncOptions: { syncTax: isSyncTaxEnabled, }, - pendingFields: { - syncTax: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, - }, + // pendingFields: { + // syncTax: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + // }, errorFields: { syncTax: null, }, @@ -133,9 +133,9 @@ function updateNetSuiteSyncTaxConfiguration(policyID: string, isSyncTaxEnabled: syncOptions: { syncTax: isSyncTaxEnabled, }, - pendingFields: { - syncTax: null - }, + // pendingFields: { + // syncTax: null + // }, errorFields: { syncTax: null, }, @@ -158,9 +158,9 @@ function updateNetSuiteSyncTaxConfiguration(policyID: string, isSyncTaxEnabled: syncOptions: { syncTax: !isSyncTaxEnabled, }, - pendingFields: { - syncTax: null, - }, + // pendingFields: { + // syncTax: null, + // }, errorFields: { syncTax: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), }, diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx index cbaea123ac0b..eb7ecb38c62a 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx @@ -6,6 +6,7 @@ import OfflineWithFeedback from '@components/OfflineWithFeedback'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import * as ErrorUtils from '@libs/ErrorUtils'; +import {updateNetSuiteSyncTaxConfiguration} from '@libs/actions/connections/NetSuiteCommands'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; @@ -71,9 +72,12 @@ function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { subtitle={translate('workspace.netsuite.import.importTaxDescription')} shouldPlaceSubtitleBelowSwitch isActive={config?.syncOptions?.syncTax ?? false} - disabled switchAccessibilityLabel={translate('common.tax')} - onToggle={() => {}} + onToggle={(isEnabled: boolean) => { + updateNetSuiteSyncTaxConfiguration(policyID, isEnabled); + }} + errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_TAX)} + onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_TAX)} /> From d0d3afd79116c1986dd5bc0f1a51309c469acc87 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Sun, 30 Jun 2024 07:20:28 +0530 Subject: [PATCH 06/19] refactor: run prettier --- src/CONST.ts | 2 +- .../parameters/UpdateNetSuiteSyncTaxConfigurationParams.ts | 4 ++-- src/libs/API/parameters/index.ts | 2 +- .../Navigation/AppNavigator/ModalStackNavigators/index.tsx | 3 +-- .../accounting/netsuite/import/NetSuiteImportPage.tsx | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 7e33790759b6..8ec621b5753f 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1342,7 +1342,7 @@ const CONST = { SUBSIDIARY: 'subsidiary', IMPORT_FIELDS: ['departments', 'classes', 'locations', 'customers', 'jobs'], IMPORT_CUSTOM_FIELDS: ['customSegments', 'customLists'], - SYNC_TAX: 'syncTax' + SYNC_TAX: 'syncTax', }, QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE: { diff --git a/src/libs/API/parameters/UpdateNetSuiteSyncTaxConfigurationParams.ts b/src/libs/API/parameters/UpdateNetSuiteSyncTaxConfigurationParams.ts index 6cbf5f08d3bb..c903ed06d028 100644 --- a/src/libs/API/parameters/UpdateNetSuiteSyncTaxConfigurationParams.ts +++ b/src/libs/API/parameters/UpdateNetSuiteSyncTaxConfigurationParams.ts @@ -1,6 +1,6 @@ type UpdateNetSuiteSyncTaxConfigurationParams = { - policyID: string; - enabled: boolean; + policyID: string; + enabled: boolean; }; export default UpdateNetSuiteSyncTaxConfigurationParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index 312bef5a0302..46bbbda0d724 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -235,4 +235,4 @@ export type {default as UpdateSubscriptionAddNewUsersAutomaticallyParams} from ' export type {default as GenerateSpotnanaTokenParams} from './GenerateSpotnanaTokenParams'; export type {default as UpdateSubscriptionSizeParams} from './UpdateSubscriptionSizeParams'; export type {default as UpdateNetSuiteSubsidiaryParams} from './UpdateNetSuiteSubsidiaryParams'; -export type {default as UpdateNetSuiteSyncTaxConfigurationParams} from './UpdateNetSuiteSyncTaxConfigurationParams'; \ No newline at end of file +export type {default as UpdateNetSuiteSyncTaxConfigurationParams} from './UpdateNetSuiteSyncTaxConfigurationParams'; diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 89a70abead2a..bb08255780b5 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -319,8 +319,7 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/xero/advanced/XeroBillPaymentAccountSelectorPage').default, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_SUBSIDIARY_SELECTOR]: () => require('../../../../pages/workspace/accounting/netsuite/NetSuiteSubsidiarySelector').default, - [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT]: () => - require('../../../../pages/workspace/accounting/netsuite/import/NetSuiteImportPage').default, + [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT]: () => require('../../../../pages/workspace/accounting/netsuite/import/NetSuiteImportPage').default, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREREQUISITES]: () => require('../../../../pages/workspace/accounting/intacct/IntacctPrerequisitesPage').default, [SCREENS.WORKSPACE.ACCOUNTING.ENTER_SAGE_INTACCT_CREDENTIALS]: () => require('../../../../pages/workspace/accounting/intacct/EnterSageIntacctCredentialsPage').default, diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx index eb7ecb38c62a..b7dff0a73fea 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx @@ -5,8 +5,8 @@ import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; -import * as ErrorUtils from '@libs/ErrorUtils'; import {updateNetSuiteSyncTaxConfiguration} from '@libs/actions/connections/NetSuiteCommands'; +import * as ErrorUtils from '@libs/ErrorUtils'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; From ba52be193c3f5759a912f603df3f1317763801a7 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Sun, 30 Jun 2024 08:57:55 +0530 Subject: [PATCH 07/19] fix: add tax enabled check for netsuite --- src/pages/workspace/WorkspaceMoreFeaturesPage.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index 1499f3a0c0b3..c8d32657f4c9 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -58,7 +58,10 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro const {translate} = useLocalize(); const {canUseReportFieldsFeature} = usePermissions(); const hasAccountingConnection = !!policy?.areConnectionsEnabled && !isEmptyObject(policy?.connections); - const isSyncTaxEnabled = !!policy?.connections?.quickbooksOnline?.config?.syncTax || !!policy?.connections?.xero?.config?.importTaxRates; + const isSyncTaxEnabled = + !!policy?.connections?.quickbooksOnline?.config?.syncTax || + !!policy?.connections?.xero?.config?.importTaxRates || + !!policy?.connections?.netsuite?.options?.config?.syncOptions?.syncTax; const policyID = policy?.id ?? ''; const [isOrganizeWarningModalOpen, setIsOrganizeWarningModalOpen] = useState(false); From 8c1251f79abf129b22f08df03dae79346c48039f Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Mon, 1 Jul 2024 23:25:42 +0530 Subject: [PATCH 08/19] refactor: reuse generic type --- .../parameters/UpdateNetSuiteSyncTaxConfigurationParams.ts | 6 ------ src/libs/API/parameters/index.ts | 1 - src/libs/API/types.ts | 2 +- 3 files changed, 1 insertion(+), 8 deletions(-) delete mode 100644 src/libs/API/parameters/UpdateNetSuiteSyncTaxConfigurationParams.ts diff --git a/src/libs/API/parameters/UpdateNetSuiteSyncTaxConfigurationParams.ts b/src/libs/API/parameters/UpdateNetSuiteSyncTaxConfigurationParams.ts deleted file mode 100644 index c903ed06d028..000000000000 --- a/src/libs/API/parameters/UpdateNetSuiteSyncTaxConfigurationParams.ts +++ /dev/null @@ -1,6 +0,0 @@ -type UpdateNetSuiteSyncTaxConfigurationParams = { - policyID: string; - enabled: boolean; -}; - -export default UpdateNetSuiteSyncTaxConfigurationParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index b4da5c18f117..ef44ce06bced 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -236,5 +236,4 @@ export type {default as UpdateSubscriptionAddNewUsersAutomaticallyParams} from ' export type {default as GenerateSpotnanaTokenParams} from './GenerateSpotnanaTokenParams'; export type {default as UpdateSubscriptionSizeParams} from './UpdateSubscriptionSizeParams'; export type {default as UpdateNetSuiteSubsidiaryParams} from './UpdateNetSuiteSubsidiaryParams'; -export type {default as UpdateNetSuiteSyncTaxConfigurationParams} from './UpdateNetSuiteSyncTaxConfigurationParams'; export type {default as UpdateNetSuiteGenericTypeParams} from './UpdateNetSuiteGenericTypeParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 88f005c40cb7..1f948139dbd9 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -480,7 +480,7 @@ type WriteCommandParameters = { // Netsuite parameters [WRITE_COMMANDS.UPDATE_NETSUITE_SUBSIDIARY]: Parameters.UpdateNetSuiteSubsidiaryParams; - [WRITE_COMMANDS.UPDATE_NETSUITE_SYNC_TAX_CONFIGURATION]: Parameters.UpdateNetSuiteSyncTaxConfigurationParams; + [WRITE_COMMANDS.UPDATE_NETSUITE_SYNC_TAX_CONFIGURATION]: Parameters.UpdateNetSuiteGenericTypeParams<'enabled', boolean>; [WRITE_COMMANDS.UPDATE_NETSUITE_EXPORTER]: Parameters.UpdateNetSuiteGenericTypeParams<'email', string>; [WRITE_COMMANDS.UPDATE_NETSUITE_EXPORT_DATE]: Parameters.UpdateNetSuiteGenericTypeParams<'value', ValueOf>; [WRITE_COMMANDS.UPDATE_NETSUITE_REIMBURSABLE_EXPENSES_EXPORT_DESTINATION]: Parameters.UpdateNetSuiteGenericTypeParams<'value', ValueOf>; From d4e010c2054a8adfc60bf1d17cbdcb670d0cf688 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Tue, 2 Jul 2024 02:15:18 +0530 Subject: [PATCH 09/19] refactor: run prettier --- src/libs/PolicyUtils.ts | 12 +++++++ .../netsuite/import/NetSuiteImportPage.tsx | 34 +++++++++++-------- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 24e123def45e..a2b91af701fc 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -528,6 +528,17 @@ function getNetSuiteTaxAccountOptions(policy: Policy | undefined, subsidiaryCoun })); } +function isSyncTaxEnabled(policy: Policy | undefined, canUseNetSuiteUSATax?: boolean) { + const netSuiteConfg = policy?.connections?.netsuite?.options?.config; + const {subsidiaryList} = policy?.connections?.netsuite?.options?.data ?? {}; + if (!netSuiteConfg || !subsidiaryList) { + return false; + } + + const selectedSubsidiary = (subsidiaryList ?? []).find((subsidiary) => subsidiary.internalID === netSuiteConfg?.subsidiaryID); + return !!netSuiteConfg?.suiteTaxEnabled || !netSuiteConfg?.syncOptions.syncTax || !canUseTaxNetSuite(canUseNetSuiteUSATax, selectedSubsidiary?.country); +} + function canUseTaxNetSuite(canUseNetSuiteUSATax?: boolean, subsidiaryCountry?: string) { return !!canUseNetSuiteUSATax || CONST.NETSUITE_TAX_COUNTRIES.includes(subsidiaryCountry ?? ''); } @@ -652,6 +663,7 @@ export { navigateWhenEnableFeature, getIntegrationLastSuccessfulDate, getCurrentConnectionName, + isSyncTaxEnabled, }; export type {MemberEmailsToAccountIDs}; diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx index b7dff0a73fea..2409814a9660 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx @@ -4,9 +4,11 @@ import ConnectionLayout from '@components/ConnectionLayout'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; import useLocalize from '@hooks/useLocalize'; +import usePermissions from '@hooks/usePermissions'; import useThemeStyles from '@hooks/useThemeStyles'; import {updateNetSuiteSyncTaxConfiguration} from '@libs/actions/connections/NetSuiteCommands'; import * as ErrorUtils from '@libs/ErrorUtils'; +import {isSyncTaxEnabled} from '@libs/PolicyUtils'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; @@ -16,6 +18,8 @@ import CONST from '@src/CONST'; function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); + const {canUseNetSuiteUSATax} = usePermissions(); + const policyID = policy?.id ?? '-1'; const config = policy?.connections?.netsuite?.options.config; const importFields = CONST.NETSUITE_CONFIG.IMPORT_FIELDS; @@ -66,20 +70,22 @@ function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { ))} - - { - updateNetSuiteSyncTaxConfiguration(policyID, isEnabled); - }} - errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_TAX)} - onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_TAX)} - /> - + {isSyncTaxEnabled(policy, canUseNetSuiteUSATax) && ( + + { + updateNetSuiteSyncTaxConfiguration(policyID, isEnabled); + }} + errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_TAX)} + onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_TAX)} + /> + + )} {importCustomFields.map((importField) => ( From 7ebd82ea9d376c450c4c1dcf05946b387d708e5a Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Tue, 2 Jul 2024 02:35:36 +0530 Subject: [PATCH 10/19] fix: tax enabled check --- src/libs/PolicyUtils.ts | 8 ++++++-- .../accounting/netsuite/import/NetSuiteImportPage.tsx | 4 +--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index a2b91af701fc..e13d14b2321a 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -528,7 +528,7 @@ function getNetSuiteTaxAccountOptions(policy: Policy | undefined, subsidiaryCoun })); } -function isSyncTaxEnabled(policy: Policy | undefined, canUseNetSuiteUSATax?: boolean) { +function isSyncTaxEnabled(policy: Policy | undefined) { const netSuiteConfg = policy?.connections?.netsuite?.options?.config; const {subsidiaryList} = policy?.connections?.netsuite?.options?.data ?? {}; if (!netSuiteConfg || !subsidiaryList) { @@ -536,7 +536,7 @@ function isSyncTaxEnabled(policy: Policy | undefined, canUseNetSuiteUSATax?: boo } const selectedSubsidiary = (subsidiaryList ?? []).find((subsidiary) => subsidiary.internalID === netSuiteConfg?.subsidiaryID); - return !!netSuiteConfg?.suiteTaxEnabled || !netSuiteConfg?.syncOptions.syncTax || !canUseTaxNetSuite(canUseNetSuiteUSATax, selectedSubsidiary?.country); + return !!netSuiteConfg?.suiteTaxEnabled && !isUSASubsidiaryNetSuite(selectedSubsidiary?.country); } function canUseTaxNetSuite(canUseNetSuiteUSATax?: boolean, subsidiaryCountry?: string) { @@ -547,6 +547,10 @@ function canUseProvincialTaxNetSuite(subsidiaryCountry?: string) { return subsidiaryCountry === '_canada'; } +function isUSASubsidiaryNetSuite(subsidiaryCountry?: string) { + return subsidiaryCountry === '_unitedStates'; +} + function getIntegrationLastSuccessfulDate(connection?: Connections[keyof Connections]) { if (!connection) { return undefined; diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx index 2409814a9660..64712ee2ce88 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx @@ -4,7 +4,6 @@ import ConnectionLayout from '@components/ConnectionLayout'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; import useLocalize from '@hooks/useLocalize'; -import usePermissions from '@hooks/usePermissions'; import useThemeStyles from '@hooks/useThemeStyles'; import {updateNetSuiteSyncTaxConfiguration} from '@libs/actions/connections/NetSuiteCommands'; import * as ErrorUtils from '@libs/ErrorUtils'; @@ -18,7 +17,6 @@ import CONST from '@src/CONST'; function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); - const {canUseNetSuiteUSATax} = usePermissions(); const policyID = policy?.id ?? '-1'; const config = policy?.connections?.netsuite?.options.config; @@ -70,7 +68,7 @@ function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { ))} - {isSyncTaxEnabled(policy, canUseNetSuiteUSATax) && ( + {isSyncTaxEnabled(policy) && ( Date: Tue, 2 Jul 2024 02:42:38 +0530 Subject: [PATCH 11/19] fix: export url change --- src/pages/workspace/accounting/PolicyAccountingPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/PolicyAccountingPage.tsx b/src/pages/workspace/accounting/PolicyAccountingPage.tsx index 6462d426851c..4040326b8b72 100644 --- a/src/pages/workspace/accounting/PolicyAccountingPage.tsx +++ b/src/pages/workspace/accounting/PolicyAccountingPage.tsx @@ -114,7 +114,7 @@ function accountingIntegrationData( /> ), onImportPagePress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT.getRoute(policyID)), - onExportPagePress: () => {}, + onExportPagePress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_EXPORT.getRoute(policyID)), onAdvancedPagePress: () => {}, }; case CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT: @@ -129,7 +129,7 @@ function accountingIntegrationData( /> ), onImportPagePress: () => {}, - onExportPagePress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_EXPORT.getRoute(policyID)), + onExportPagePress: () => {}, onAdvancedPagePress: () => {}, }; default: From fae01d9c759f07d92d52a029dd3ac9820aa1e810 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Tue, 2 Jul 2024 06:00:10 +0530 Subject: [PATCH 12/19] fix: condition for tax --- src/libs/PolicyUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index e13d14b2321a..098ff526cf2e 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -536,7 +536,7 @@ function isSyncTaxEnabled(policy: Policy | undefined) { } const selectedSubsidiary = (subsidiaryList ?? []).find((subsidiary) => subsidiary.internalID === netSuiteConfg?.subsidiaryID); - return !!netSuiteConfg?.suiteTaxEnabled && !isUSASubsidiaryNetSuite(selectedSubsidiary?.country); + return !isUSASubsidiaryNetSuite(selectedSubsidiary?.country); } function canUseTaxNetSuite(canUseNetSuiteUSATax?: boolean, subsidiaryCountry?: string) { From 596ad36a7550f809ba964397e4ce820c4756a2d9 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Tue, 2 Jul 2024 06:24:35 +0530 Subject: [PATCH 13/19] refactor: update method --- src/libs/PolicyUtils.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 098ff526cf2e..492234f70464 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -528,7 +528,7 @@ function getNetSuiteTaxAccountOptions(policy: Policy | undefined, subsidiaryCoun })); } -function isSyncTaxEnabled(policy: Policy | undefined) { +function isSyncTaxEnabled(policy: Policy | undefined): boolean { const netSuiteConfg = policy?.connections?.netsuite?.options?.config; const {subsidiaryList} = policy?.connections?.netsuite?.options?.data ?? {}; if (!netSuiteConfg || !subsidiaryList) { @@ -536,7 +536,7 @@ function isSyncTaxEnabled(policy: Policy | undefined) { } const selectedSubsidiary = (subsidiaryList ?? []).find((subsidiary) => subsidiary.internalID === netSuiteConfg?.subsidiaryID); - return !isUSASubsidiaryNetSuite(selectedSubsidiary?.country); + return !!selectedSubsidiary?.country && CONST.NETSUITE_TAX_COUNTRIES.includes(selectedSubsidiary?.country); } function canUseTaxNetSuite(canUseNetSuiteUSATax?: boolean, subsidiaryCountry?: string) { @@ -547,10 +547,6 @@ function canUseProvincialTaxNetSuite(subsidiaryCountry?: string) { return subsidiaryCountry === '_canada'; } -function isUSASubsidiaryNetSuite(subsidiaryCountry?: string) { - return subsidiaryCountry === '_unitedStates'; -} - function getIntegrationLastSuccessfulDate(connection?: Connections[keyof Connections]) { if (!connection) { return undefined; From 545e77cc091d24af5d6f507fee27f53eea3504b4 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Tue, 2 Jul 2024 06:49:16 +0530 Subject: [PATCH 14/19] feat: added spanish translations --- src/languages/es.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index 6a055a337515..59f34a3fc018 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2325,19 +2325,19 @@ export default { noSubsidiariesFound: 'No se ha encontrado subsidiarias', noSubsidiariesFoundDescription: 'Añade la subsidiaria en NetSuite y sincroniza de nuevo la conexión.', import: { - expenseCategories: `Expense categories`, - expenseCategoriesDescription: `NetSuite expense categories import into Expensify as categories.`, + expenseCategories: 'Categorías de gastos', + expenseCategoriesDescription: 'Las categorías de gastos de NetSuite se importan a Expensify como categorías.', importFields: { - departments: 'Departments', - classes: 'Classes', - locations: 'Locations', - customers: 'Customers', - jobs: 'Projects(jobs)', + departments: 'Departamentos', + classes: 'Clases', + locations: 'Ubicaciones', + customers: 'Clientes', + jobs: 'Proyectos (trabajos)', }, - importTaxDescription: 'Import tax groups from NetSuite', + importTaxDescription: 'Importar grupos de impuestos desde NetSuite', importCustomFields: { - customSegments: 'Custom segments/records', - customLists: 'Custom lists', + customSegments: 'Segmentos/registros personalizado', + customLists: 'Listas personalizado', }, }, }, From 38db1b130397e8b30f5028dd2a5d9e0bba05e720 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Tue, 2 Jul 2024 19:38:33 +0530 Subject: [PATCH 15/19] refactor: apply feedback --- src/CONST.ts | 4 +++- src/ROUTES.ts | 8 ++++---- .../accounting/netsuite/import/NetSuiteImportPage.tsx | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index a52716ad6f63..63e9dd791f2c 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1370,7 +1370,9 @@ const CONST = { EXPORT_TO_NEXT_OPEN_PERIOD: 'exportToNextOpenPeriod', IMPORT_FIELDS: ['departments', 'classes', 'locations', 'customers', 'jobs'], IMPORT_CUSTOM_FIELDS: ['customSegments', 'customLists'], - SYNC_TAX: 'syncTax', + SYNC_OPTIONS: { + SYNC_TAX: 'syncTax', + }, }, NETSUITE_EXPORT_DATE: { diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 7b83998fb192..06acec538c22 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -932,6 +932,10 @@ const ROUTES = { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/import/taxes', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/import/taxes` as const, }, + RESTRICTED_ACTION: { + route: 'restricted-action/workspace/:policyID', + getRoute: (policyID: string) => `restricted-action/workspace/${policyID}` as const, + }, POLICY_ACCOUNTING_NETSUITE_SUBSIDIARY_SELECTOR: { route: 'settings/workspaces/:policyID/accounting/net-suite/subsidiary-selector', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/net-suite/subsidiary-selector` as const, @@ -940,10 +944,6 @@ const ROUTES = { route: 'settings/workspaces/:policyID/accounting/netsuite/import', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/netsuite/import` as const, }, - RESTRICTED_ACTION: { - route: 'restricted-action/workspace/:policyID', - getRoute: (policyID: string) => `restricted-action/workspace/${policyID}` as const, - }, POLICY_ACCOUNTING_NETSUITE_EXPORT: { route: 'settings/workspaces/:policyID/connections/netsuite/export/', getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/netsuite/export/` as const, diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx index 64712ee2ce88..1f8da702487b 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx @@ -79,8 +79,8 @@ function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { onToggle={(isEnabled: boolean) => { updateNetSuiteSyncTaxConfiguration(policyID, isEnabled); }} - errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_TAX)} - onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_TAX)} + errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.SYNC_TAX)} + onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.SYNC_TAX)} /> )} From fa2d846bb1cdc57b06f8fa6a2d9f6cdf5834e265 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Tue, 2 Jul 2024 19:39:35 +0530 Subject: [PATCH 16/19] docs: added todo --- src/libs/actions/connections/NetSuiteCommands.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libs/actions/connections/NetSuiteCommands.ts b/src/libs/actions/connections/NetSuiteCommands.ts index 1f35d19a313e..4a8c405cd476 100644 --- a/src/libs/actions/connections/NetSuiteCommands.ts +++ b/src/libs/actions/connections/NetSuiteCommands.ts @@ -191,6 +191,7 @@ function updateNetSuiteSyncTaxConfiguration(policyID: string, isSyncTaxEnabled: syncOptions: { syncTax: isSyncTaxEnabled, }, + // TODO: Fixing in the future PR // pendingFields: { // syncTax: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, // }, @@ -216,6 +217,7 @@ function updateNetSuiteSyncTaxConfiguration(policyID: string, isSyncTaxEnabled: syncOptions: { syncTax: isSyncTaxEnabled, }, + // TODO: Fixing in the future PR // pendingFields: { // syncTax: null // }, From 3b530fdfe04c3f11ffb94f224e4e65d19836309f Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Wed, 3 Jul 2024 00:41:57 +0530 Subject: [PATCH 17/19] feat: pr comments --- src/ROUTES.ts | 4 ++-- src/SCREENS.ts | 4 ++-- src/languages/en.ts | 4 ++-- src/libs/actions/connections/NetSuiteCommands.ts | 4 ++-- .../accounting/netsuite/import/NetSuiteImportPage.tsx | 6 ++---- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 06acec538c22..1531727a4e82 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -937,8 +937,8 @@ const ROUTES = { getRoute: (policyID: string) => `restricted-action/workspace/${policyID}` as const, }, POLICY_ACCOUNTING_NETSUITE_SUBSIDIARY_SELECTOR: { - route: 'settings/workspaces/:policyID/accounting/net-suite/subsidiary-selector', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/net-suite/subsidiary-selector` as const, + route: 'settings/workspaces/:policyID/accounting/netsuite/subsidiary-selector', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/netsuite/subsidiary-selector` as const, }, POLICY_ACCOUNTING_NETSUITE_IMPORT: { route: 'settings/workspaces/:policyID/accounting/netsuite/import', diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 67b967ed9f73..8214c04cef75 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -272,8 +272,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', - NETSUITE_SUBSIDIARY_SELECTOR: 'Policy_Accounting_Net_Suite_Subsidiary_Selector', - NETSUITE_IMPORT: 'Policy_Accounting_Net_Suite_Import', + NETSUITE_SUBSIDIARY_SELECTOR: 'Policy_Accounting_NetSuite_Subsidiary_Selector', + NETSUITE_IMPORT: 'Policy_Accounting_NetSuite_Import', NETSUITE_EXPORT: 'Policy_Accounting_NetSuite_Export', NETSUITE_PREFERRED_EXPORTER_SELECT: 'Policy_Accounting_NetSuite_Preferred_Exporter_Select', NETSUITE_DATE_SELECT: 'Policy_Accounting_NetSuite_Date_Select', diff --git a/src/languages/en.ts b/src/languages/en.ts index e387d7de6a52..df2063b2b3e7 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2292,8 +2292,8 @@ export default { noSubsidiariesFound: 'No subsidiaries found', noSubsidiariesFoundDescription: 'Add the subsidiary in NetSuite and sync the connection again.', import: { - expenseCategories: `Expense categories`, - expenseCategoriesDescription: `NetSuite expense categories import into Expensify as categories.`, + expenseCategories: 'Expense categories', + expenseCategoriesDescription: 'NetSuite expense categories import into Expensify as categories.', importFields: { departments: 'Departments', classes: 'Classes', diff --git a/src/libs/actions/connections/NetSuiteCommands.ts b/src/libs/actions/connections/NetSuiteCommands.ts index 4a8c405cd476..4d1a6617c253 100644 --- a/src/libs/actions/connections/NetSuiteCommands.ts +++ b/src/libs/actions/connections/NetSuiteCommands.ts @@ -191,7 +191,7 @@ function updateNetSuiteSyncTaxConfiguration(policyID: string, isSyncTaxEnabled: syncOptions: { syncTax: isSyncTaxEnabled, }, - // TODO: Fixing in the future PR + // TODO: Fixing in the PR for Import Mapping https://github.com/Expensify/App/pull/44743 // pendingFields: { // syncTax: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, // }, @@ -217,7 +217,7 @@ function updateNetSuiteSyncTaxConfiguration(policyID: string, isSyncTaxEnabled: syncOptions: { syncTax: isSyncTaxEnabled, }, - // TODO: Fixing in the future PR + // TODO: Fixing in the PR for Import Mapping https://github.com/Expensify/App/pull/44743 // pendingFields: { // syncTax: null // }, diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx index 1f8da702487b..b27500155c09 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx @@ -20,8 +20,6 @@ function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { const policyID = policy?.id ?? '-1'; const config = policy?.connections?.netsuite?.options.config; - const importFields = CONST.NETSUITE_CONFIG.IMPORT_FIELDS; - const importCustomFields = CONST.NETSUITE_CONFIG.IMPORT_CUSTOM_FIELDS; return ( - {importFields.map((importField) => ( + {CONST.NETSUITE_CONFIG.IMPORT_FIELDS.map((importField) => ( - {importCustomFields.map((importField) => ( + {CONST.NETSUITE_CONFIG.IMPORT_CUSTOM_FIELDS.map((importField) => ( Date: Wed, 3 Jul 2024 00:46:03 +0530 Subject: [PATCH 18/19] refactor: remove can use suite tax --- src/libs/PolicyUtils.ts | 12 ------------ .../netsuite/import/NetSuiteImportPage.tsx | 10 +++++++--- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 492234f70464..24e123def45e 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -528,17 +528,6 @@ function getNetSuiteTaxAccountOptions(policy: Policy | undefined, subsidiaryCoun })); } -function isSyncTaxEnabled(policy: Policy | undefined): boolean { - const netSuiteConfg = policy?.connections?.netsuite?.options?.config; - const {subsidiaryList} = policy?.connections?.netsuite?.options?.data ?? {}; - if (!netSuiteConfg || !subsidiaryList) { - return false; - } - - const selectedSubsidiary = (subsidiaryList ?? []).find((subsidiary) => subsidiary.internalID === netSuiteConfg?.subsidiaryID); - return !!selectedSubsidiary?.country && CONST.NETSUITE_TAX_COUNTRIES.includes(selectedSubsidiary?.country); -} - function canUseTaxNetSuite(canUseNetSuiteUSATax?: boolean, subsidiaryCountry?: string) { return !!canUseNetSuiteUSATax || CONST.NETSUITE_TAX_COUNTRIES.includes(subsidiaryCountry ?? ''); } @@ -663,7 +652,6 @@ export { navigateWhenEnableFeature, getIntegrationLastSuccessfulDate, getCurrentConnectionName, - isSyncTaxEnabled, }; export type {MemberEmailsToAccountIDs}; diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx index b27500155c09..7cab222d7db1 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx @@ -1,13 +1,14 @@ -import React from 'react'; +import React, {useMemo} from 'react'; import {View} from 'react-native'; import ConnectionLayout from '@components/ConnectionLayout'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; import useLocalize from '@hooks/useLocalize'; +import usePermissions from '@hooks/usePermissions'; import useThemeStyles from '@hooks/useThemeStyles'; import {updateNetSuiteSyncTaxConfiguration} from '@libs/actions/connections/NetSuiteCommands'; import * as ErrorUtils from '@libs/ErrorUtils'; -import {isSyncTaxEnabled} from '@libs/PolicyUtils'; +import {canUseTaxNetSuite} from '@libs/PolicyUtils'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; @@ -17,9 +18,12 @@ import CONST from '@src/CONST'; function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); + const {canUseNetSuiteUSATax} = usePermissions(); const policyID = policy?.id ?? '-1'; const config = policy?.connections?.netsuite?.options.config; + const {subsidiaryList} = policy?.connections?.netsuite?.options?.data ?? {}; + const selectedSubsidiary = useMemo(() => (subsidiaryList ?? []).find((subsidiary) => subsidiary.internalID === config?.subsidiaryID), [subsidiaryList, config?.subsidiaryID]); return ( - {isSyncTaxEnabled(policy) && ( + {canUseTaxNetSuite(canUseNetSuiteUSATax, selectedSubsidiary) && ( Date: Wed, 3 Jul 2024 00:50:00 +0530 Subject: [PATCH 19/19] fix: condition --- .../workspace/accounting/netsuite/import/NetSuiteImportPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx index 7cab222d7db1..8c9e4bbf947f 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx @@ -70,7 +70,7 @@ function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { ))} - {canUseTaxNetSuite(canUseNetSuiteUSATax, selectedSubsidiary) && ( + {canUseTaxNetSuite(canUseNetSuiteUSATax, selectedSubsidiary?.country) && (