service

package
v1.0.0-beta.227 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SubscriptionSyncComponentName billing.ComponentName = "subscription-sync"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	BillingService          billing.Service
	SubscriptionService     subscription.Service
	SubscriptionSyncAdapter subscriptionsync.Adapter
	FeatureFlags            FeatureFlags
	Logger                  *slog.Logger
	Tracer                  trace.Tracer
}

func (Config) Validate

func (c Config) Validate() error

type FeatureFlags

type FeatureFlags struct {
	EnableFlatFeeInAdvanceProrating bool
	EnableFlatFeeInArrearsProrating bool
}

type InvoiceByID

type InvoiceByID map[string]billing.StandardInvoice

func (InvoiceByID) IsGatheringInvoice

func (i InvoiceByID) IsGatheringInvoice(invoiceID string) bool

type InvoiceUpdater

type InvoiceUpdater struct {
	// contains filtered or unexported fields
}

func NewInvoiceUpdater

func NewInvoiceUpdater(billingService billing.Service, logger *slog.Logger) *InvoiceUpdater

func (*InvoiceUpdater) ApplyPatches

func (u *InvoiceUpdater) ApplyPatches(ctx context.Context, customerID customer.CustomerID, patches []linePatch) error

type PhaseIterator

type PhaseIterator struct {
	// contains filtered or unexported fields
}

func NewPhaseIterator

func NewPhaseIterator(logger *slog.Logger, tracer trace.Tracer, subs subscription.SubscriptionView, phaseKey string) (*PhaseIterator, error)

func (*PhaseIterator) Generate

func (it *PhaseIterator) Generate(ctx context.Context, iterationEnd time.Time) ([]subscriptionItemWithPeriods, error)

Generate generates the lines for the phase so that all active subscription item's are generated up to the point where either the item gets deactivated or the last item's invoice_at >= iterationEnd and it's period's end is equal to or after iterationEnd.

This ensures that we always have the upcoming lines stored on the gathering invoice.

func (*PhaseIterator) GetMinimumBillableTime

func (it *PhaseIterator) GetMinimumBillableTime() time.Time

GetMinimumBillableTime returns the minimum time that we can bill for the phase (e.g. the first time we would be yielding a line item)

The response always truncated to capture that billing has 1s resolution.

func (*PhaseIterator) HasInvoicableItems

func (it *PhaseIterator) HasInvoicableItems() bool

func (*PhaseIterator) PhaseEnd

func (it *PhaseIterator) PhaseEnd() *time.Time

func (*PhaseIterator) PhaseStart

func (it *PhaseIterator) PhaseStart() time.Time

type Service

type Service struct {
	// contains filtered or unexported fields
}

func New

func New(config Config) (*Service, error)

func (*Service) GetSyncStates

func (*Service) HandleCancelledEvent

func (s *Service) HandleCancelledEvent(ctx context.Context, event *subscription.CancelledEvent) error

HandleCancelledEvent is a handler for the subscription cancel event, it will make sure that we synchronize the

func (*Service) HandleInvoiceCreation

func (s *Service) HandleInvoiceCreation(ctx context.Context, event *billing.StandardInvoiceCreatedEvent) error

HandleInvoiceCreation is a handler for the invoice creation event, it will make sure that we are backfilling the items consumed by invoice creation into the gathering invoice.

func (*Service) HandleSubscriptionSyncEvent

func (s *Service) HandleSubscriptionSyncEvent(ctx context.Context, event *subscription.SubscriptionSyncEvent) error

func (*Service) SynchronizeSubscription

func (s *Service) SynchronizeSubscription(ctx context.Context, subs subscription.SubscriptionView, asOf time.Time) error

func (*Service) SynchronizeSubscriptionAndInvoiceCustomer

func (s *Service) SynchronizeSubscriptionAndInvoiceCustomer(ctx context.Context, subs subscription.SubscriptionView, asOf time.Time) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL