Skip to content

Commit 32c6638

Browse files
committed
[usage] Address nits from #14485
1 parent bc3efb2 commit 32c6638

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

components/usage/pkg/db/cost_center.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,6 @@ func (c *CostCenterManager) ResetUsage(ctx context.Context, cc CostCenter) (Cost
318318

319319
now := time.Now().UTC()
320320

321-
// Resetting the usage always resets the billing cycle start time
322-
billingCycleStart := now
323-
324321
// Default to 1 month from now, if there's no nextBillingTime set on the record.
325322
nextBillingTime := now.AddDate(0, 1, 0)
326323
if cc.NextBillingTime.IsSet() {
@@ -333,12 +330,12 @@ func (c *CostCenterManager) ResetUsage(ctx context.Context, cc CostCenter) (Cost
333330
return CostCenter{}, fmt.Errorf("failed to compute invocie usage record for AttributonID: %s: %w", cc.ID, err)
334331
}
335332

336-
// All fields on the new cost center remain the same, except for CreationTime and NextBillingTime
333+
// All fields on the new cost center remain the same, except for BillingCycleStart, NextBillingTime, and CreationTime
337334
newCostCenter := CostCenter{
338335
ID: cc.ID,
339336
SpendingLimit: spendingLimit,
340337
BillingStrategy: cc.BillingStrategy,
341-
BillingCycleStart: NewVarcharTime(billingCycleStart),
338+
BillingCycleStart: NewVarcharTime(now),
342339
NextBillingTime: NewVarcharTime(nextBillingTime),
343340
CreationTime: NewVarcharTime(now),
344341
}

0 commit comments

Comments
 (0)