Hub 2.0 step 4: billing per customer
- One invoice per customer per period for all its products; the schedule moves from Licence to Customer (migration copies it, so billing carries on unchanged); licences get billedFrom / billedUntil - Website (R99, 5 GB) and App (on active members) prices next to the Events tiers; founding prices per product, then bundles (15% two, 25% three); extra website storage R20 per 5 GB, never discounted - A product added to a billed customer starts after its free month; days before its first full period are prorated, never charged twice - Annual review per product (Events income, App members), one notice of licence change per product; invoices, PDFs and emails name products - Customer page: schedule, per-product billing, next-invoice preview - Invoices from before 2.0 kept as they were (still recalculable) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -166,7 +166,9 @@ router.post('/customers/:id/licences', wrap(async (req, res) => {
|
||||
if (!customer) throw bad('Customer not found', 404);
|
||||
const product = req.body?.product ?? 'events';
|
||||
if (!isProduct(product)) throw bad('Product must be events, accounts, website or app.');
|
||||
const { licence, accounts } = await generateLicence(prisma, { customerId: customer.id, product, data: licenceData(req.body) });
|
||||
// A new Website licence is on its one plan, an App licence on the first tier (the review moves it).
|
||||
const data = { ...(product === 'website' ? { plan: 'Website' } : product === 'app' ? { plan: 'Mustard Seed' } : {}), ...licenceData(req.body) };
|
||||
const { licence, accounts } = await generateLicence(prisma, { customerId: customer.id, product, data });
|
||||
await audit(req, 'licence_generated', licence.id, { customer: customer.name, product, expiresAt: licence.expiresAt });
|
||||
if (accounts) await audit(req, 'licence_generated', accounts.id, { customer: customer.name, product: 'accounts', automatic: true });
|
||||
res.status(201).json({ ...licence, accountsLicence: accounts });
|
||||
|
||||
Reference in New Issue
Block a user