Skip to content

Commit ff0a41a

Browse files
committed
fix(billing): say out loud when a yearly subscription skips recurring charges
The skip is deliberate: a MONTH charge on a yearly subscription would be raised once a year rather than twelve times, so it is skipped rather than under-charged. But it returned 0 with nothing logged, so an installed app expecting to be paid simply never was and nobody could tell. Moved below the declaration read so it fires only for workspaces actually running an app that declares a recurring charge, rather than daily for every yearly-plan workspace, and it can name how many charges were skipped.
1 parent 082d4fc commit ff0a41a

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

packages/twenty-server/src/engine/core-modules/billing/app-billing/application-recurring-charge.service.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ export class ApplicationRecurringChargeService {
4949
return 0;
5050
}
5151

52-
// A MONTH charge on a yearly subscription would be raised once a year, not
53-
// twelve times, so it is skipped rather than silently under-charged.
54-
if (currentBillingSubscription.interval !== SubscriptionInterval.Month) {
55-
return 0;
56-
}
57-
5852
const periodStart = currentBillingSubscription.currentPeriodStart;
5953

6054
const { declaredCharges, rejectedCharges: malformedCharges } =
@@ -68,6 +62,18 @@ export class ApplicationRecurringChargeService {
6862
return 0;
6963
}
7064

65+
// A MONTH charge on a yearly subscription would be raised once a year, not
66+
// twelve times, so it is skipped rather than silently under-charged. Only
67+
// reached once an app actually declares one, so the workspaces this is said
68+
// about are the ones running an app that expects to be paid and is not.
69+
if (currentBillingSubscription.interval !== SubscriptionInterval.Month) {
70+
this.logger.warn(
71+
`Skipping ${declaredCharges.length} recurring app charge(s) for workspace ${workspaceId}: the workspace is on a ${currentBillingSubscription.interval} subscription and only MONTH charges can be raised`,
72+
);
73+
74+
return 0;
75+
}
76+
7177
const alreadyChargedKeys =
7278
await this.usageAnalyticsService.getChargedRecurringKeys({
7379
workspaceId,

0 commit comments

Comments
 (0)