Hub 2.0 step 1: products foundation
- Product enum (events, accounts, website, app) on Licence and Install, Install.publicKey; existing rows are events - One open licence per product per customer: partial unique index, with a migration guard that names customers with duplicates (npm run check:hub2 lists them beforehand) - Licence keys per product (CEH-, CCA-, CCW-, CCP-); free Accounts licence created with the first other product licence - Protocol v1 registers Events licences only (409 WRONG_PRODUCT); only Events licences can be invoiced until billing per customer - Cross Code Hub in the UI, emails and PDFs - @crosscode/contracts 1.0.0 vendored (backend/vendor) - Steps merge into release/2.0, not main (plan updated) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -21,6 +21,7 @@ const pdf = require('./pdf');
|
||||
const { layout, sendBillingEmail } = require('./email');
|
||||
const { ymd, day, today, saHour, addDays, longDate, periodLabel, money } = require('./dates');
|
||||
const { planPrice, tierNamed } = require('./tiers');
|
||||
const { BILLABLE } = require('../products');
|
||||
|
||||
const bad = (message, status = 400) => Object.assign(new Error(message), { status });
|
||||
const hubLink = p => `${(process.env.FRONTEND_URL || '').replace(/\/$/, '')}${p}`;
|
||||
@@ -97,7 +98,7 @@ async function createDueDrafts(now, settings) {
|
||||
const days = parseInt(settings.billing_draft_days, 10) || 14;
|
||||
const horizon = addDays(today(now), days);
|
||||
const licences = await prisma.licence.findMany({
|
||||
where: { status: 'active', billingCycle: { not: 'none' }, nextInvoiceDate: { lte: horizon } },
|
||||
where: { status: 'active', product: { in: BILLABLE }, billingCycle: { not: 'none' }, nextInvoiceDate: { lte: horizon } },
|
||||
select: { id: true },
|
||||
});
|
||||
let made = 0;
|
||||
|
||||
Reference in New Issue
Block a user