Hub 2.0 step 5: the church's address

Own domain R0, Cross Code address R10, domain included R25 (custom price
for other endings), once per invoice and never discounted; renewal date
with a reminder 30 days before, once per renewal, and Renewed to move it on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-04 16:24:10 +02:00
co-authored by Claude Opus 5.5
parent fff1c6f4ef
commit fbbf72dcd8
9 changed files with 229 additions and 11 deletions
+24
View File
@@ -347,3 +347,27 @@ describe('payments and statements', () => {
expect(later.closingCents).toBe(90000);
});
});
describe('the church\'s address (one per church, never discounted)', () => {
test('own domain: nothing to charge', () => {
const { invoice } = draft(customer({ addressType: 'own_domain', domain: 'hope.co.za' }), [events()]);
expect(invoice.lines.some(l => /domain|address/i.test(l.description))).toBe(false);
});
test('Cross Code address R10 and domain included R25 a month, after the bundle, not discounted', () => {
const { invoice } = draft(customer({ founding: true, addressType: 'crosscode', domain: 'hope.crosscode.co.za' }), [events(), website()]);
expect(invoice.lines.at(-1)).toEqual({ description: 'Cross Code address (hope.crosscode.co.za), December 2026', quantity: 1, unitCents: 1000, amountCents: 1000 });
const { invoice: inc } = draft(customer({ addressType: 'included', domain: 'hope.co.za' }), [events()]);
expect(inc.lines.at(-1)).toMatchObject({ description: 'Domain included (hope.co.za), December 2026', amountCents: 2500 });
});
test('yearly: 12 months\' price; a custom price (e.g. a .com at cost) wins', () => {
const { invoice } = draft(customer({ billingCycle: 'yearly', reviewDate: day('2027-12-01'), addressType: 'included', domain: 'hope.church', addressCustomCents: 4500 }), [events()]);
expect(invoice.lines.at(-1)).toMatchObject({ description: 'Domain included (hope.church), 12 months', quantity: 12, unitCents: 4500, amountCents: 54000 });
});
test('a church with no product charged gets no invoice just for its address', () => {
const { empty } = draft(customer({ addressType: 'crosscode' }), [events({ billedFrom: null })]);
expect(empty).toBe(true);
});
});