mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-05 15:19:02 +02:00
4edf4b2d42
* Show Recurly's line items breakdown in subscription change preview * fix rounding, filter items that cancel each other out GitOrigin-RevId: 0f5d71b3917ce8a52ff36608a6ec6280fe7d38ce
47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
// @ts-check
|
|
// Initially, this functions lived in PaymentProviderEntities.js,
|
|
// but it was moved to this file to prevent circular dependency issue
|
|
|
|
const AI_ASSIST_STANDALONE_MONTHLY_PLAN_CODE = 'assistant'
|
|
const AI_ASSIST_STANDALONE_ANNUAL_PLAN_CODE = 'assistant-annual'
|
|
const AI_ADD_ON_CODE = 'assistant'
|
|
|
|
/**
|
|
* Returns whether the given plan code is a standalone AI plan
|
|
*
|
|
* @param {string | null | undefined} planCode
|
|
* @return {boolean}
|
|
*/
|
|
function isStandaloneAiAddOnPlanCode(planCode) {
|
|
return (
|
|
planCode === AI_ASSIST_STANDALONE_MONTHLY_PLAN_CODE ||
|
|
planCode === AI_ASSIST_STANDALONE_ANNUAL_PLAN_CODE
|
|
)
|
|
}
|
|
|
|
/**
|
|
* Returns whether subscription change will have have the ai bundle once the change is processed
|
|
*
|
|
* @param {Object} subscriptionChange The subscription change object coming from payment provider
|
|
* type should be PaymentProviderSubscriptionChange but if imported here, it creates a circular dependency
|
|
* TODO: fix this when moved to es modules
|
|
*
|
|
* @return {boolean}
|
|
*/
|
|
function subscriptionChangeIsAiAssistUpgrade(subscriptionChange) {
|
|
return Boolean(
|
|
isStandaloneAiAddOnPlanCode(subscriptionChange.nextPlanCode) ||
|
|
subscriptionChange.nextAddOns?.some(
|
|
addOn => addOn.code === AI_ADD_ON_CODE
|
|
)
|
|
)
|
|
}
|
|
|
|
module.exports = {
|
|
AI_ADD_ON_CODE,
|
|
AI_ASSIST_STANDALONE_MONTHLY_PLAN_CODE,
|
|
AI_ASSIST_STANDALONE_ANNUAL_PLAN_CODE,
|
|
isStandaloneAiAddOnPlanCode,
|
|
subscriptionChangeIsAiAssistUpgrade,
|
|
}
|