Skip to content

The open alternative to Salesforce, designed for AI.

fix(billing): skip the rollover for workspaces that no longer exist (#24068)

Félix Malfaitdab81f57e9ba
diff --git a/packages/twenty-server/src/engine/core-modules/billing-webhook/services/billing-webhook-invoice.service.ts b/packages/twenty-server/src/engine/core-modules/billing-webhook/services/billing-webhook-invoice.service.ts
index 044735dcd3a..3f2f6e0ba56 100644
--- a/packages/twenty-server/src/engine/core-modules/billing-webhook/services/billing-webhook-invoice.service.ts
+++ b/packages/twenty-server/src/engine/core-modules/billing-webhook/services/billing-webhook-invoice.service.ts
@@ -134,6 +134,15 @@ export class BillingWebhookInvoiceService {
invoicePeriodEnd: Date;
isFirstPeriodAfterTrial: boolean;
}): Promise<void> {
+ const workspaceExists = await this.workspaceRepository.exists({
+ where: { id: subscription.workspaceId },
+ withDeleted: true,
+ });
+
+ if (!workspaceExists) {
+ return;
+ }
+
const params =
await this.resourceCreditService.getResourceCreditRolloverParameters(
subscription.workspaceId,