diff --git a/src/lib/legal.js b/src/lib/legal.js index e305aed..0315744 100644 --- a/src/lib/legal.js +++ b/src/lib/legal.js @@ -50,11 +50,14 @@ export function nextCancellationDate(contract, today) { if (isSet(contract.cancelledAt)) { return { state: 'cancelled', periodEnd: contract.endsAt || null, noticeBy: null } } + // Jederzeit kuendbar braucht keinen Beginn (z. B. Stripe, Cloud-Server) + if (isSet(contract.termMonths) && Number(contract.termMonths) === 0) { + return { state: 'anytime', periodEnd: null, noticeBy: null } + } if (!isSet(contract.startDate) || !isSet(contract.termMonths)) { return { state: 'incomplete', periodEnd: null, noticeBy: null } } const term = Number(contract.termMonths) - if (term === 0) return { state: 'anytime', periodEnd: null, noticeBy: null } const renewal = Number(contract.renewalMonths) || 0 let periodEnd = addMonthsClamped(contract.startDate, term) diff --git a/tests/legal.test.mjs b/tests/legal.test.mjs index 7183a23..5eaed9f 100644 --- a/tests/legal.test.mjs +++ b/tests/legal.test.mjs @@ -145,3 +145,7 @@ test('Verlaengerungen ab dem 31. driften nicht auf den 28.', () => { assert.equal(r.periodEnd, '2025-04-30') assert.equal(r.noticeBy, '2025-04-29') }) + +test('jederzeit kuendbar braucht kein Beginn-Datum', () => { + assert.equal(nextCancellationDate({ termMonths: 0 }, '2026-09-30').state, 'anytime') +})