Skip to content

Commit

Permalink
fix: correct last synced time
Browse files Browse the repository at this point in the history
  • Loading branch information
daledah committed Jul 30, 2024
1 parent df69c80 commit 4cb4f21
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
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(
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

0 comments on commit 4cb4f21

Please sign in to comment.