Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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