Abo: Mindestlaufzeit nur fuer Vertraege ab Bedingungen Version 3
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9b563482ff
commit
2bd166adf3
2 files changed
+17
-5
No files matched your search
@@ -200,7 +200,7 @@ function addMonths(date, months) {
|
||||
* - Wunschtermin: fruehestens zum berechneten Zeitpunkt, sonst zum Ende des Abrechnungsmonats,
|
||||
* in dem der Wunschtermin liegt
|
||||
*/
|
||||
export function computeCancellationDate({ serviceStart, receivedAt = new Date(), requestedDate = null, kind = 'ordentlich' }) {
|
||||
export function computeCancellationDate({ serviceStart, receivedAt = new Date(), requestedDate = null, kind = 'ordentlich', minTermMonths = config.abo.minTermMonths }) {
|
||||
const start = new Date(serviceStart)
|
||||
const boundary = (k) => addMonths(start, k)
|
||||
const firstBoundaryFrom = (minK, notBefore) => {
|
||||
@@ -208,7 +208,7 @@ export function computeCancellationDate({ serviceStart, receivedAt = new Date(),
|
||||
while (boundary(k) < notBefore) k += 1
|
||||
return k
|
||||
}
|
||||
const minTermK = config.abo.minTermMonths
|
||||
const minTermK = minTermMonths
|
||||
let k
|
||||
if (kind === 'geschaeftsaufgabe') {
|
||||
k = firstBoundaryFrom(1, addMonths(receivedAt, 1))
|
||||
@@ -220,6 +220,11 @@ export function computeCancellationDate({ serviceStart, receivedAt = new Date(),
|
||||
return { effectiveAt: boundary(k), minTermEnd: boundary(minTermK), serviceStart: start }
|
||||
}
|
||||
|
||||
/** Es gilt die Mindestlaufzeit der Bedingungen, denen der Kunde zugestimmt hat (erst ab Version 3). */
|
||||
export function minTermMonthsFor(termsVersion) {
|
||||
return ['2026-09-25', '2026-09-25-v2'].includes(termsVersion) ? 0 : config.abo.minTermMonths
|
||||
}
|
||||
|
||||
export function serviceStartOf(sub) {
|
||||
return new Date(((sub.trial_end || sub.start_date) || 0) * 1000)
|
||||
}
|
||||
@@ -425,6 +430,7 @@ export async function cancelSubscriptionAt(subscriptionId, requestedDate = null,
|
||||
receivedAt,
|
||||
requestedDate,
|
||||
kind,
|
||||
minTermMonths: minTermMonthsFor(sub.metadata?.termsVersion),
|
||||
})
|
||||
const periodEnd = periodEndOf(sub)
|
||||
const effectiveUnix = Math.floor(effectiveAt.getTime() / 1000)
|
||||
|
||||
Reference in new issue
Block a user