Finanzen: Liquiditaetsvorschau, Abo-Kuendigung: cancelAt allein massgeblich, cancelAtPeriodEnd ohne cancelAt keine Verlaengerung

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Sonnet 5.5 committed 2026-10-01 15:42:06 +00:00
1 parent 9361000a70
commit 34dfe181e4
2 files changed
+30 -6

No files matched your search

+4 -2
View File
@@ -146,12 +146,14 @@ export function buildForecast({
if (!isCents(subscription.priceAmount) || subscription.priceAmount <= 0) continue
const periodEnd = berlinDayOf(subscription.currentPeriodEnd)
if (!periodEnd) continue
// Kuendigung: Ein gesetztes cancelAt gilt allein (es kann mehrere Perioden voraus liegen, z.B. Mindestlaufzeit);
// cancelAtPeriodEnd allein heisst: Stripe bucht zum Periodenende nichts mehr ab, also gar keine Verlaengerung.
const cancelAt = berlinDayOf(subscription.cancelAt)
if (!cancelAt && subscription.cancelAtPeriodEnd) continue
for (const renewal of recurring(periodEnd, 1)) {
const payoutDate = addDays(renewal, PAYOUT_DELAY_DAYS)
if (payoutDate > end) break
if (cancelAt && renewal >= cancelAt) break // gekuendigt: ab dem Kuendigungstag keine Verlaengerung mehr
if (subscription.cancelAtPeriodEnd && renewal > periodEnd) break // zum Periodenende gekuendigt: nur die laufende Periode
if (cancelAt && renewal >= cancelAt) break // nur Verlaengerungen vor dem Kuendigungstag
if (payoutDate >= today) add(payoutDate, 'Abo-Verlängerung', subscription.priceAmount, ERWARTET)
}
}