Skip to content

Commit

Permalink
Merge pull request Expensify#50766 from hungvu193/fix-qbo-sync-issue
Browse files Browse the repository at this point in the history
QBO: Fix connection missing
  • Loading branch information
yuwenmemon authored Oct 23, 2024
2 parents ba29224 + 1b1d03a commit 5e975f5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/libs/actions/connections/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,15 @@ function isConnectionInProgress(connectionSyncProgress: OnyxEntry<PolicyConnecti
return false;
}

const qboConnection = policy?.connections?.quickbooksOnline;

const lastSyncProgressDate = parseISO(connectionSyncProgress?.timestamp ?? '');
return (
!!connectionSyncProgress?.stageInProgress &&
(connectionSyncProgress.stageInProgress !== CONST.POLICY.CONNECTIONS.SYNC_STAGE_NAME.JOB_DONE || !policy?.connections?.[connectionSyncProgress.connectionName]) &&
isValid(lastSyncProgressDate) &&
differenceInMinutes(new Date(), lastSyncProgressDate) < CONST.POLICY.CONNECTIONS.SYNC_STAGE_TIMEOUT_MINUTES
(!!connectionSyncProgress?.stageInProgress &&
(connectionSyncProgress.stageInProgress !== CONST.POLICY.CONNECTIONS.SYNC_STAGE_NAME.JOB_DONE || !policy?.connections?.[connectionSyncProgress.connectionName]) &&
isValid(lastSyncProgressDate) &&
differenceInMinutes(new Date(), lastSyncProgressDate) < CONST.POLICY.CONNECTIONS.SYNC_STAGE_TIMEOUT_MINUTES) ||
(!!qboConnection && !qboConnection?.data && !!qboConnection?.config?.credentials)
);
}

Expand Down
23 changes: 23 additions & 0 deletions src/types/onyx/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,26 @@ type ConnectionLastSync = {
isConnected?: boolean;
};

/**
* Model of QBO credentials data.
*/
type QBOCredentials = {
/**
* The company ID that's connected from QBO.
*/
companyID: string;

/**
* The company name that's connected from QBO.
*/
companyName: string;

/**
* The current scope of QBO connection.
*/
scope: string;
};

/** Financial account (bank account, debit card, etc) */
type Account = {
/** GL code assigned to the financial account */
Expand Down Expand Up @@ -437,6 +457,9 @@ type QBOConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{

/** Collections of form field errors */
errorFields?: OnyxCommon.ErrorFields;

/** Credentials of the current QBO connection */
credentials: QBOCredentials;
}>;

/**
Expand Down

0 comments on commit 5e975f5

Please sign in to comment.