fix(display): cadence-aware contribution suffix across UI + admin dashboard

Add formatContribution helper in app/config/contributions.js and route
all member-facing and admin contribution displays through cadence-aware
expressions so annual members see /yr instead of /mo. Normalize annual
amounts to monthly equivalents in the admin dashboard revenue
aggregate now that contributionAmount is stored in cadence units.
This commit is contained in:
Jennie Robinson Faber 2026-05-23 15:47:10 +01:00
parent 5023fb14ad
commit 0dd68ff1aa
6 changed files with 29 additions and 12 deletions

View file

@ -16,10 +16,14 @@ export default defineEventHandler(async (event) => {
endDate: { $gte: now }
})
// Calculate monthly revenue from member contributions
const members = await Member.find({}, 'contributionAmount').lean()
// Calculate monthly revenue from member contributions.
// contributionAmount is stored in cadence units (monthly = $/mo, annual = $/yr),
// so normalize annual amounts to monthly equivalents before summing.
const members = await Member.find({}, 'contributionAmount billingCadence').lean()
const monthlyRevenue = members.reduce((total, member) => {
return total + (member.contributionAmount || 0)
const amt = member.contributionAmount || 0
const monthlyEquivalent = member.billingCadence === 'annual' ? amt / 12 : amt
return total + monthlyEquivalent
}, 0)
const pendingSlackInvites = await Member.countDocuments({ slackInvited: false })