Documentation
¶
Overview ¶
lineservice package contains the implementation of the LineAdapter interface which acts as a adapter between the specific line types and the billing service.
This package allows us to not to have line type specific implementation details in the billing service. (Which is already quite complex)
Index ¶
- Constants
- type CanBeInvoicedAsOfInput
- type Config
- type InvoicingCapabilityQueryInput
- type Line
- type LineBase
- type LineWithBillablePeriod
- type Lines
- type ResolveBillablePeriodInput
- type Service
- func (s *Service) AssociateLinesToInvoice(ctx context.Context, invoice *billing.Invoice, lines Lines) (Lines, error)
- func (s *Service) FromEntities(line []*billing.Line) (Lines, error)
- func (s *Service) FromEntity(line *billing.Line) (Line, error)
- func (s *Service) UpsertLines(ctx context.Context, ns string, lines ...Line) (Lines, error)
- type SplitResult
- type UpdateInput
Constants ¶
View Source
const ( FlatPriceChildUniqueReferenceID = "flat-price" UnitPriceUsageChildUniqueReferenceID = "unit-price-usage" UnitPriceMinSpendChildUniqueReferenceID = "unit-price-min-spend" UnitPriceMaxSpendChildUniqueReferenceID = "unit-price-max-spend" VolumeFlatPriceChildUniqueReferenceID = "volume-flat-price" VolumeUnitPriceChildUniqueReferenceID = "volume-tiered-price" VolumeMinSpendChildUniqueReferenceID = "volume-min-spend" GraduatedTieredPriceUsageChildUniqueReferenceID = "graduated-tiered-%d-price-usage" GraduatedTieredFlatPriceChildUniqueReferenceID = "graduated-tiered-%d-flat-price" GraduatedMinSpendChildUniqueReferenceID = "graduated-tiered-min-spend" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CanBeInvoicedAsOfInput ¶
type CanBeInvoicedAsOfInput = InvoicingCapabilityQueryInput
type Config ¶
type Config struct { BillingAdapter billing.Adapter FeatureService feature.FeatureConnector MeterRepo meter.Repository StreamingConnector streaming.Connector }
type Line ¶
type Line interface { LineBase Service() *Service Validate(context.Context, *billing.Invoice) error CanBeInvoicedAsOf(context.Context, CanBeInvoicedAsOfInput) (*billing.Period, error) SnapshotQuantity(context.Context, *billing.Invoice) error CalculateDetailedLines() error PrepareForCreate(context.Context) (Line, error) UpdateTotals() error }
type LineBase ¶
type LineBase interface { ToEntity() *billing.Line ID() string InvoiceID() string Currency() currencyx.Code Period() billing.Period Status() billing.InvoiceLineStatus HasParent() bool // IsLastInPeriod returns true if the line is the last line in the period that is going to be invoiced. IsLastInPeriod() bool IsDeleted() bool IsSplit() bool CloneForCreate(in UpdateInput) Line Update(in UpdateInput) Line Save(context.Context) (Line, error) // Split splits a line into two lines at the given time. // The strategy is that we will have a line with status InvoiceLineStatusSplit and two child // lines with status InvoiceLineStatusValid. // // To make algorithms easier, upon next split, we will not create an imbalanced tree, but rather attach // the new split line to the existing parent line. Split(ctx context.Context, at time.Time) (SplitResult, error) Service() *Service ResetTotals() }
type LineWithBillablePeriod ¶
type Lines ¶
type Lines []Line
func (Lines) ResolveBillablePeriod ¶
func (s Lines) ResolveBillablePeriod(ctx context.Context, in ResolveBillablePeriodInput) ([]LineWithBillablePeriod, error)
func (Lines) ToEntities ¶
type ResolveBillablePeriodInput ¶
type ResolveBillablePeriodInput = InvoicingCapabilityQueryInput
type Service ¶
type Service struct { Config // contains filtered or unexported fields }
func (*Service) AssociateLinesToInvoice ¶
type SplitResult ¶
type UpdateInput ¶
type UpdateInput struct { ParentLine mo.Option[*billing.Line] PeriodStart time.Time PeriodEnd time.Time InvoiceAt time.Time Status billing.InvoiceLineStatus // PreventChildChanges is used to prevent any child changes to the line by the adapter. PreventChildChanges bool ResetChildUniqueReferenceID bool }
Click to show internal directories.
Click to hide internal directories.