Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions openmeter/billing/service/lineservice/linebase.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ func (l lineBase) Validate(ctx context.Context, invoice *billing.Invoice) error
}
}

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

return nil
}

Expand All @@ -114,10 +121,6 @@ func (l lineBase) IsLastInPeriod() bool {
return true
}

if l.line.SplitLineHierarchy == nil {
return true
}

if l.line.SplitLineHierarchy.Group.ServicePeriod.End.Equal(l.line.Period.End) {
return true
}
Expand All @@ -130,10 +133,6 @@ func (l lineBase) IsFirstInPeriod() bool {
return true
}

if l.line.SplitLineHierarchy == nil {
return true
}

if l.line.SplitLineHierarchy.Group.ServicePeriod.Start.Equal(l.line.Period.Start) {
return true
}
Expand Down
Loading