Skip to content

Commit

Permalink
Merge pull request #44064 from Expensify/yuwen-netSuiteBeta
Browse files Browse the repository at this point in the history
Add handling of the NetSuite beta in NewDot
  • Loading branch information
dangrous authored Jun 20, 2024
2 parents d721e2a + 9b8cf91 commit b90ac12
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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',
Expand Down
5 changes: 5 additions & 0 deletions src/libs/Permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ function canUseXeroIntegration(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.XERO_ON_NEW_EXPENSIFY) || canUseAllBetas(betas);
}

function canUseNetSuiteIntegration(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.NETSUITE_ON_NEW_EXPENSIFY) || canUseAllBetas(betas);
}

function canUseReportFieldsFeature(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.REPORT_FIELDS_FEATURE) || canUseAllBetas(betas);
}
Expand All @@ -71,5 +75,6 @@ export default {
canUseSpotnanaTravel,
canUseAccountingIntegrations,
canUseXeroIntegration,
canUseNetSuiteIntegration,
canUseReportFieldsFeature,
};
5 changes: 5 additions & 0 deletions src/libs/actions/connections/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ function updateManyPolicyConnectionConfigs<TConnectionName extends ConnectionNam
}

function hasSynchronizationError(policy: OnyxEntry<Policy>, 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;
}

Expand Down
6 changes: 4 additions & 2 deletions src/pages/workspace/accounting/PolicyAccountingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<AnchorPosition>({horizontal: 0, vertical: 0});
const [isDisconnectModalOpen, setIsDisconnectModalOpen] = useState(false);
Expand All @@ -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;
Expand Down

0 comments on commit b90ac12

Please sign in to comment.