Documentation
¶
Index ¶
- Constants
- type Config
- type FeatureFlags
- type InvoiceByID
- type InvoiceUpdater
- type PhaseIterator
- func (it *PhaseIterator) Generate(ctx context.Context, iterationEnd time.Time) ([]subscriptionItemWithPeriods, error)
- func (it *PhaseIterator) GetMinimumBillableTime() time.Time
- func (it *PhaseIterator) HasInvoicableItems() bool
- func (it *PhaseIterator) PhaseEnd() *time.Time
- func (it *PhaseIterator) PhaseStart() time.Time
- type Service
- func (s *Service) GetSyncStates(ctx context.Context, input subscriptionsync.GetSyncStatesInput) ([]subscriptionsync.SyncState, error)
- func (s *Service) HandleCancelledEvent(ctx context.Context, event *subscription.CancelledEvent) error
- func (s *Service) HandleInvoiceCreation(ctx context.Context, event *billing.StandardInvoiceCreatedEvent) error
- func (s *Service) HandleSubscriptionSyncEvent(ctx context.Context, event *subscription.SubscriptionSyncEvent) error
- func (s *Service) SynchronizeSubscription(ctx context.Context, subs subscription.SubscriptionView, asOf time.Time) error
- func (s *Service) SynchronizeSubscriptionAndInvoiceCustomer(ctx context.Context, subs subscription.SubscriptionView, asOf time.Time) error
Constants ¶
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
}
type FeatureFlags ¶
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 (*Service) GetSyncStates ¶
func (s *Service) GetSyncStates(ctx context.Context, input subscriptionsync.GetSyncStatesInput) ([]subscriptionsync.SyncState, error)
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