mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-31 21:01:33 +02:00
22 lines
588 B
JavaScript
22 lines
588 B
JavaScript
/**
|
|
* If the user changes to a less expensive plan, we shouldn't apply the change immediately.
|
|
* This is to avoid unintended/artifical credits on users Recurly accounts.
|
|
*/
|
|
function shouldPlanChangeAtTermEnd(oldPlan, newPlan) {
|
|
return getPlanPriceInCents(oldPlan) > getPlanPriceInCents(newPlan)
|
|
}
|
|
|
|
/**
|
|
* Group plans have their price in dollars, but individual plans store the price in cents
|
|
*/
|
|
function getPlanPriceInCents(plan) {
|
|
if (plan.price_in_unit) {
|
|
return plan.price_in_unit * 100
|
|
}
|
|
return plan.price_in_cents
|
|
}
|
|
|
|
module.exports = {
|
|
shouldPlanChangeAtTermEnd,
|
|
}
|