diff --git a/src/CONST.ts b/src/CONST.ts index bff8ced87b5c..71ef5e26f7ae 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -363,6 +363,7 @@ const CONST = { SPOTNANA_TRAVEL: 'spotnanaTravel', ACCOUNTING_ON_NEW_EXPENSIFY: 'accountingOnNewExpensify', XERO_ON_NEW_EXPENSIFY: 'xeroOnNewExpensify', + NETSUITE_ON_NEW_EXPENSIFY: 'netsuiteOnNewExpensify', REPORT_FIELDS_FEATURE: 'reportFieldsFeature', }, BUTTON_STATES: { @@ -1799,6 +1800,7 @@ const CONST = { // Here we will add other connections names when we add support for them QBO: 'quickbooksOnline', XERO: 'xero', + NETSUITE: 'netsuite', }, SYNC_STAGE_NAME: { STARTING_IMPORT_QBO: 'startingImportQBO', diff --git a/src/libs/Permissions.ts b/src/libs/Permissions.ts index 56d366ef330d..7a9db9f4fbbd 100644 --- a/src/libs/Permissions.ts +++ b/src/libs/Permissions.ts @@ -48,6 +48,10 @@ function canUseXeroIntegration(betas: OnyxEntry): boolean { return !!betas?.includes(CONST.BETAS.XERO_ON_NEW_EXPENSIFY) || canUseAllBetas(betas); } +function canUseNetSuiteIntegration(betas: OnyxEntry): boolean { + return !!betas?.includes(CONST.BETAS.NETSUITE_ON_NEW_EXPENSIFY) || canUseAllBetas(betas); +} + function canUseReportFieldsFeature(betas: OnyxEntry): boolean { return !!betas?.includes(CONST.BETAS.REPORT_FIELDS_FEATURE) || canUseAllBetas(betas); } @@ -71,5 +75,6 @@ export default { canUseSpotnanaTravel, canUseAccountingIntegrations, canUseXeroIntegration, + canUseNetSuiteIntegration, canUseReportFieldsFeature, }; diff --git a/src/libs/actions/connections/index.ts b/src/libs/actions/connections/index.ts index 4770722aca21..d0c9fb762a4c 100644 --- a/src/libs/actions/connections/index.ts +++ b/src/libs/actions/connections/index.ts @@ -236,6 +236,11 @@ function updateManyPolicyConnectionConfigs, connectionName: PolicyConnectionName, isSyncInProgress: boolean): boolean { + // NetSuite does not use the conventional lastSync object, so we need to check for lastErrorSyncDate + if (connectionName === CONST.POLICY.CONNECTIONS.NAME.NETSUITE) { + return !isSyncInProgress && !!policy?.connections?.[CONST.POLICY.CONNECTIONS.NAME.NETSUITE].lastErrorSyncDate; + } + return !isSyncInProgress && policy?.connections?.[connectionName]?.lastSync?.isSuccessful === false; } diff --git a/src/pages/workspace/accounting/PolicyAccountingPage.tsx b/src/pages/workspace/accounting/PolicyAccountingPage.tsx index 78dc434b3d2c..f2e3744f92e4 100644 --- a/src/pages/workspace/accounting/PolicyAccountingPage.tsx +++ b/src/pages/workspace/accounting/PolicyAccountingPage.tsx @@ -110,7 +110,7 @@ function PolicyAccountingPage({policy, connectionSyncProgress}: PolicyAccounting const styles = useThemeStyles(); const {translate} = useLocalize(); const {isOffline} = useNetwork(); - const {canUseXeroIntegration} = usePermissions(); + const {canUseXeroIntegration, canUseNetSuiteIntegration} = usePermissions(); const {isSmallScreenWidth, windowWidth} = useWindowDimensions(); const [threeDotsMenuPosition, setThreeDotsMenuPosition] = useState({horizontal: 0, vertical: 0}); const [isDisconnectModalOpen, setIsDisconnectModalOpen] = useState(false); @@ -124,7 +124,9 @@ function PolicyAccountingPage({policy, connectionSyncProgress}: PolicyAccounting isValid(lastSyncProgressDate) && differenceInMinutes(new Date(), lastSyncProgressDate) < CONST.POLICY.CONNECTIONS.SYNC_STAGE_TIMEOUT_MINUTES; - const accountingIntegrations = Object.values(CONST.POLICY.CONNECTIONS.NAME).filter((name) => !(name === CONST.POLICY.CONNECTIONS.NAME.XERO && !canUseXeroIntegration)); + const accountingIntegrations = Object.values(CONST.POLICY.CONNECTIONS.NAME).filter( + (name) => !(name === CONST.POLICY.CONNECTIONS.NAME.XERO && !canUseXeroIntegration) && !(name === CONST.POLICY.CONNECTIONS.NAME.NETSUITE && !canUseNetSuiteIntegration), + ); const connectedIntegration = accountingIntegrations.find((integration) => !!policy?.connections?.[integration]) ?? connectionSyncProgress?.connectionName; const policyID = policy?.id ?? '-1'; const successfulDate = policy?.connections?.quickbooksOnline?.lastSync?.successfulDate;