Skip to content

Commit f440848

Browse files
committed
fix: make sure that split lines are expanded for line service
1 parent a79e33f commit f440848

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

openmeter/billing/service/lineservice/linebase.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ func (l lineBase) Validate(ctx context.Context, invoice *billing.Invoice) error
106106
}
107107
}
108108

109+
// Expanding the split lines are mandatory for the lineservice to work properly.
110+
if l.line.SplitLineGroupID != nil && l.line.SplitLineHierarchy == nil {
111+
return billing.ValidationError{
112+
Err: fmt.Errorf("split line group[%s] has no hierarchy expanded hierarchy", *l.line.SplitLineGroupID),
113+
}
114+
}
115+
109116
return nil
110117
}
111118

@@ -114,10 +121,6 @@ func (l lineBase) IsLastInPeriod() bool {
114121
return true
115122
}
116123

117-
if l.line.SplitLineHierarchy == nil {
118-
return true
119-
}
120-
121124
if l.line.SplitLineHierarchy.Group.ServicePeriod.End.Equal(l.line.Period.End) {
122125
return true
123126
}
@@ -130,10 +133,6 @@ func (l lineBase) IsFirstInPeriod() bool {
130133
return true
131134
}
132135

133-
if l.line.SplitLineHierarchy == nil {
134-
return true
135-
}
136-
137136
if l.line.SplitLineHierarchy.Group.ServicePeriod.Start.Equal(l.line.Period.Start) {
138137
return true
139138
}

0 commit comments

Comments
 (0)