Hub 2.21.0: install the Church Website; Website storage bought in steps

- New install offers the Church Website: Accounts first when the church has
  none, at accounts.<its address> (www. dropped); the FastPanel email sends a
  www. site's bare domain to www. with a 301.
- Licence.extraStorageSteps (migration): the token sends a Website its limit
  (5 GB + steps, limits.storageBytes, contracts 1.17.0); invoices bill the
  steps bought instead of the storage reported. Edit popup field 0-99.
- A Website/App licence starts on its plan however it's made (New install too).
- Vendored @crosscode/contracts 1.17.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 00:03:21 +02:00
co-authored by Claude Opus 5.5
parent 6f8242064f
commit c6f734ab20
21 changed files with 235 additions and 36 deletions
+17 -4
View File
@@ -3,7 +3,7 @@ jest.mock('../src/config/db', () => ({}));
const fs = require('fs');
const path = require('path');
const { hub } = require('@crosscode/contracts');
const { TIERS, WEBSITE_PLANS, APP_TIERS, tierForBand, appTierForBand, planPrice, extraStorageBlocks } = require('../src/utils/billing/tiers');
const { TIERS, WEBSITE_PLANS, APP_TIERS, tierForBand, appTierForBand, planPrice, extraStorageBlocks, storageLimitBytes } = require('../src/utils/billing/tiers');
const { day, ymd, addMonths, addDays, today, saHour, periodLabel, money } = require('../src/utils/billing/dates');
const { draftCustomerInvoice, customerInvoiceLines, planChangesOf, cleanLines, totals, invoiceState, statement, recipientFor } = require('../src/utils/billing/compute');
@@ -78,6 +78,14 @@ describe('tiers', () => {
expect(extraStorageBlocks({ usedBytes: 11 * GB })).toBe(2);
expect(extraStorageBlocks(null)).toBe(0);
});
test("2.21.0: a Website's storage limit is 5 GB plus the steps bought", () => {
expect(storageLimitBytes(0)).toBe(5 * GB);
expect(storageLimitBytes(2)).toBe(15 * GB);
expect(storageLimitBytes(undefined)).toBe(5 * GB);
expect(storageLimitBytes(-1)).toBe(5 * GB);
expect(storageLimitBytes(1000)).toBe(500 * GB);
});
});
describe('dates', () => {
@@ -214,18 +222,23 @@ describe('drafting an invoice (several products, Hub 2.0)', () => {
expect(invoice.lines.some(l => /Bundle|Accounts/.test(l.description))).toBe(false);
});
test('extra website storage: R20 per 5 GB a month, never discounted', () => {
const { invoice } = draft(customer({ founding: true }), [events(), website({ install: { product: 'website', stats: { storage: { usedBytes: 12 * GB, includedBytes: 5 * GB } } } })]);
test('extra website storage: R20 per 5 GB bought a month, never discounted', () => {
const { invoice } = draft(customer({ founding: true }), [events(), website({ extraStorageSteps: 2, install: { product: 'website', stats: { storage: { usedBytes: 7 * GB, includedBytes: 15 * GB } } } })]);
expect(invoice.lines.at(-1)).toEqual({ description: 'Extra website storage: 2 × 5 GB, December 2026', quantity: 2, unitCents: 2000, amountCents: 4000 });
// The bundle comes off the products only: (360 + 64) × 15% = R63.60.
expect(invoice.lines.find(l => /Bundle/.test(l.description)).amountCents).toBe(-6360);
});
test('yearly: add-ons are 12 months\' price (decision 2), products 10', () => {
const { invoice } = draft(customer({ billingCycle: 'yearly', reviewDate: day('2027-12-01') }), [website({ install: { product: 'website', stats: { storage: { usedBytes: 8 * GB } } } })]);
const { invoice } = draft(customer({ billingCycle: 'yearly', reviewDate: day('2027-12-01') }), [website({ extraStorageSteps: 1 })]);
expect(invoice.lines.map(l => [l.quantity, l.unitCents])).toEqual([[10, 9900], [12, 2000]]);
});
test('2.21.0: storage is billed on the steps bought, not on what the site reports using', () => {
const { invoice } = draft(customer(), [website({ install: { product: 'website', stats: { storage: { usedBytes: 12 * GB, includedBytes: 5 * GB } } } })]);
expect(invoice.lines.some(l => /storage/.test(l.description))).toBe(false);
});
test('the App is reviewed on its active members', () => {
const { invoice } = draft(customer({ nextInvoiceDate: day('2027-01-01') }), [app({ billedUntil: day('2026-12-31'), install: { product: 'app', stats: { activeMembers90d: '301–750' } } })]);
expect(invoice.planChange).toEqual([expect.objectContaining({ licenceId: 'l3', product: 'app', from: 'Mustard Seed', to: 'Congregation', toMonthlyCents: 39900, band: '301–750' })]);