- 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>
38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
/**
|
|
* The Cross Code products a church can have (Hub 2.0, ROADMAP-v3 §5). The same names as the
|
|
* `Product` enum in schema.prisma and `productSchema` in @crosscode/contracts.
|
|
*
|
|
* - A customer has at most one licence per product that isn't revoked (a partial unique index).
|
|
* - Accounts is free and comes with any other product: its licence is created with the first one.
|
|
*/
|
|
|
|
const PRODUCTS = ['events', 'accounts', 'website', 'app'];
|
|
|
|
const PRODUCT_NAMES = {
|
|
events: 'Cross Events',
|
|
accounts: 'Accounts',
|
|
website: 'Church Website',
|
|
app: 'Church App',
|
|
};
|
|
|
|
/** Licence key prefixes. CEH- (Cross Events Hub) predates 2.0 and stays for Events. */
|
|
const KEY_PREFIXES = {
|
|
events: 'CEH',
|
|
accounts: 'CCA',
|
|
website: 'CCW',
|
|
app: 'CCP',
|
|
};
|
|
|
|
/** The product a licence key is for, from its prefix, or null. */
|
|
function productOfKey(key) {
|
|
const prefix = String(key || '').slice(0, 3).toUpperCase();
|
|
return PRODUCTS.find(p => KEY_PREFIXES[p] === prefix) || null;
|
|
}
|
|
|
|
const isProduct = p => PRODUCTS.includes(p);
|
|
|
|
/** Products that are invoiced (Accounts is free and never invoiced). */
|
|
const BILLABLE = ['events', 'website', 'app'];
|
|
|
|
module.exports = { PRODUCTS, PRODUCT_NAMES, KEY_PREFIXES, BILLABLE, productOfKey, isProduct };
|