Merge pull request #23462 from overleaf/ls-update-pricing-logic-for-small-educational-plans

Update pricing logic for small educational plans

GitOrigin-RevId: 0051f238ce50b2067b7dc75d08f55dc1c7ac3502
This commit is contained in:
Liangjun Song
2025-02-10 09:05:11 +00:00
committed by Copybot
parent 64e8d2b8b3
commit eb5417fad5
2 changed files with 83 additions and 2 deletions
@@ -143,8 +143,12 @@ async function _addSeatsSubscriptionChange(userId, adding) {
.additional_license_legacy_price_in_cents
if (
planPriceInCents / 100 > recurlySubscription.planPrice &&
legacyUnitPriceInCents > 0
_shouldUseLegacyPricing(
recurlySubscription.planPrice,
planPriceInCents / 100,
usage,
size
)
) {
unitPrice = legacyUnitPriceInCents / 100
}
@@ -163,6 +167,23 @@ async function _addSeatsSubscriptionChange(userId, adding) {
}
}
function _shouldUseLegacyPricing(
actualPlanPrice,
currentPlanPrice,
usage,
size
) {
// For small educational groups (5 or fewer members)
// 2025 pricing is cheaper than legacy pricing
if (size <= 5 && usage === 'educational') {
return currentPlanPrice < actualPlanPrice
}
// For all other scenarios
// 2025 pricing is more expensive than legacy pricing
return currentPlanPrice > actualPlanPrice
}
async function previewAddSeatsSubscriptionChange(userId, adding) {
const { changeRequest, currentAddonQuantity } =
await _addSeatsSubscriptionChange(userId, adding)