Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ require (
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/authzed/authzed-go v1.4.1 // indirect
github.com/authzed/grpcutil v0.0.0-20250221190651-1985b19b35b8 // indirect
github.com/awalterschulze/goderive v0.5.1 // indirect
github.com/bhmj/xpression v0.9.4 // indirect
github.com/bitfield/gotestdox v0.2.2 // indirect
github.com/bmatcuk/doublestar v1.3.4 // indirect
Expand Down Expand Up @@ -150,6 +151,7 @@ require (
github.com/jonboulle/clockwork v0.5.0 // indirect
github.com/jzelinskie/stringz v0.0.3 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/kisielk/gotool v1.0.0 // indirect
github.com/klauspost/asmfmt v1.3.2 // indirect
github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 // indirect
github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 // indirect
Expand Down Expand Up @@ -532,6 +534,7 @@ require (
)

tool (
github.com/awalterschulze/goderive
github.com/google/wire/cmd/wire
github.com/jmattheis/goverter/cmd/goverter
github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen
Expand Down
5 changes: 3 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,8 @@ github.com/authzed/grpcutil v0.0.0-20250221190651-1985b19b35b8 h1:y17oq4U8n+k1Oc
github.com/authzed/grpcutil v0.0.0-20250221190651-1985b19b35b8/go.mod h1:Pf1ZSi41EePvx1GC1DeEJw5dn35iUcxZHqpHuG1Rpic=
github.com/avast/retry-go/v4 v4.7.0 h1:yjDs35SlGvKwRNSykujfjdMxMhMQQM0TnIjJaHB+Zio=
github.com/avast/retry-go/v4 v4.7.0/go.mod h1:ZMPDa3sY2bKgpLtap9JRUgk2yTAba7cgiFhqxY2Sg6Q=
github.com/awalterschulze/goderive v0.5.1 h1:H2XNRDw0Ordwj/pgLAVqQgDC1LQWP7L99ofOs72bjqg=
github.com/awalterschulze/goderive v0.5.1/go.mod h1:DLlff0SRVo846CBrp8nXuXJ4mdWA92ai5CYTr+LV/II=
github.com/aws/aws-lambda-go v1.49.0 h1:z4VhTqkFZPM3xpEtTqWqRqsRH4TZBMJqTkRiBPYLqIQ=
github.com/aws/aws-lambda-go v1.49.0/go.mod h1:dpMpZgvWx5vuQJfBt0zqBha60q7Dd7RfgJv23DymV8A=
github.com/aws/aws-sdk-go v1.15.27/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0=
Expand Down Expand Up @@ -1797,6 +1799,7 @@ github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF
github.com/keybase/go-keychain v0.0.1 h1:way+bWYa6lDppZoZcgMbYsvC7GxljxrskdNInRtuthU=
github.com/keybase/go-keychain v0.0.1/go.mod h1:PdEILRW3i9D8JcdM+FmY6RwkHGnhHxXwkPPMeUgOK1k=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/asmfmt v1.3.2 h1:4Ri7ox3EwapiOjCki+hw14RyKk201CN4rzyCJRFLpK4=
github.com/klauspost/asmfmt v1.3.2/go.mod h1:AG8TuvYojzulgDAMCnYn50l/5QV3Bs/tp6j0HLHbNSE=
Expand Down Expand Up @@ -2002,8 +2005,6 @@ github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/oklog/ulid/v2 v2.1.1 h1:suPZ4ARWLOJLegGFiZZ1dFAkqzhMjL3J1TzI+5wHz8s=
github.com/oklog/ulid/v2 v2.1.1/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/oliveagle/jsonpath v0.0.0-20180606110733-2e52cf6e6852 h1:Yl0tPBa8QPjGmesFh1D0rDy+q1Twx6FyU7VWHi8wZbI=
github.com/oliveagle/jsonpath v0.0.0-20180606110733-2e52cf6e6852/go.mod h1:eqOVx5Vwu4gd2mmMZvVZsgIqNSaW3xxRThUJ0k/TPk4=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
Expand Down
186 changes: 186 additions & 0 deletions openmeter/billing/derived.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions openmeter/billing/generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package billing

//go:generate go run github.com/awalterschulze/goderive
3 changes: 1 addition & 2 deletions openmeter/billing/invoicedetailedline.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package billing
import (
"errors"
"fmt"
"reflect"
"slices"

"github.com/alpacahq/alpacadecimal"
Expand Down Expand Up @@ -115,7 +114,7 @@ func (l DetailedLineBase) Clone() DetailedLineBase {
}

func (l DetailedLineBase) Equal(other DetailedLineBase) bool {
return reflect.DeepEqual(l, other)
return deriveEqualDetailedLineBase(&l, &other)
}

type DetailedLine struct {
Expand Down
34 changes: 2 additions & 32 deletions openmeter/billing/invoiceline.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package billing
import (
"errors"
"fmt"
"reflect"
"slices"
"sort"
"strings"
Expand All @@ -17,7 +16,6 @@ import (
"github.com/openmeterio/openmeter/openmeter/productcatalog"
"github.com/openmeterio/openmeter/openmeter/streaming"
"github.com/openmeterio/openmeter/pkg/currencyx"
"github.com/openmeterio/openmeter/pkg/equal"
"github.com/openmeterio/openmeter/pkg/models"
"github.com/openmeterio/openmeter/pkg/timeutil"
)
Expand Down Expand Up @@ -125,7 +123,7 @@ type LineBase struct {
}

func (i LineBase) Equal(other LineBase) bool {
return reflect.DeepEqual(i, other)
return deriveEqualLineBase(&i, &other)
}

func (i LineBase) GetParentID() (string, bool) {
Expand Down Expand Up @@ -647,35 +645,7 @@ type UsageBasedLine struct {
}

func (i UsageBasedLine) Equal(other *UsageBasedLine) bool {
if other == nil {
return false
}

if !i.Price.Equal(other.Price) {
return false
}

if i.FeatureKey != other.FeatureKey {
return false
}

if !equal.PtrEqual(i.Quantity, other.Quantity) {
return false
}

if !equal.PtrEqual(i.MeteredQuantity, other.MeteredQuantity) {
return false
}

if !equal.PtrEqual(i.PreLinePeriodQuantity, other.PreLinePeriodQuantity) {
return false
}

if !equal.PtrEqual(i.MeteredPreLinePeriodQuantity, other.MeteredPreLinePeriodQuantity) {
return false
}

return true
return deriveEqualUsageBasedLine(&i, other)
}

func (i UsageBasedLine) Clone() *UsageBasedLine {
Expand Down
Loading
Loading