Skip to content

Commit a5d6744

Browse files
svenefftingeroboquat
authored andcommitted
Revert "[usage] handle reset usage for chargebee"
1 parent 81f23e9 commit a5d6744

File tree

7 files changed

+66
-148
lines changed

7 files changed

+66
-148
lines changed

components/gitpod-db/go/cost_center.go

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ var CostCenterNotFound = errors.New("CostCenter not found")
2222
type BillingStrategy string
2323

2424
const (
25-
CostCenter_Stripe BillingStrategy = "stripe"
26-
CostCenter_Other BillingStrategy = "other"
27-
CostCenter_ChargebeeCancelled BillingStrategy = "chargebee-cancelled"
25+
CostCenter_Stripe BillingStrategy = "stripe"
26+
CostCenter_Other BillingStrategy = "other"
2827
)
2928

3029
type CostCenter struct {
@@ -291,19 +290,11 @@ func (c *CostCenterManager) ResetUsage(ctx context.Context, id AttributionID) (C
291290
nextBillingTime = cc.NextBillingTime.Time().AddDate(0, 1, 0)
292291
}
293292

294-
futureSpendingLimit := cc.SpendingLimit
295-
futurebillingStrategy := cc.BillingStrategy
296-
// chargebee cancellations will be switched to free plan (strategy: other)
297-
if cc.BillingStrategy == CostCenter_ChargebeeCancelled {
298-
futureSpendingLimit = c.cfg.ForTeams
299-
futurebillingStrategy = CostCenter_Other
300-
}
301-
302293
// All fields on the new cost center remain the same, except for BillingCycleStart, NextBillingTime, and CreationTime
303294
newCostCenter := CostCenter{
304295
ID: cc.ID,
305-
SpendingLimit: futureSpendingLimit,
306-
BillingStrategy: futurebillingStrategy,
296+
SpendingLimit: cc.SpendingLimit,
297+
BillingStrategy: cc.BillingStrategy,
307298
BillingCycleStart: NewVarCharTime(billingCycleStart),
308299
NextBillingTime: NewVarCharTime(nextBillingTime),
309300
CreationTime: NewVarCharTime(now),

components/gitpod-protocol/src/usage.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,5 @@ export interface CostCenterJSON {
8181
export enum CostCenter_BillingStrategy {
8282
BILLING_STRATEGY_STRIPE = "BILLING_STRATEGY_STRIPE",
8383
BILLING_STRATEGY_OTHER = "BILLING_STRATEGY_OTHER",
84-
BILLING_STRATEGY_CHARGEBEE_CANCELLATION = "BILLING_STRATEGY_CHARGEBEE_CANCELLATION",
8584
UNRECOGNIZED = "UNRECOGNIZED",
8685
}

components/usage-api/go/v1/usage.pb.go

Lines changed: 61 additions & 67 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/usage-api/typescript/src/usage/v1/usage.pb.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ export interface CostCenter {
201201
export enum CostCenter_BillingStrategy {
202202
BILLING_STRATEGY_STRIPE = "BILLING_STRATEGY_STRIPE",
203203
BILLING_STRATEGY_OTHER = "BILLING_STRATEGY_OTHER",
204-
BILLING_STRATEGY_CHARGEBEE_CANCELLATION = "BILLING_STRATEGY_CHARGEBEE_CANCELLATION",
205204
UNRECOGNIZED = "UNRECOGNIZED",
206205
}
207206

@@ -213,9 +212,6 @@ export function costCenter_BillingStrategyFromJSON(object: any): CostCenter_Bill
213212
case 1:
214213
case "BILLING_STRATEGY_OTHER":
215214
return CostCenter_BillingStrategy.BILLING_STRATEGY_OTHER;
216-
case 2:
217-
case "BILLING_STRATEGY_CHARGEBEE_CANCELLATION":
218-
return CostCenter_BillingStrategy.BILLING_STRATEGY_CHARGEBEE_CANCELLATION;
219215
case -1:
220216
case "UNRECOGNIZED":
221217
default:
@@ -229,8 +225,6 @@ export function costCenter_BillingStrategyToJSON(object: CostCenter_BillingStrat
229225
return "BILLING_STRATEGY_STRIPE";
230226
case CostCenter_BillingStrategy.BILLING_STRATEGY_OTHER:
231227
return "BILLING_STRATEGY_OTHER";
232-
case CostCenter_BillingStrategy.BILLING_STRATEGY_CHARGEBEE_CANCELLATION:
233-
return "BILLING_STRATEGY_CHARGEBEE_CANCELLATION";
234228
case CostCenter_BillingStrategy.UNRECOGNIZED:
235229
default:
236230
return "UNRECOGNIZED";
@@ -243,8 +237,6 @@ export function costCenter_BillingStrategyToNumber(object: CostCenter_BillingStr
243237
return 0;
244238
case CostCenter_BillingStrategy.BILLING_STRATEGY_OTHER:
245239
return 1;
246-
case CostCenter_BillingStrategy.BILLING_STRATEGY_CHARGEBEE_CANCELLATION:
247-
return 2;
248240
case CostCenter_BillingStrategy.UNRECOGNIZED:
249241
default:
250242
return -1;

components/usage-api/usage/v1/usage.proto

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ message CostCenter {
127127
enum BillingStrategy {
128128
BILLING_STRATEGY_STRIPE = 0;
129129
BILLING_STRATEGY_OTHER = 1;
130-
BILLING_STRATEGY_CHARGEBEE_CANCELLATION = 2;
131130
}
132131
BillingStrategy billing_strategy = 3;
133132

components/usage/pkg/apiv1/usage.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,19 +204,13 @@ func convertBillingStrategyToDB(in v1.CostCenter_BillingStrategy) db.BillingStra
204204
if in == v1.CostCenter_BILLING_STRATEGY_STRIPE {
205205
return db.CostCenter_Stripe
206206
}
207-
if in == v1.CostCenter_BILLING_STRATEGY_CHARGEBEE_CANCELLATION {
208-
return db.CostCenter_ChargebeeCancelled
209-
}
210207
return db.CostCenter_Other
211208
}
212209

213210
func convertBillingStrategyToAPI(in db.BillingStrategy) v1.CostCenter_BillingStrategy {
214211
if in == db.CostCenter_Stripe {
215212
return v1.CostCenter_BILLING_STRATEGY_STRIPE
216213
}
217-
if in == db.CostCenter_ChargebeeCancelled {
218-
return v1.CostCenter_BILLING_STRATEGY_CHARGEBEE_CANCELLATION
219-
}
220214
return v1.CostCenter_BILLING_STRATEGY_OTHER
221215
}
222216

0 commit comments

Comments
 (0)