Skip to content

Commit 0c38331

Browse files
jankeromnesroboquat
authored andcommitted
[usage] Always set a CostCenter.nextBillingTime, even when we don't manage the billing
1 parent b1161a5 commit 0c38331

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

components/usage/pkg/db/cost_center.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ func (c *CostCenterManager) UpdateCostCenter(ctx context.Context, newCC CostCent
186186
}
187187

188188
newCC.BillingCycleStart = common_db.NewVarCharTime(now)
189-
// we don't manage stripe billing cycle
190-
newCC.NextBillingTime = common_db.VarcharTime{}
189+
// set an informative nextBillingTime, even though we don't manage Stripe billing cycle
190+
newCC.NextBillingTime = common_db.NewVarCharTime(now.AddDate(0, 1, 0))
191191
}
192192
} else if isTeam {
193193
// Billing strategy is Other, and it remains unchanged
@@ -214,8 +214,8 @@ func (c *CostCenterManager) UpdateCostCenter(ctx context.Context, newCC CostCent
214214
}
215215

216216
newCC.BillingCycleStart = common_db.NewVarCharTime(now)
217-
// we don't manage stripe billing cycle
218-
newCC.NextBillingTime = common_db.VarcharTime{}
217+
// set an informative nextBillingTime, even though we don't manage Stripe billing cycle
218+
newCC.NextBillingTime = common_db.NewVarCharTime(now.AddDate(0, 1, 0))
219219
}
220220
} else {
221221
return CostCenter{}, status.Errorf(codes.InvalidArgument, "Unknown attribution entity %s", string(attributionID))

components/usage/pkg/db/cost_center_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ func TestSaveCostCenterMovedToStripe(t *testing.T) {
289289
teamCC, err = mnr.UpdateCostCenter(context.Background(), teamCC)
290290
require.NoError(t, err)
291291
require.Equal(t, db.CostCenter_Stripe, teamCC.BillingStrategy)
292-
require.Equal(t, common_db.VarcharTime{}, teamCC.NextBillingTime)
292+
require.Equal(t, teamCC.CreationTime.Time().AddDate(0, 1, 0), teamCC.NextBillingTime.Time())
293293
require.Equal(t, int32(400050), teamCC.SpendingLimit)
294294

295295
teamCC.BillingStrategy = db.CostCenter_Other

0 commit comments

Comments
 (0)