Skip to content

Commit 829b102

Browse files
GAlexIHUturip
andauthored
feat(pc): use billing cadence in subscription sync (#2922)
Co-authored-by: Peter Turi <peter.turi@openmeter.io>
1 parent dc4e109 commit 829b102

File tree

22 files changed

+1479
-661
lines changed

22 files changed

+1479
-661
lines changed

openmeter/billing/invoiceline.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func (i LineBase) Validate() error {
180180
if i.InvoiceAt.IsZero() {
181181
errs = append(errs, errors.New("invoice at is required"))
182182
} else if i.InvoiceAt.Before(i.Period.Start) {
183-
errs = append(errs, errors.New("invoice at must be after period start"))
183+
errs = append(errs, fmt.Errorf("invoice at (%s) must be after period start (%s)", i.InvoiceAt, i.Period.Start))
184184
}
185185

186186
if i.Name == "" {
@@ -437,7 +437,7 @@ func (i Line) Validate() error {
437437
}
438438

439439
if i.InvoiceAt.Before(i.Period.Truncate(DefaultMeterResolution).Start) {
440-
errs = append(errs, errors.New("invoice at must be after period start"))
440+
errs = append(errs, fmt.Errorf("invoice at (%s) must be after period start (%s)", i.InvoiceAt, i.Period.Truncate(DefaultMeterResolution).Start))
441441
}
442442

443443
if err := i.Discounts.Validate(); err != nil {
@@ -538,7 +538,7 @@ func (i Line) ValidateUsageBased() error {
538538
}
539539

540540
if i.DependsOnMeteredQuantity() && i.InvoiceAt.Before(i.Period.Truncate(DefaultMeterResolution).End) {
541-
errs = append(errs, errors.New("invoice at must be after period end for usage based line"))
541+
errs = append(errs, fmt.Errorf("invoice at (%s) must be after period end (%s) for usage based line", i.InvoiceAt, i.Period.Truncate(DefaultMeterResolution).End))
542542
}
543543

544544
return errors.Join(errs...)

0 commit comments

Comments
 (0)