Documentation
¶
Index ¶
- func ExecuteTriggerWithAllowInStates(states ...billing.InvoiceStatus) executeTriggerApplyOptionFunc
- func ExecuteTriggerWithEditCallback(cb editCallbackFunc) executeTriggerApplyOptionFunc
- func ExecuteTriggerWithIncludeDeletedLines(includeDeletedLines bool) executeTriggerApplyOptionFunc
- func GetEarliestValidInvoiceAt(lines billing.LineChildren) time.Time
- func GetInvoiceWithEarliestCollectionAt(invoices []billing.Invoice) billing.Invoice
- func GetLatestValidInvoiceAtAsOf(lines billing.LineChildren, asOf time.Time) time.Time
- func TranscationForGatheringInvoiceManipulation[T any](ctx context.Context, svc *Service, customerID customer.CustomerID, ...) (T, error)
- func UpdateInvoiceCollectionAt(invoice *billing.Invoice, collection billing.CollectionConfig) bool
- type Config
- type InvoiceStateMachine
- func (m *InvoiceStateMachine) AdvanceUntilStateStable(ctx context.Context) error
- func (m *InvoiceStateMachine) CanFire(ctx context.Context, trigger billing.InvoiceTrigger) (bool, error)
- func (m *InvoiceStateMachine) FireAndActivate(ctx context.Context, trigger billing.InvoiceTrigger) error
- func (m *InvoiceStateMachine) HandleInvoiceTrigger(ctx context.Context, trigger billing.InvoiceTriggerInput) error
- func (m *InvoiceStateMachine) StatusDetails(ctx context.Context) (billing.InvoiceStatusDetails, error)
- func (m *InvoiceStateMachine) TriggerFailed(ctx context.Context) error
- type InvoiceStateMachineCallback
- type Service
- func (s *Service) AdvanceInvoice(ctx context.Context, input billing.AdvanceInvoiceInput) (billing.Invoice, error)
- func (s *Service) ApproveInvoice(ctx context.Context, input billing.ApproveInvoiceInput) (billing.Invoice, error)
- func (s *Service) CreatePendingInvoiceLines(ctx context.Context, input billing.CreateInvoiceLinesInput) ([]*billing.Line, error)
- func (s *Service) CreateProfile(ctx context.Context, input billing.CreateProfileInput) (*billing.Profile, error)
- func (s *Service) DeleteCustomerOverride(ctx context.Context, input billing.DeleteCustomerOverrideInput) error
- func (s *Service) DeleteInvoice(ctx context.Context, input billing.DeleteInvoiceInput) error
- func (s *Service) DeleteProfile(ctx context.Context, input billing.DeleteProfileInput) error
- func (s *Service) GenerateInvoiceSequenceNumber(ctx context.Context, in billing.SequenceGenerationInput, ...) (string, error)
- func (s Service) GetAdvancementStrategy() billing.AdvancementStrategy
- func (s *Service) GetCustomerOverride(ctx context.Context, input billing.GetCustomerOverrideInput) (billing.CustomerOverrideWithDetails, error)
- func (s *Service) GetDefaultProfile(ctx context.Context, input billing.GetDefaultProfileInput) (*billing.Profile, error)
- func (s *Service) GetInvoiceByID(ctx context.Context, input billing.GetInvoiceByIdInput) (billing.Invoice, error)
- func (s *Service) GetLinesForSubscription(ctx context.Context, input billing.GetLinesForSubscriptionInput) ([]*billing.Line, error)
- func (s *Service) GetProfile(ctx context.Context, input billing.GetProfileInput) (*billing.Profile, error)
- func (s Service) InvoiceCalculator() invoicecalc.Calculator
- func (s *Service) InvoicePendingLines(ctx context.Context, input billing.InvoicePendingLinesInput) ([]billing.Invoice, error)
- func (s *Service) IsAppUsed(ctx context.Context, appID app.AppID) error
- func (s *Service) ListCustomerOverrides(ctx context.Context, input billing.ListCustomerOverridesInput) (billing.ListCustomerOverridesResult, error)
- func (s *Service) ListInvoices(ctx context.Context, input billing.ListInvoicesInput) (billing.ListInvoicesResponse, error)
- func (s *Service) ListProfiles(ctx context.Context, input billing.ListProfilesInput) (billing.ListProfilesResult, error)
- func (s *Service) ProvisionDefaultBillingProfile(ctx context.Context, namespace string) error
- func (s *Service) RetryInvoice(ctx context.Context, input billing.RetryInvoiceInput) (billing.Invoice, error)
- func (s Service) SimulateInvoice(ctx context.Context, input billing.SimulateInvoiceInput) (billing.Invoice, error)
- func (s *Service) SnapshotLineQuantity(ctx context.Context, input billing.SnapshotLineQuantityInput) (*billing.Line, error)
- func (s *Service) TriggerInvoice(ctx context.Context, input billing.InvoiceTriggerServiceInput) error
- func (s *Service) UpdateInvoice(ctx context.Context, input billing.UpdateInvoiceInput) (billing.Invoice, error)
- func (s *Service) UpdateInvoiceFields(ctx context.Context, input billing.UpdateInvoiceFieldsInput) error
- func (s *Service) UpdateProfile(ctx context.Context, input billing.UpdateProfileInput) (*billing.Profile, error)
- func (s *Service) UpsertCustomerOverride(ctx context.Context, input billing.UpsertCustomerOverrideInput) (billing.CustomerOverrideWithDetails, error)
- func (s *Service) UpsertValidationIssues(ctx context.Context, input billing.UpsertValidationIssuesInput) error
- func (s Service) WithInvoiceCalculator(calc invoicecalc.Calculator) *Service
- func (s *Service) WithInvoiceStateMachine(ctx context.Context, invoice billing.Invoice, cb InvoiceStateMachineCallback) (billing.Invoice, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecuteTriggerWithAllowInStates ¶
func ExecuteTriggerWithAllowInStates(states ...billing.InvoiceStatus) executeTriggerApplyOptionFunc
func ExecuteTriggerWithEditCallback ¶
func ExecuteTriggerWithEditCallback(cb editCallbackFunc) executeTriggerApplyOptionFunc
func ExecuteTriggerWithIncludeDeletedLines ¶
func ExecuteTriggerWithIncludeDeletedLines(includeDeletedLines bool) executeTriggerApplyOptionFunc
func GetEarliestValidInvoiceAt ¶
func GetEarliestValidInvoiceAt(lines billing.LineChildren) time.Time
func TranscationForGatheringInvoiceManipulation ¶
func TranscationForGatheringInvoiceManipulation[T any](ctx context.Context, svc *Service, customerID customer.CustomerID, fn func(ctx context.Context) (T, error)) (T, error)
TranscationForGatheringInvoiceManipulation is a helper function that wraps the given function in a transaction and ensures that an update lock is held on the customer record. This is useful when you need to manipulate the gathering invoices, as we cannot lock an invoice, that doesn't exist yet.
func UpdateInvoiceCollectionAt ¶
func UpdateInvoiceCollectionAt(invoice *billing.Invoice, collection billing.CollectionConfig) bool
UpdateInvoiceCollectionAt updates the collectionAt attribute of the invoice with gathering type using the customers collection configuration. It returns true if the attribute has been updated. The collectionAt is calculated by adding the collection interval (from CollectionConfig) to the earliest invoicedAt timestamp of the invoice lines on the gathering invoice.
Types ¶
type Config ¶
type Config struct {
Adapter billing.Adapter
CustomerService customer.Service
AppService app.Service
Logger *slog.Logger
FeatureService feature.FeatureConnector
MeterService meter.Service
StreamingConnector streaming.Connector
Publisher eventbus.Publisher
AdvancementStrategy billing.AdvancementStrategy
}
type InvoiceStateMachine ¶
type InvoiceStateMachine struct {
Invoice billing.Invoice
Calculator invoicecalc.Calculator
StateMachine *stateless.StateMachine
}
func (*InvoiceStateMachine) AdvanceUntilStateStable ¶
func (m *InvoiceStateMachine) AdvanceUntilStateStable(ctx context.Context) error
func (*InvoiceStateMachine) CanFire ¶
func (m *InvoiceStateMachine) CanFire(ctx context.Context, trigger billing.InvoiceTrigger) (bool, error)
func (*InvoiceStateMachine) FireAndActivate ¶
func (m *InvoiceStateMachine) FireAndActivate(ctx context.Context, trigger billing.InvoiceTrigger) error
FireAndActivate fires the trigger and activates the new state, if activation fails it automatically transitions to the failed state and activates that. In addition to the activation a calculation is always performed to ensure that the invoice is up to date.
func (*InvoiceStateMachine) HandleInvoiceTrigger ¶
func (m *InvoiceStateMachine) HandleInvoiceTrigger(ctx context.Context, trigger billing.InvoiceTriggerInput) error
func (*InvoiceStateMachine) StatusDetails ¶
func (m *InvoiceStateMachine) StatusDetails(ctx context.Context) (billing.InvoiceStatusDetails, error)
func (*InvoiceStateMachine) TriggerFailed ¶
func (m *InvoiceStateMachine) TriggerFailed(ctx context.Context) error
type InvoiceStateMachineCallback ¶
type InvoiceStateMachineCallback func(context.Context, *InvoiceStateMachine) error
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) AdvanceInvoice ¶
func (*Service) ApproveInvoice ¶
func (*Service) CreatePendingInvoiceLines ¶
func (*Service) CreateProfile ¶
func (*Service) DeleteCustomerOverride ¶
func (*Service) DeleteInvoice ¶
func (*Service) DeleteProfile ¶
func (*Service) GenerateInvoiceSequenceNumber ¶
func (s *Service) GenerateInvoiceSequenceNumber(ctx context.Context, in billing.SequenceGenerationInput, def billing.SequenceDefinition) (string, error)
func (Service) GetAdvancementStrategy ¶
func (s Service) GetAdvancementStrategy() billing.AdvancementStrategy
func (*Service) GetCustomerOverride ¶
func (s *Service) GetCustomerOverride(ctx context.Context, input billing.GetCustomerOverrideInput) (billing.CustomerOverrideWithDetails, error)
func (*Service) GetDefaultProfile ¶
func (*Service) GetInvoiceByID ¶
func (*Service) GetLinesForSubscription ¶
func (*Service) GetProfile ¶
func (Service) InvoiceCalculator ¶
func (s Service) InvoiceCalculator() invoicecalc.Calculator
func (*Service) InvoicePendingLines ¶
func (*Service) ListCustomerOverrides ¶
func (s *Service) ListCustomerOverrides(ctx context.Context, input billing.ListCustomerOverridesInput) (billing.ListCustomerOverridesResult, error)
func (*Service) ListInvoices ¶
func (s *Service) ListInvoices(ctx context.Context, input billing.ListInvoicesInput) (billing.ListInvoicesResponse, error)
func (*Service) ListProfiles ¶
func (s *Service) ListProfiles(ctx context.Context, input billing.ListProfilesInput) (billing.ListProfilesResult, error)
func (*Service) ProvisionDefaultBillingProfile ¶
func (*Service) RetryInvoice ¶
func (Service) SimulateInvoice ¶
func (*Service) SnapshotLineQuantity ¶
func (*Service) TriggerInvoice ¶
func (*Service) UpdateInvoice ¶
func (*Service) UpdateInvoiceFields ¶
func (*Service) UpdateProfile ¶
func (*Service) UpsertCustomerOverride ¶
func (s *Service) UpsertCustomerOverride(ctx context.Context, input billing.UpsertCustomerOverrideInput) (billing.CustomerOverrideWithDetails, error)
func (*Service) UpsertValidationIssues ¶
func (Service) WithInvoiceCalculator ¶
func (s Service) WithInvoiceCalculator(calc invoicecalc.Calculator) *Service
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
lineservice package contains the implementation of the LineAdapter interface which acts as a adapter between the specific line types and the billing service.
|
lineservice package contains the implementation of the LineAdapter interface which acts as a adapter between the specific line types and the billing service. |