Hub 2.0 step 7: dashboard per product, revenue, linked products

Dashboard: monthly recurring revenue after discounts, overdue invoices,
per-product installs, latest version, behind, critical and licences.
Install page: the church's other products and whether they're listed to
this site.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-05 09:03:39 +02:00
co-authored by Claude Opus 5.5
parent 255ac6ae6e
commit e697564ff5
6 changed files with 125 additions and 8 deletions
+20
View File
@@ -371,3 +371,23 @@ describe('the church\'s address (one per church, never discounted)', () => {
expect(empty).toBe(true);
});
});
describe('monthly recurring revenue (dashboard)', () => {
const { monthlyRecurringCents } = require('../src/utils/billing/compute');
const now = new Date('2026-11-20T10:00:00Z');
test('a full month of each product charged now, after founding and bundle, plus add-ons', () => {
// Founding: 360 + 64 = R424, less 15% = R360.40, plus a Cross Code address R10.
expect(monthlyRecurringCents(customer({ founding: true, addressType: 'crosscode' }), [events(), website(), accounts()], now)).toBe(37040);
});
test('days owed from before a period aren\'t recurring; a product not charged yet doesn\'t count', () => {
expect(monthlyRecurringCents(customer(), [events(), app({ billedFrom: day('2026-11-10'), billedUntil: null })], now)).toBe(Math.round((55000 + 9900) * 0.85));
expect(monthlyRecurringCents(customer(), [events(), app({ billedFrom: day('2026-12-15'), billedUntil: null })], now)).toBe(55000);
});
test('yearly is a twelfth of the year\'s invoice; not billed is 0', () => {
expect(monthlyRecurringCents(customer({ billingCycle: 'yearly' }), [events()], now)).toBe(Math.round((55000 * 10) / 12));
expect(monthlyRecurringCents(customer({ billingCycle: 'none' }), [events()], now)).toBe(0);
});
});