-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[#Wave-Control: Add NetSuite] Reuse Existing Connection for NetSuite and Sage Intacct #45375
Changes from all commits
34c1417
fdb4d71
0ed5def
42ef683
70636fb
f639c6b
26332b1
c1e4a59
03a3bb9
4be452d
5853fce
609e1b9
670823e
c3b1ff2
46d367d
95ab3d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import type {ConnectionName} from '@src/types/onyx/Policy'; | ||
|
||
type CopyExistingPolicyConnectionParams = { | ||
policyID: string; | ||
targetPolicyID: string; | ||
connectionName: string; | ||
connectionName: ConnectionName; | ||
}; | ||
|
||
export default CopyExistingPolicyConnectionParams; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3075,6 +3075,10 @@ function getAdminPoliciesConnectedToSageIntacct(): Policy[] { | |
return Object.values(allPolicies ?? {}).filter<Policy>((policy): policy is Policy => !!policy && policy.role === CONST.POLICY.ROLE.ADMIN && !!policy?.connections?.intacct); | ||
} | ||
|
||
function getAdminPoliciesConnectedToNetSuite(): Policy[] { | ||
return Object.values(allPolicies ?? {}).filter<Policy>((policy): policy is Policy => !!policy && policy.role === CONST.POLICY.ROLE.ADMIN && !!policy?.connections?.netsuite); | ||
} | ||
Comment on lines
+3078
to
+3080
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NAB: Instead of a method for each integration we could do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought so. Will try to take care of it in any future PR. |
||
|
||
export { | ||
leaveWorkspace, | ||
addBillingCardAndRequestPolicyOwnerChange, | ||
|
@@ -3144,6 +3148,7 @@ export { | |
upgradeToCorporate, | ||
openPolicyExpensifyCardsPage, | ||
requestExpensifyCardLimitIncrease, | ||
getAdminPoliciesConnectedToNetSuite, | ||
getAdminPoliciesConnectedToSageIntacct, | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -269,4 +269,39 @@ function hasSynchronizationError(policy: OnyxEntry<Policy>, connectionName: Poli | |
return !isSyncInProgress && policy?.connections?.[connectionName]?.lastSync?.isSuccessful === false; | ||
} | ||
|
||
export {removePolicyConnection, updatePolicyConnectionConfig, updateManyPolicyConnectionConfigs, hasSynchronizationError, syncConnection}; | ||
function copyExistingPolicyConnection(connectedPolicyID: string, targetPolicyID: string, connectionName: ConnectionName) { | ||
let stageInProgress; | ||
switch (connectionName) { | ||
case CONST.POLICY.CONNECTIONS.NAME.NETSUITE: | ||
stageInProgress = CONST.POLICY.CONNECTIONS.SYNC_STAGE_NAME.NETSUITE_SYNC_CONNECTION; | ||
break; | ||
case CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT: | ||
stageInProgress = CONST.POLICY.CONNECTIONS.SYNC_STAGE_NAME.SAGE_INTACCT_SYNC_CHECK_CONNECTION; | ||
break; | ||
default: | ||
stageInProgress = null; | ||
} | ||
|
||
const optimisticData: OnyxUpdate[] = [ | ||
{ | ||
onyxMethod: Onyx.METHOD.MERGE, | ||
key: `${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${targetPolicyID}`, | ||
value: { | ||
stageInProgress, | ||
connectionName, | ||
timestamp: new Date().toISOString(), | ||
}, | ||
}, | ||
]; | ||
API.write( | ||
WRITE_COMMANDS.COPY_EXISTING_POLICY_CONNECTION, | ||
{ | ||
policyID: connectedPolicyID, | ||
targetPolicyID, | ||
connectionName, | ||
}, | ||
{optimisticData}, | ||
); | ||
} | ||
|
||
export {removePolicyConnection, updatePolicyConnectionConfig, updateManyPolicyConnectionConfigs, hasSynchronizationError, syncConnection, copyExistingPolicyConnection}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NAB: time to put these on individual lines I'd say There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did and the prettier put this back in one line. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice