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
19 changes: 16 additions & 3 deletions src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import type {
NetSuiteCustomSegment,
NetSuiteTaxAccount,
NetSuiteVendor,
PolicyConnectionSyncProgress,
PolicyFeatureName,
Rate,
Tenant,
Expand Down Expand Up @@ -746,14 +747,26 @@ function isNetSuiteCustomFieldPropertyEditable(customField: NetSuiteCustomList |
return fieldsAllowedToEdit.includes(fieldKey);
}

function getIntegrationLastSuccessfulDate(connection?: Connections[keyof Connections]) {
function getIntegrationLastSuccessfulDate(connection?: Connections[keyof Connections], connectionSyncProgress?: PolicyConnectionSyncProgress) {
let syncSuccessfulDate;
if (!connection) {
return undefined;
}
if ((connection as NetSuiteConnection)?.lastSyncDate) {
return (connection as NetSuiteConnection)?.lastSyncDate;
syncSuccessfulDate = (connection as NetSuiteConnection)?.lastSyncDate;
} else {
syncSuccessfulDate = (connection as ConnectionWithLastSyncData)?.lastSync?.successfulDate;
}
return (connection as ConnectionWithLastSyncData)?.lastSync?.successfulDate;

if (
connectionSyncProgress &&
connectionSyncProgress.stageInProgress === CONST.POLICY.CONNECTIONS.SYNC_STAGE_NAME.JOB_DONE &&
syncSuccessfulDate &&
connectionSyncProgress.timestamp > syncSuccessfulDate
) {
syncSuccessfulDate = connectionSyncProgress.timestamp;
}
return syncSuccessfulDate;
}

function getCurrentSageIntacctEntityName(policy?: Policy): string | undefined {
Expand Down
6 changes: 5 additions & 1 deletion src/pages/workspace/accounting/PolicyAccountingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,11 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
const connectedIntegration = getConnectedIntegration(policy, accountingIntegrations) ?? connectionSyncProgress?.connectionName;

const policyID = policy?.id ?? '-1';
const successfulDate = getIntegrationLastSuccessfulDate(connectedIntegration ? policy?.connections?.[connectedIntegration] : undefined);
// Get the last successful date of the integration. Then, if `connectionSyncProgress` is the same integration displayed and the state is 'jobDone', get the more recent update time of the two.
const successfulDate = getIntegrationLastSuccessfulDate(
Comment thread
daledah marked this conversation as resolved.
connectedIntegration ? policy?.connections?.[connectedIntegration] : undefined,
connectedIntegration === connectionSyncProgress?.connectionName ? connectionSyncProgress : undefined,
);

const tenants = useMemo(() => getXeroTenants(policy), [policy]);
const currentXeroOrganization = findCurrentXeroOrganization(tenants, policy?.connections?.xero?.config?.tenantID);
Expand Down