mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
convert price_in_unit to price_in_cents
GitOrigin-RevId: bae030e9c90f8286d6e6550744849984fe81f63d
This commit is contained in:
parent
3e70546e18
commit
bbac46156b
8 changed files with 327 additions and 331 deletions
|
@ -43,7 +43,7 @@ for (const [usage, planData] of Object.entries(groups)) {
|
|||
planCode
|
||||
)} - Group Account (${size} licenses) - ${capitalize(usage)}`,
|
||||
hideFromUsers: true,
|
||||
price_in_cents: groups[usage][planCode].USD[size].price_in_unit * 100,
|
||||
price_in_cents: groups[usage][planCode].USD[size].price_in_cents,
|
||||
annual: true,
|
||||
features: Settings.features[planCode],
|
||||
groupPlan: true,
|
||||
|
|
|
@ -3,10 +3,7 @@ const logger = require('@overleaf/logger')
|
|||
|
||||
function ensurePlansAreSetupCorrectly() {
|
||||
Settings.plans.forEach(plan => {
|
||||
if (
|
||||
typeof plan.price_in_unit !== 'number' &&
|
||||
typeof plan.price_in_cents !== 'number'
|
||||
) {
|
||||
if (typeof plan.price_in_cents !== 'number') {
|
||||
logger.fatal({ plan }, 'missing price on plan')
|
||||
process.exit(1)
|
||||
}
|
||||
|
@ -14,6 +11,10 @@ function ensurePlansAreSetupCorrectly() {
|
|||
logger.fatal({ plan }, 'unclear price attribute on plan')
|
||||
process.exit(1)
|
||||
}
|
||||
if (plan.price_in_unit) {
|
||||
logger.fatal({ plan }, 'deprecated price_in_unit attribute on plan')
|
||||
process.exit(1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -3,17 +3,7 @@
|
|||
* 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
|
||||
return oldPlan.price_in_cents > newPlan.price_in_cents
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -22,10 +22,12 @@ function updateGroupPlanView() {
|
|||
const modalEl = document.querySelector('[data-ol-group-plan-modal]')
|
||||
const { planCode, size, currency, usage } = getFormValues()
|
||||
|
||||
const priceInUnit = groupPlans[usage][planCode][currency][size].price_in_unit
|
||||
const priceInCents =
|
||||
groupPlans[usage][planCode][currency][size].price_in_cents
|
||||
const priceInUnit = (priceInCents / 100).toFixed()
|
||||
const currencySymbol = currencySymbols[currency]
|
||||
const displayPrice = `${currencySymbol}${priceInUnit}`
|
||||
const perUserPrice = parseFloat((priceInUnit / size).toFixed(2))
|
||||
const perUserPrice = parseFloat((priceInCents / 100 / size).toFixed(2))
|
||||
|
||||
modalEl.querySelectorAll('[data-ol-group-plan-plan-code]').forEach(el => {
|
||||
el.hidden = el.getAttribute('data-ol-group-plan-plan-code') !== planCode
|
||||
|
|
|
@ -161,8 +161,9 @@ App.controller(
|
|||
let perUserDisplayPricePlaceholder = '...'
|
||||
const currencySymbol = $scope.options.currencySymbols[currency]
|
||||
if (taxRate === 0) {
|
||||
const basePriceInUnit =
|
||||
$scope.groupPlans[usage][plan_code][currency][size].price_in_unit
|
||||
const basePriceInCents =
|
||||
$scope.groupPlans[usage][plan_code][currency][size].price_in_cents
|
||||
const basePriceInUnit = (basePriceInCents / 100).toFixed()
|
||||
recurlyPricePlaceholder.total = `${currencySymbol}${basePriceInUnit}`
|
||||
perUserDisplayPricePlaceholder = getPricePerUser(
|
||||
basePriceInUnit,
|
||||
|
|
|
@ -23,7 +23,9 @@ async function getRecurlyGroupPrices() {
|
|||
prices[usage] = prices[usage] || {}
|
||||
prices[usage][type] = prices[usage][type] || {}
|
||||
prices[usage][type][currency] = prices[usage][type][currency] || {}
|
||||
prices[usage][type][currency][size] = { price_in_unit: unitAmount }
|
||||
prices[usage][type][currency][size] = {
|
||||
price_in_cents: unitAmount * 100,
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,12 +18,12 @@ const plans = {
|
|||
},
|
||||
expensiveGroup: {
|
||||
plancode: 'group_expensive',
|
||||
price_in_unit: 495,
|
||||
price_in_cents: 49500,
|
||||
groupPlan: true,
|
||||
},
|
||||
cheapGroup: {
|
||||
plancode: 'group_cheap',
|
||||
price_in_unit: 10,
|
||||
price_in_cents: 1000,
|
||||
groupPlan: true,
|
||||
},
|
||||
bad: {},
|
||||
|
|
Loading…
Reference in a new issue