mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-31 12:51:35 +02:00
This reverts commit fcca974a69217dc885c458543a82b4dcc338d98b. GitOrigin-RevId: cc7e2561a5f6b4866e5f69f4fb41ffb1bad07bb1
49 lines
1.2 KiB
JavaScript
49 lines
1.2 KiB
JavaScript
export function extractAccountMappingsFromSubscription(
|
|
subscription,
|
|
updatedSubscription
|
|
) {
|
|
const accountMappings = []
|
|
if (
|
|
updatedSubscription.salesforce_id ||
|
|
updatedSubscription.salesforce_id === ''
|
|
) {
|
|
if (subscription.salesforce_id !== updatedSubscription.salesforce_id) {
|
|
accountMappings.push(
|
|
generateSubscriptionToSalesforceMapping(
|
|
subscription.id,
|
|
updatedSubscription.salesforce_id
|
|
)
|
|
)
|
|
}
|
|
}
|
|
if (updatedSubscription.v1_id || updatedSubscription.v1_id === '') {
|
|
if (subscription.v1_id !== updatedSubscription.v1_id) {
|
|
accountMappings.push(
|
|
generateSubscriptionToV1Mapping(
|
|
subscription.id,
|
|
updatedSubscription.v1_id
|
|
)
|
|
)
|
|
}
|
|
}
|
|
return accountMappings
|
|
}
|
|
}
|
|
|
|
|
|
function generateSubscriptionToSalesforceMapping(subscriptionId, salesforceId) {
|
|
return {
|
|
source: 'salesforce',
|
|
sourceEntity: 'account',
|
|
sourceEntityId: salesforceId,
|
|
target: 'v2',
|
|
targetEntity: 'subscription',
|
|
targetEntityId: subscriptionId,
|
|
createdAt: new Date().toISOString(),
|
|
}
|
|
}
|
|
|
|
export default {
|
|
extractAccountMappingsFromSubscription,
|
|
}
|