Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct last synced time #46480

Merged
merged 2 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion src/pages/workspace/accounting/PolicyAccountingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,10 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
const connectedIntegration = getConnectedIntegration(policy, accountingIntegrations) ?? connectionSyncProgress?.connectionName;

const policyID = policy?.id ?? '-1';
const successfulDate = getIntegrationLastSuccessfulDate(connectedIntegration ? policy?.connections?.[connectedIntegration] : undefined);
const successfulDate = getIntegrationLastSuccessfulDate(
daledah marked this conversation as resolved.
Show resolved Hide 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
Loading