Files
speckle-server/packages/server/modules/gatekeeper/services/subscriptions/calculateNewBillingCycleEnd.ts
T
Kristaps Fabians Geikins 4b06f42db7 chore(server): run TS files directly (no compilation) (#5134)
* sort of works

* type fixes

* added option to run old way too
2025-07-23 11:20:40 +02:00

22 lines
726 B
TypeScript

import type { WorkspaceSubscription } from '@/modules/gatekeeper/domain/billing'
import { throwUncoveredError } from '@speckle/shared'
export const calculateNewBillingCycleEnd = ({
workspaceSubscription
}: {
workspaceSubscription: WorkspaceSubscription
}): Date => {
const newBillingCycleEnd = new Date(workspaceSubscription.currentBillingCycleEnd)
switch (workspaceSubscription.billingInterval) {
case 'monthly':
newBillingCycleEnd.setMonth(newBillingCycleEnd.getMonth() + 1)
break
case 'yearly':
newBillingCycleEnd.setFullYear(newBillingCycleEnd.getFullYear() + 1)
break
default:
throwUncoveredError(workspaceSubscription.billingInterval)
}
return newBillingCycleEnd
}