Skip to content

Commit 08fc5eb

Browse files
authored
fix(subs): use correct timing validation (#3637)
1 parent d6c8bbd commit 08fc5eb

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

openmeter/subscription/timing.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,8 @@ func (c Timing) ResolveForSpec(spec SubscriptionSpec) (time.Time, error) {
7171
case TimingImmediate:
7272
return clock.Now(), nil
7373
case TimingNextBillingCycle:
74-
currentPhase, exists := spec.GetCurrentPhaseAt(clock.Now())
75-
if !exists {
76-
// If there isn't a current phase, the subscription hasn't started or has already ended
77-
return def, models.NewGenericValidationError(fmt.Errorf("billing isn't active for the subscription, there isn't a next_billing_cycle"))
78-
}
79-
80-
if !currentPhase.HasBillables() {
81-
return def, models.NewGenericValidationError(fmt.Errorf("current phase has no billables, there isn't a next_billing_cycle"))
74+
if spec.BillingCadence.IsZero() {
75+
return def, models.NewGenericValidationError(fmt.Errorf("subscription does not have a billing cadence, there isn't a next_billing_cycle"))
8276
}
8377

8478
period, err := spec.GetAlignedBillingPeriodAt(clock.Now())

0 commit comments

Comments
 (0)