Documentation
¶
Index ¶
- func New(config Config) (usagebased.Service, error)
- type Config
- type CreditThenInvoiceStateMachine
- func (s CreditThenInvoiceStateMachine) AdvanceAfterCollectionPeriodEnd(ctx context.Context) error
- func (s CreditThenInvoiceStateMachine) AdvanceAfterServicePeriodFrom(ctx context.Context) error
- func (s CreditThenInvoiceStateMachine) AdvanceAfterServicePeriodTo(ctx context.Context) error
- func (s *CreditThenInvoiceStateMachine) AreAllInvoicedRunsSettled() bool
- func (s *CreditThenInvoiceStateMachine) DeleteCharge(ctx context.Context, patch meta.PatchDelete) error
- func (s *CreditThenInvoiceStateMachine) ExtendCharge(ctx context.Context, patch meta.PatchExtend) error
- func (s *CreditThenInvoiceStateMachine) FinalizeInvoiceRun(ctx context.Context, input billing.StandardLineWithInvoiceHeader) error
- func (s *CreditThenInvoiceStateMachine) HasTerminalInvoicedRealizationWithoutCurrentRun() bool
- func (s CreditThenInvoiceStateMachine) IsAfterCollectionPeriod(ctx context.Context, _ ...any) bool
- func (s CreditThenInvoiceStateMachine) IsAfterServicePeriod() bool
- func (s CreditThenInvoiceStateMachine) IsInsideServicePeriod() bool
- func (s *CreditThenInvoiceStateMachine) ShrinkCharge(ctx context.Context, patch meta.PatchShrink) error
- func (s *CreditThenInvoiceStateMachine) ShrinkToRealizedPeriod(ctx context.Context, patch meta.PatchShrinkToRealizedPeriod) error
- func (s *CreditThenInvoiceStateMachine) SnapshotInvoiceUsage(ctx context.Context) error
- func (s *CreditThenInvoiceStateMachine) StartInvoiceRun(ctx context.Context, input invoiceCreatedInput) error
- func (s CreditThenInvoiceStateMachine) SyncFeatureIDFromFeatureMeter(ctx context.Context) error
- func (s *CreditThenInvoiceStateMachine) UnsupportedExtendOperation(_ context.Context, _ meta.PatchExtend) error
- func (s *CreditThenInvoiceStateMachine) UnsupportedShrinkOperation(_ context.Context, _ meta.PatchShrink) error
- func (s *CreditThenInvoiceStateMachine) UnsupportedShrinkToRealizedPeriodOperation(_ context.Context, _ meta.PatchShrinkToRealizedPeriod) error
- type CreditsOnlyStateMachine
- func (s CreditsOnlyStateMachine) AdvanceAfterCollectionPeriodEnd(ctx context.Context) error
- func (s CreditsOnlyStateMachine) AdvanceAfterServicePeriodFrom(ctx context.Context) error
- func (s CreditsOnlyStateMachine) AdvanceAfterServicePeriodTo(ctx context.Context) error
- func (s *CreditsOnlyStateMachine) ClearAdvanceAfter(ctx context.Context) error
- func (s *CreditsOnlyStateMachine) DeleteCharge(ctx context.Context, patch meta.PatchDelete) error
- func (s *CreditsOnlyStateMachine) ExtendCharge(ctx context.Context, patch meta.PatchExtend) error
- func (s *CreditsOnlyStateMachine) FinalizeRealizationRun(ctx context.Context) error
- func (s CreditsOnlyStateMachine) IsAfterCollectionPeriod(ctx context.Context, _ ...any) bool
- func (s CreditsOnlyStateMachine) IsAfterServicePeriod() bool
- func (s CreditsOnlyStateMachine) IsInsideServicePeriod() bool
- func (s *CreditsOnlyStateMachine) ShrinkCharge(ctx context.Context, patch meta.PatchShrink) error
- func (s *CreditsOnlyStateMachine) StartFinalRealizationRun(ctx context.Context) error
- func (s CreditsOnlyStateMachine) SyncFeatureIDFromFeatureMeter(ctx context.Context) error
- type LineEngine
- func (e *LineEngine) BuildStandardInvoiceLines(ctx context.Context, input billing.BuildStandardInvoiceLinesInput) (billing.StandardLines, error)
- func (e *LineEngine) BuildStandardLinesForGatheringPreview(ctx context.Context, input billing.BuildStandardInvoiceLinesInput) (billing.StandardLines, error)
- func (e *LineEngine) GetLineEngineType() billing.LineEngineType
- func (e *LineEngine) IsLineBillableAsOf(_ context.Context, input billing.IsLineBillableAsOfInput) (bool, error)
- func (e *LineEngine) OnCollectionCompleted(ctx context.Context, input billing.OnCollectionCompletedInput) (billing.StandardLines, error)
- func (e *LineEngine) OnInvoiceIssued(ctx context.Context, input billing.OnInvoiceIssuedInput) error
- func (e *LineEngine) OnMutableInvoiceLinesEditedViaAPI(ctx context.Context, input billing.OnMutableInvoiceUpdateInput) (billing.OnMutableInvoiceUpdateResult, error)
- func (e *LineEngine) OnMutableStandardLinesDeletedBySystem(ctx context.Context, input billing.OnMutableStandardLinesDeletedInput) error
- func (e *LineEngine) OnPaymentAuthorized(ctx context.Context, input billing.OnPaymentAuthorizedInput) error
- func (e *LineEngine) OnPaymentSettled(ctx context.Context, input billing.OnPaymentSettledInput) error
- func (e *LineEngine) OnStandardInvoiceCreated(ctx context.Context, input billing.OnStandardInvoiceCreatedInput) (billing.StandardLines, error)
- func (e *LineEngine) OnUnsupportedCreditNote(ctx context.Context, input billing.OnUnsupportedCreditNoteInput) error
- func (e *LineEngine) SplitGatheringLine(_ context.Context, input billing.SplitGatheringLineInput) (billing.SplitGatheringLineResult, error)
- func (e *LineEngine) ValidateMutableInvoiceLineEditViaAPI(ctx context.Context, input billing.OnMutableInvoiceUpdateInput) error
- type StateMachine
- type StateMachineConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Adapter usagebased.Adapter
Handler usagebased.Handler
Lineage lineage.Service
Locker *lockr.Locker
MetaAdapter meta.Adapter
InvoiceUpdater invoiceupdater.Updater
CustomerOverrideService billing.CustomerOverrideService
FeatureService feature.FeatureConnector
RatingService rating.Service
StreamingConnector streaming.Connector
}
type CreditThenInvoiceStateMachine ¶
type CreditThenInvoiceStateMachine struct {
// contains filtered or unexported fields
}
func NewCreditThenInvoiceStateMachine ¶
func NewCreditThenInvoiceStateMachine(config StateMachineConfig) (*CreditThenInvoiceStateMachine, error)
func (CreditThenInvoiceStateMachine) AdvanceAfterCollectionPeriodEnd ¶
func (CreditThenInvoiceStateMachine) AdvanceAfterServicePeriodFrom ¶
func (CreditThenInvoiceStateMachine) AdvanceAfterServicePeriodTo ¶
func (*CreditThenInvoiceStateMachine) AreAllInvoicedRunsSettled ¶
func (s *CreditThenInvoiceStateMachine) AreAllInvoicedRunsSettled() bool
func (*CreditThenInvoiceStateMachine) DeleteCharge ¶
func (s *CreditThenInvoiceStateMachine) DeleteCharge(ctx context.Context, patch meta.PatchDelete) error
func (*CreditThenInvoiceStateMachine) ExtendCharge ¶
func (s *CreditThenInvoiceStateMachine) ExtendCharge(ctx context.Context, patch meta.PatchExtend) error
func (*CreditThenInvoiceStateMachine) FinalizeInvoiceRun ¶
func (s *CreditThenInvoiceStateMachine) FinalizeInvoiceRun(ctx context.Context, input billing.StandardLineWithInvoiceHeader) error
func (*CreditThenInvoiceStateMachine) HasTerminalInvoicedRealizationWithoutCurrentRun ¶
func (s *CreditThenInvoiceStateMachine) HasTerminalInvoicedRealizationWithoutCurrentRun() bool
HasTerminalInvoicedRealizationWithoutCurrentRun lets the active state discover a completed invoice-backed realization after manual period changes. Normally the realization branch moves to settlement when it creates the final run; API gathering-line deletes can instead make an existing paid partial run become final while the charge is already back in active.
func (CreditThenInvoiceStateMachine) IsAfterCollectionPeriod ¶
func (CreditThenInvoiceStateMachine) IsAfterServicePeriod ¶
func (s CreditThenInvoiceStateMachine) IsAfterServicePeriod() bool
func (CreditThenInvoiceStateMachine) IsInsideServicePeriod ¶
func (s CreditThenInvoiceStateMachine) IsInsideServicePeriod() bool
func (*CreditThenInvoiceStateMachine) ShrinkCharge ¶
func (s *CreditThenInvoiceStateMachine) ShrinkCharge(ctx context.Context, patch meta.PatchShrink) error
func (*CreditThenInvoiceStateMachine) ShrinkToRealizedPeriod ¶
func (s *CreditThenInvoiceStateMachine) ShrinkToRealizedPeriod(ctx context.Context, patch meta.PatchShrinkToRealizedPeriod) error
func (*CreditThenInvoiceStateMachine) SnapshotInvoiceUsage ¶
func (s *CreditThenInvoiceStateMachine) SnapshotInvoiceUsage(ctx context.Context) error
func (*CreditThenInvoiceStateMachine) StartInvoiceRun ¶
func (s *CreditThenInvoiceStateMachine) StartInvoiceRun( ctx context.Context, input invoiceCreatedInput, ) error
func (CreditThenInvoiceStateMachine) SyncFeatureIDFromFeatureMeter ¶
func (*CreditThenInvoiceStateMachine) UnsupportedExtendOperation ¶
func (s *CreditThenInvoiceStateMachine) UnsupportedExtendOperation(_ context.Context, _ meta.PatchExtend) error
func (*CreditThenInvoiceStateMachine) UnsupportedShrinkOperation ¶
func (s *CreditThenInvoiceStateMachine) UnsupportedShrinkOperation(_ context.Context, _ meta.PatchShrink) error
func (*CreditThenInvoiceStateMachine) UnsupportedShrinkToRealizedPeriodOperation ¶
func (s *CreditThenInvoiceStateMachine) UnsupportedShrinkToRealizedPeriodOperation(_ context.Context, _ meta.PatchShrinkToRealizedPeriod) error
type CreditsOnlyStateMachine ¶
type CreditsOnlyStateMachine struct {
// contains filtered or unexported fields
}
func NewCreditsOnlyStateMachine ¶
func NewCreditsOnlyStateMachine(config StateMachineConfig) (*CreditsOnlyStateMachine, error)
func (CreditsOnlyStateMachine) AdvanceAfterCollectionPeriodEnd ¶
func (CreditsOnlyStateMachine) AdvanceAfterServicePeriodFrom ¶
func (CreditsOnlyStateMachine) AdvanceAfterServicePeriodTo ¶
func (*CreditsOnlyStateMachine) ClearAdvanceAfter ¶
func (s *CreditsOnlyStateMachine) ClearAdvanceAfter(ctx context.Context) error
func (*CreditsOnlyStateMachine) DeleteCharge ¶
func (s *CreditsOnlyStateMachine) DeleteCharge(ctx context.Context, patch meta.PatchDelete) error
func (*CreditsOnlyStateMachine) ExtendCharge ¶
func (s *CreditsOnlyStateMachine) ExtendCharge(ctx context.Context, patch meta.PatchExtend) error
func (*CreditsOnlyStateMachine) FinalizeRealizationRun ¶
func (s *CreditsOnlyStateMachine) FinalizeRealizationRun(ctx context.Context) error
func (CreditsOnlyStateMachine) IsAfterCollectionPeriod ¶
func (CreditsOnlyStateMachine) IsAfterServicePeriod ¶
func (s CreditsOnlyStateMachine) IsAfterServicePeriod() bool
func (CreditsOnlyStateMachine) IsInsideServicePeriod ¶
func (s CreditsOnlyStateMachine) IsInsideServicePeriod() bool
func (*CreditsOnlyStateMachine) ShrinkCharge ¶
func (s *CreditsOnlyStateMachine) ShrinkCharge(ctx context.Context, patch meta.PatchShrink) error
func (*CreditsOnlyStateMachine) StartFinalRealizationRun ¶
func (s *CreditsOnlyStateMachine) StartFinalRealizationRun(ctx context.Context) error
func (CreditsOnlyStateMachine) SyncFeatureIDFromFeatureMeter ¶
type LineEngine ¶
type LineEngine struct {
// contains filtered or unexported fields
}
func (*LineEngine) BuildStandardInvoiceLines ¶
func (e *LineEngine) BuildStandardInvoiceLines(ctx context.Context, input billing.BuildStandardInvoiceLinesInput) (billing.StandardLines, error)
func (*LineEngine) BuildStandardLinesForGatheringPreview ¶
func (e *LineEngine) BuildStandardLinesForGatheringPreview(ctx context.Context, input billing.BuildStandardInvoiceLinesInput) (billing.StandardLines, error)
func (*LineEngine) GetLineEngineType ¶
func (e *LineEngine) GetLineEngineType() billing.LineEngineType
func (*LineEngine) IsLineBillableAsOf ¶
func (e *LineEngine) IsLineBillableAsOf(_ context.Context, input billing.IsLineBillableAsOfInput) (bool, error)
func (*LineEngine) OnCollectionCompleted ¶
func (e *LineEngine) OnCollectionCompleted(ctx context.Context, input billing.OnCollectionCompletedInput) (billing.StandardLines, error)
func (*LineEngine) OnInvoiceIssued ¶
func (e *LineEngine) OnInvoiceIssued(ctx context.Context, input billing.OnInvoiceIssuedInput) error
func (*LineEngine) OnMutableInvoiceLinesEditedViaAPI ¶
func (e *LineEngine) OnMutableInvoiceLinesEditedViaAPI(ctx context.Context, input billing.OnMutableInvoiceUpdateInput) (billing.OnMutableInvoiceUpdateResult, error)
func (*LineEngine) OnMutableStandardLinesDeletedBySystem ¶
func (e *LineEngine) OnMutableStandardLinesDeletedBySystem(ctx context.Context, input billing.OnMutableStandardLinesDeletedInput) error
func (*LineEngine) OnPaymentAuthorized ¶
func (e *LineEngine) OnPaymentAuthorized(ctx context.Context, input billing.OnPaymentAuthorizedInput) error
func (*LineEngine) OnPaymentSettled ¶
func (e *LineEngine) OnPaymentSettled(ctx context.Context, input billing.OnPaymentSettledInput) error
func (*LineEngine) OnStandardInvoiceCreated ¶
func (e *LineEngine) OnStandardInvoiceCreated(ctx context.Context, input billing.OnStandardInvoiceCreatedInput) (billing.StandardLines, error)
func (*LineEngine) OnUnsupportedCreditNote ¶
func (e *LineEngine) OnUnsupportedCreditNote(ctx context.Context, input billing.OnUnsupportedCreditNoteInput) error
func (*LineEngine) SplitGatheringLine ¶
func (e *LineEngine) SplitGatheringLine(_ context.Context, input billing.SplitGatheringLineInput) (billing.SplitGatheringLineResult, error)
func (*LineEngine) ValidateMutableInvoiceLineEditViaAPI ¶
func (e *LineEngine) ValidateMutableInvoiceLineEditViaAPI(ctx context.Context, input billing.OnMutableInvoiceUpdateInput) error
type StateMachine ¶
type StateMachine = chargestatemachine.StateMachine[usagebased.Charge]
type StateMachineConfig ¶
type StateMachineConfig struct {
Charge usagebased.Charge
Adapter usagebased.Adapter
Rater usagebasedrating.Service
Runs *usagebasedrun.Service
Logger *slog.Logger
CustomerOverride billing.CustomerOverrideWithDetails
FeatureMeter feature.FeatureMeter
CurrencyCalculator currencyx.Calculator
}
func (StateMachineConfig) Validate ¶
func (c StateMachineConfig) Validate() error
Source Files
¶
Click to show internal directories.
Click to hide internal directories.