Documentation
¶
Index ¶
- Constants
- Variables
- func EncodeValidationIssues[T error](err T) map[string]interface{}
- func ValidationWithComponent(component ComponentName, err error) error
- func ValidationWithFieldPrefix(prefix string, err error) error
- type Adapter
- type AdvanceInvoiceInput
- type AlignmentKind
- type AppReference
- type ApproveInvoiceInput
- type AssociateLinesToInvoiceAdapterInput
- type AssociatedLineCountsAdapterInput
- type AssociatedLineCountsAdapterResponse
- type BaseProfile
- type CollectionConfig
- type CollectionMethod
- type CollectionOverrideConfig
- type ComponentName
- type ConflictError
- type CreateCustomerOverrideInput
- type CreateInvoiceAdapterInput
- type CreateInvoiceAdapterRespone
- type CreateInvoiceLinesInput
- type CreateProfileAppsInput
- type CreateProfileInput
- type CreateWorkflowConfigInput
- type CustomerMetadata
- type CustomerOverride
- type CustomerOverrideAdapter
- type CustomerOverrideService
- type CustomerUsageAttribution
- type DeleteCustomerOverrideInput
- type DeleteInvoiceInput
- type DeleteInvoiceLineInput
- type DeleteInvoicesAdapterInput
- type DeleteProfileInput
- type FinalizeInvoiceResult
- type FlatFeeCategory
- type FlatFeeLine
- type GetCustomerOverrideAdapterInput
- type GetCustomerOverrideInput
- type GetDefaultProfileInput
- type GetInvoiceByIdInput
- type GetInvoiceLineAdapterInput
- type GetInvoiceLineInput
- type GetInvoiceLineOwnershipAdapterInput
- type GetInvoiceOwnershipAdapterInput
- type GetLinesForSubscriptionInput
- type GetOwnershipAdapterResponse
- type GetProfileInput
- type GetProfileWithCustomerOverrideInput
- type GranularityResolution
- type HasCustomerOverrideReferencingProfileAdapterInput
- type Invoice
- func (i Invoice) Clone() Invoice
- func (i *Invoice) FlattenLinesByID() map[string]*Line
- func (i *Invoice) HasCriticalValidationIssues() bool
- func (i Invoice) InvoiceID() InvoiceID
- func (i *Invoice) MergeValidationIssues(errIn error, reportingComponent ComponentName) error
- func (i Invoice) RemoveCircularReferences() Invoice
- func (i Invoice) RemoveMetaForCompare() Invoice
- type InvoiceAction
- type InvoiceAdapter
- type InvoiceBase
- type InvoiceCustomer
- type InvoiceExpand
- type InvoiceExternalIDs
- type InvoiceID
- type InvoiceLineAdapter
- type InvoiceLineService
- type InvoiceLineStatus
- type InvoiceLineType
- type InvoicePendingLinesInput
- type InvoiceService
- type InvoiceStatus
- type InvoiceStatusDetails
- type InvoiceType
- type InvoiceWorkflow
- type InvoicingApp
- type InvoicingConfig
- type InvoicingOverrideConfig
- type Line
- func (c Line) ChildrenWithIDReuse(l []*Line) LineChildren
- func (i Line) Clone() *Line
- func (i Line) CloneWithoutDependencies() *Line
- func (i *Line) DisassociateChildren()
- func (i Line) LineID() LineID
- func (i Line) RemoveCircularReferences() *Line
- func (i Line) RemoveMetaForCompare() *Line
- func (i *Line) SaveDBSnapshot()
- func (i Line) Validate() error
- func (i Line) ValidateFee() error
- func (i Line) ValidateUsageBased() error
- func (i Line) WithoutDBState() *Line
- type LineBase
- type LineChildren
- func (c *LineChildren) Append(l ...*Line)
- func (c LineChildren) Clone() LineChildren
- func (c LineChildren) GetByID(id string) *Line
- func (c LineChildren) Map(fn func(*Line) *Line) LineChildren
- func (c *LineChildren) RemoveByID(id string) bool
- func (c *LineChildren) ReplaceByID(id string, newLine *Line) bool
- type LineDiscount
- type LineDiscounts
- type LineExternalIDs
- type LineID
- type LineWithCustomer
- type ListInvoiceLinesAdapterInput
- type ListInvoicesInput
- type ListInvoicesResponse
- type ListProfilesInput
- type ListProfilesResult
- type LockCustomerForUpdateAdapterInput
- type LockInvoicesForUpdateInput
- type Metadata
- type NotFoundError
- type PaymentConfig
- type PaymentOverrideConfig
- type Period
- type Price
- type Profile
- type ProfileAdapter
- type ProfileAppReferences
- type ProfileApps
- type ProfileExpand
- type ProfileService
- type ProfileWithCustomerDetails
- type RetryInvoiceInput
- type Service
- type SubscriptionReference
- type SupplierContact
- type TaxConfig
- type Totals
- type UpdateAfterDeleteError
- type UpdateCustomerOverrideAdapterInput
- type UpdateCustomerOverrideInput
- type UpdateInvoiceAdapterInput
- type UpdateInvoiceLineAdapterInput
- type UpdateInvoiceLineBaseInput
- type UpdateInvoiceLineFlatFeeInput
- type UpdateInvoiceLineInput
- type UpdateInvoiceLineUsageBasedInput
- type UpdateInvoiceLinesInternalInput
- type UpdateProfileAdapterInput
- type UpdateProfileInput
- type UpsertCustomerOverrideAdapterInput
- type UpsertInvoiceLinesAdapterInput
- type UpsertInvoiceResult
- type UpsertResults
- func (u *UpsertResults) AddLineExternalID(lineID string, externalID string)
- func (u *UpsertResults) GetExternalID() (string, bool)
- func (u *UpsertResults) GetInvoiceNumber() (string, bool)
- func (u *UpsertResults) GetLineExternalID(lineID string) (string, bool)
- func (u *UpsertResults) GetLineExternalIDs() map[string]string
- func (u *UpsertResults) SetExternalID(externalID string)
- func (u *UpsertResults) SetInvoiceNumber(invoiceNumber string)
- type UsageBasedLine
- type ValidationError
- type ValidationIssue
- type ValidationIssueSeverity
- type ValidationIssues
- type VersionedCustomerUsageAttribution
- type WorkflowConfig
Constants ¶
const ( EntityCustomerOverride = "BillingCustomerOverride" EntityCustomer = "Customer" EntityDefaultProfile = "DefaultBillingProfile" EntityInvoice = "Invoice" EntityInvoiceLine = "InvoiceLine" )
const (
CustomerUsageAttributionTypeVersion = "customer_usage_attribution.v1"
)
const (
DefaultMeterResolution = time.Minute
)
const (
// LineMaximumSpendReferenceID is a discount applied due to maximum spend.
LineMaximumSpendReferenceID = "line_maximum_spend"
)
Variables ¶
var ( ErrDefaultProfileAlreadyExists = NewValidationError("default_profile_exists", "default profile already exists") ErrDefaultProfileNotFound = NewValidationError("default_profile_not_found", "default profile not found") ErrProfileNotFound = NewValidationError("profile_not_found", "profile not found") ErrProfileAlreadyDeleted = NewValidationError("profile_already_deleted", "profile already deleted") ErrProfileReferencedByOverrides = NewValidationError("profile_referenced", "profile is referenced by customer overrides") ErrCustomerOverrideNotFound = NewValidationError("customer_override_not_found", "customer override not found") ErrCustomerOverrideAlreadyDeleted = NewValidationError("customer_override_deleted", "customer override already deleted") ErrCustomerNotFound = NewValidationError("customer_not_found", "customer not found") ErrCustomerDeleted = NewValidationError("customer_deleted", "customer has been deleted") ErrFieldRequired = NewValidationError("field_required", "field is required") ErrFieldMustBePositive = NewValidationError("field_must_be_positive", "field must be positive") ErrFieldMustBePositiveOrZero = NewValidationError("field_must_be_positive_or_zero", "field must be positive or zero") ErrInvoiceCannotAdvance = NewValidationError("invoice_cannot_advance", "invoice cannot advance") ErrInvoiceCannotBeEdited = NewValidationError("invoice_cannot_be_edited", "invoice cannot be edited in the current state") ErrInvoiceActionNotAvailable = NewValidationError("invoice_action_not_available", "invoice action not available") ErrInvoiceLinesNotBillable = NewValidationError("invoice_lines_not_billable", "some invoice lines are not billable") ErrInvoiceEmpty = NewValidationError("invoice_empty", "invoice is empty") ErrInvoiceDeleteFailed = NewValidationError("invoice_delete_failed", "invoice delete failed") ErrInvoiceLineFeatureHasNoMeters = NewValidationError("invoice_line_feature_has_no_meters", "usage based invoice line: feature has no meters") ErrInvoiceLineVolumeSplitNotSupported = NewValidationError("invoice_line_graduated_split_not_supported", "graduated tiered pricing is not supported for split periods") ErrInvoiceLineNoTiers = NewValidationError("invoice_line_no_tiers", "usage based invoice line: no tiers found") ErrInvoiceLineMissingOpenEndedTier = NewValidationError("invoice_line_missing_open_ended_tier", "usage based invoice line: missing open ended tier") ErrInvoiceLineDeleteInvalidStatus = NewValidationError("invoice_line_delete_invalid_status", "invoice line cannot be deleted in the current state (only valid lines can be deleted)") ErrInvoiceCreateNoLines = NewValidationError("invoice_create_no_lines", "the new invoice would have no lines") ErrInvoiceCreateUBPLineCustomerHasNoSubjects = NewValidationError("invoice_create_ubp_line_customer_has_no_subjects", "creating an usage based line: customer has no subjects") ErrInvoiceCreateUBPLinePeriodIsEmpty = NewValidationError("invoice_create_ubp_line_period_is_empty", "creating an usage based line: truncated period is empty") ErrInvoiceLineCurrencyMismatch = NewValidationError("invoice_line_currency_mismatch", "invoice line currency mismatch") )
var DefaultWorkflowConfig = WorkflowConfig{ Collection: CollectionConfig{ Alignment: AlignmentKindSubscription, Interval: lo.Must(datex.ISOString("PT2H").Parse()), }, Invoicing: InvoicingConfig{ AutoAdvance: true, DraftPeriod: lo.Must(datex.ISOString("P1D").Parse()), DueAfter: lo.Must(datex.ISOString("P1W").Parse()), }, Payment: PaymentConfig{ CollectionMethod: CollectionMethodChargeAutomatically, }, }
var InvoiceExpandAll = InvoiceExpand{ Preceding: true, WorkflowApps: true, Lines: true, DeletedLines: false, SplitLines: false, }
var ProfileExpandAll = ProfileExpand{ Apps: true, }
Functions ¶
func EncodeValidationIssues ¶
func ValidationWithComponent ¶
func ValidationWithComponent(component ComponentName, err error) error
ValidationWithComponent wraps an error with a component name, if error is nil, it returns nil This can be used to add context to an error when we are crossing service boundaries.
func ValidationWithFieldPrefix ¶
ValidationWithFieldPrefix wraps an error with a field prefix, if error is nil, it returns nil This can be used to delegate validation duties to a sub-entity. (e.g. lines don't need to know about the path in the invoice they are residing at)
Types ¶
type Adapter ¶
type Adapter interface {
ProfileAdapter
CustomerOverrideAdapter
InvoiceLineAdapter
InvoiceAdapter
entutils.TxCreator
}
type AdvanceInvoiceInput ¶
type AdvanceInvoiceInput = InvoiceID
type AlignmentKind ¶
type AlignmentKind string
AlignmentKind specifies what governs when an invoice is issued
const ( // AlignmentKindSubscription specifies that the invoice is issued based on the subscription period ( // e.g. whenever a due line item is added, it will trigger an invoice generation after the collection period) AlignmentKindSubscription AlignmentKind = "subscription" )
func (AlignmentKind) Values ¶
func (k AlignmentKind) Values() []string
type AppReference ¶
type AppReference struct {
ID string `json:"id"`
Type appentitybase.AppType `json:"type"`
}
func (AppReference) Validate ¶
func (a AppReference) Validate() error
type ApproveInvoiceInput ¶
type ApproveInvoiceInput = InvoiceID
type AssociateLinesToInvoiceAdapterInput ¶
func (AssociateLinesToInvoiceAdapterInput) Validate ¶
func (i AssociateLinesToInvoiceAdapterInput) Validate() error
type AssociatedLineCountsAdapterInput ¶
type AssociatedLineCountsAdapterInput = genericMultiInvoiceInput
type BaseProfile ¶
type BaseProfile struct {
ID string `json:"id"`
Namespace string `json:"namespace"`
Name string `json:"name"`
Description *string `json:"description,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt *time.Time `json:"deletedAt,omitempty"`
WorkflowConfig WorkflowConfig `json:"workflow"`
Supplier SupplierContact `json:"supplier"`
Default bool `json:"default"`
Metadata Metadata `json:"metadata"`
AppReferences *ProfileAppReferences `json:"appReferences,omitempty"`
}
func (BaseProfile) Validate ¶
func (p BaseProfile) Validate() error
type CollectionConfig ¶
type CollectionConfig struct {
Alignment AlignmentKind `json:"alignment"`
Interval datex.Period `json:"period,omitempty"`
}
CollectionConfig groups fields related to item collection.
func (*CollectionConfig) Validate ¶
func (c *CollectionConfig) Validate() error
type CollectionMethod ¶
type CollectionMethod string
const ( // CollectionMethodChargeAutomatically charges the customer automatically based on previously saved card data CollectionMethodChargeAutomatically CollectionMethod = "charge_automatically" // CollectionMethodSendInvoice sends an invoice to the customer along with the payment instructions/links CollectionMethodSendInvoice CollectionMethod = "send_invoice" )
func (CollectionMethod) Values ¶
func (c CollectionMethod) Values() []string
type CollectionOverrideConfig ¶
type CollectionOverrideConfig struct {
Alignment *AlignmentKind `json:"alignment,omitempty"`
Interval *datex.Period `json:"interval,omitempty"`
}
func (*CollectionOverrideConfig) Validate ¶
func (c *CollectionOverrideConfig) Validate() error
type ComponentName ¶
type ComponentName string
func AppTypeCapabilityToComponent ¶
func AppTypeCapabilityToComponent(appType appentitybase.AppType, cap appentitybase.CapabilityType, op string) ComponentName
type ConflictError ¶
func (ConflictError) Error ¶
func (e ConflictError) Error() string
func (ConflictError) Unwrap ¶
func (e ConflictError) Unwrap() error
type CreateCustomerOverrideInput ¶
type CreateCustomerOverrideInput struct {
Namespace string `json:"namespace"`
CustomerID string `json:"customerID"`
ProfileID string `json:"billingProfile,omitempty"`
Collection CollectionOverrideConfig `json:"collection"`
Invoicing InvoicingOverrideConfig `json:"invoicing"`
Payment PaymentOverrideConfig `json:"payment"`
}
func (CreateCustomerOverrideInput) Validate ¶
func (c CreateCustomerOverrideInput) Validate() error
type CreateInvoiceAdapterInput ¶
type CreateInvoiceAdapterInput struct {
Namespace string
Customer customerentity.Customer
Profile Profile
Currency currencyx.Code
Status InvoiceStatus
Metadata map[string]string
IssuedAt time.Time
Type InvoiceType
Description *string
DueAt *time.Time
Totals Totals
}
func (CreateInvoiceAdapterInput) Validate ¶
func (c CreateInvoiceAdapterInput) Validate() error
type CreateInvoiceAdapterRespone ¶
type CreateInvoiceAdapterRespone = Invoice
type CreateInvoiceLinesInput ¶
type CreateInvoiceLinesInput struct {
Namespace string
Lines []LineWithCustomer
}
func (CreateInvoiceLinesInput) Validate ¶
func (c CreateInvoiceLinesInput) Validate() error
type CreateProfileAppsInput ¶
type CreateProfileAppsInput = ProfileAppReferences
type CreateProfileInput ¶
type CreateProfileInput struct {
Namespace string `json:"namespace"`
Name string `json:"name"`
Description *string `json:"description,omitempty"`
Metadata map[string]string `json:"metadata"`
Supplier SupplierContact `json:"supplier"`
Default bool `json:"default"`
WorkflowConfig WorkflowConfig `json:"workflowConfig"`
Apps CreateProfileAppsInput `json:"apps"`
}
func (CreateProfileInput) Validate ¶
func (i CreateProfileInput) Validate() error
type CreateWorkflowConfigInput ¶
type CreateWorkflowConfigInput struct {
WorkflowConfig
}
type CustomerMetadata ¶
type CustomerMetadata struct {
Name string `json:"name"`
}
type CustomerOverride ¶
type CustomerOverride struct {
Namespace string `json:"namespace"`
ID string `json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt *time.Time `json:"deletedAt,omitempty"`
CustomerID string `json:"customerID"`
Profile *Profile `json:"billingProfile,omitempty"`
Collection CollectionOverrideConfig `json:"collection"`
Invoicing InvoicingOverrideConfig `json:"invoicing"`
Payment PaymentOverrideConfig `json:"payment"`
}
func (CustomerOverride) Validate ¶
func (c CustomerOverride) Validate() error
type CustomerOverrideAdapter ¶
type CustomerOverrideAdapter interface {
CreateCustomerOverride(ctx context.Context, input CreateCustomerOverrideInput) (*CustomerOverride, error)
GetCustomerOverride(ctx context.Context, input GetCustomerOverrideAdapterInput) (*CustomerOverride, error)
UpdateCustomerOverride(ctx context.Context, input UpdateCustomerOverrideAdapterInput) (*CustomerOverride, error)
DeleteCustomerOverride(ctx context.Context, input DeleteCustomerOverrideInput) error
// UpsertCustomerOverride upserts a customer override ignoring the transactional context, the override
// will be empty.
UpsertCustomerOverride(ctx context.Context, input UpsertCustomerOverrideAdapterInput) error
LockCustomerForUpdate(ctx context.Context, input LockCustomerForUpdateAdapterInput) error
GetCustomerOverrideReferencingProfile(ctx context.Context, input HasCustomerOverrideReferencingProfileAdapterInput) ([]customerentity.CustomerID, error)
}
type CustomerOverrideService ¶
type CustomerOverrideService interface {
CreateCustomerOverride(ctx context.Context, input CreateCustomerOverrideInput) (*CustomerOverride, error)
UpdateCustomerOverride(ctx context.Context, input UpdateCustomerOverrideInput) (*CustomerOverride, error)
GetCustomerOverride(ctx context.Context, input GetCustomerOverrideInput) (*CustomerOverride, error)
DeleteCustomerOverride(ctx context.Context, input DeleteCustomerOverrideInput) error
GetProfileWithCustomerOverride(ctx context.Context, input GetProfileWithCustomerOverrideInput) (*ProfileWithCustomerDetails, error)
}
type CustomerUsageAttribution ¶
type CustomerUsageAttribution = customerentity.CustomerUsageAttribution
type DeleteCustomerOverrideInput ¶
type DeleteCustomerOverrideInput namespacedCustomerID
func (DeleteCustomerOverrideInput) Validate ¶
func (d DeleteCustomerOverrideInput) Validate() error
type DeleteInvoiceInput ¶
type DeleteInvoiceInput = InvoiceID
type DeleteInvoiceLineInput ¶
type DeleteInvoiceLineInput = LineID
type DeleteInvoicesAdapterInput ¶
type DeleteInvoicesAdapterInput = genericMultiInvoiceInput
type DeleteProfileInput ¶
type DeleteProfileInput genericNamespaceID
func (DeleteProfileInput) Validate ¶
func (i DeleteProfileInput) Validate() error
type FinalizeInvoiceResult ¶
type FinalizeInvoiceResult struct {
// contains filtered or unexported fields
}
func NewFinalizeInvoiceResult ¶
func NewFinalizeInvoiceResult() *FinalizeInvoiceResult
func (*FinalizeInvoiceResult) GetPaymentExternalID ¶
func (f *FinalizeInvoiceResult) GetPaymentExternalID() (string, bool)
func (*FinalizeInvoiceResult) SetPaymentExternalID ¶
func (f *FinalizeInvoiceResult) SetPaymentExternalID(paymentExternalID string)
type FlatFeeCategory ¶
type FlatFeeCategory string
const ( // FlatFeeCategoryRegular is a regular flat fee, that is based on the usage or a subscription. FlatFeeCategoryRegular FlatFeeCategory = "regular" // FlatFeeCategoryCommitment is a flat fee that is based on a commitment such as min spend. FlatFeeCategoryCommitment FlatFeeCategory = "commitment" )
func (FlatFeeCategory) Values ¶
func (FlatFeeCategory) Values() []string
type FlatFeeLine ¶
type FlatFeeLine struct {
ConfigID string `json:"configId"`
PerUnitAmount alpacadecimal.Decimal `json:"perUnitAmount"`
PaymentTerm productcatalog.PaymentTermType `json:"paymentTerm"`
Category FlatFeeCategory `json:"category"`
Quantity alpacadecimal.Decimal `json:"quantity"`
}
func (FlatFeeLine) Clone ¶
func (i FlatFeeLine) Clone() *FlatFeeLine
func (FlatFeeLine) Equal ¶
func (i FlatFeeLine) Equal(other *FlatFeeLine) bool
type GetCustomerOverrideAdapterInput ¶
type GetCustomerOverrideAdapterInput struct {
Customer customerentity.CustomerID
IncludeDeleted bool
}
func (GetCustomerOverrideAdapterInput) Validate ¶
func (i GetCustomerOverrideAdapterInput) Validate() error
type GetCustomerOverrideInput ¶
type GetCustomerOverrideInput namespacedCustomerID
func (GetCustomerOverrideInput) Validate ¶
func (g GetCustomerOverrideInput) Validate() error
type GetDefaultProfileInput ¶
type GetDefaultProfileInput struct {
Namespace string
}
func (GetDefaultProfileInput) Validate ¶
func (i GetDefaultProfileInput) Validate() error
type GetInvoiceByIdInput ¶
type GetInvoiceByIdInput struct {
Invoice InvoiceID
Expand InvoiceExpand
}
func (GetInvoiceByIdInput) Validate ¶
func (i GetInvoiceByIdInput) Validate() error
type GetInvoiceLineAdapterInput ¶
type GetInvoiceLineAdapterInput = LineID
type GetInvoiceLineInput ¶
type GetInvoiceLineInput = LineID
type GetInvoiceLineOwnershipAdapterInput ¶
type GetInvoiceLineOwnershipAdapterInput = LineID
type GetInvoiceOwnershipAdapterInput ¶
type GetInvoiceOwnershipAdapterInput = InvoiceID
type GetLinesForSubscriptionInput ¶
func (GetLinesForSubscriptionInput) Validate ¶
func (i GetLinesForSubscriptionInput) Validate() error
type GetProfileInput ¶
type GetProfileInput struct {
Profile models.NamespacedID
Expand ProfileExpand
}
func (GetProfileInput) Validate ¶
func (i GetProfileInput) Validate() error
type GetProfileWithCustomerOverrideInput ¶
type GetProfileWithCustomerOverrideInput namespacedCustomerID
func (GetProfileWithCustomerOverrideInput) Validate ¶
func (g GetProfileWithCustomerOverrideInput) Validate() error
type GranularityResolution ¶
type GranularityResolution string
const ( // GranularityResolutionDay provides line items for metered data per day GranularityResolutionDay GranularityResolution = "day" // GranularityResolutionPeriod provides one line item per period GranularityResolutionPeriod GranularityResolution = "period" )
func (GranularityResolution) Values ¶
func (r GranularityResolution) Values() []string
type HasCustomerOverrideReferencingProfileAdapterInput ¶
type HasCustomerOverrideReferencingProfileAdapterInput genericNamespaceID
func (HasCustomerOverrideReferencingProfileAdapterInput) Validate ¶
func (i HasCustomerOverrideReferencingProfileAdapterInput) Validate() error
type Invoice ¶
type Invoice struct {
InvoiceBase `json:",inline"`
// Line items
Lines LineChildren `json:"lines,omitempty"`
ValidationIssues ValidationIssues `json:"validationIssues,omitempty"`
Totals Totals `json:"totals"`
// private fields required by the service
ExpandedFields InvoiceExpand `json:"-"`
}
func (*Invoice) FlattenLinesByID ¶
func (*Invoice) HasCriticalValidationIssues ¶
func (*Invoice) MergeValidationIssues ¶
func (i *Invoice) MergeValidationIssues(errIn error, reportingComponent ComponentName) error
func (Invoice) RemoveCircularReferences ¶
func (Invoice) RemoveMetaForCompare ¶
RemoveMetaForCompare returns a copy of the invoice without the fields that are not relevant for higher level tests that compare invoices. What gets removed: - Line's DB state - Line's dependencies are marked as resolved - Parent pointers are removed
type InvoiceAction ¶
type InvoiceAction string
const ( InvoiceActionAdvance InvoiceAction = "advance" InvoiceActionApprove InvoiceAction = "approve" InvoiceActionDelete InvoiceAction = "delete" InvoiceActionRetry InvoiceAction = "retry" InvoiceActionVoid InvoiceAction = "void" )
type InvoiceAdapter ¶
type InvoiceAdapter interface {
CreateInvoice(ctx context.Context, input CreateInvoiceAdapterInput) (CreateInvoiceAdapterRespone, error)
GetInvoiceById(ctx context.Context, input GetInvoiceByIdInput) (Invoice, error)
LockInvoicesForUpdate(ctx context.Context, input LockInvoicesForUpdateInput) error
DeleteInvoices(ctx context.Context, input DeleteInvoicesAdapterInput) error
ListInvoices(ctx context.Context, input ListInvoicesInput) (ListInvoicesResponse, error)
AssociatedLineCounts(ctx context.Context, input AssociatedLineCountsAdapterInput) (AssociatedLineCountsAdapterResponse, error)
UpdateInvoice(ctx context.Context, input UpdateInvoiceAdapterInput) (Invoice, error)
GetInvoiceOwnership(ctx context.Context, input GetInvoiceOwnershipAdapterInput) (GetOwnershipAdapterResponse, error)
}
type InvoiceBase ¶
type InvoiceBase struct {
Namespace string `json:"namespace"`
ID string `json:"id"`
Number *string `json:"number,omitempty"`
Description *string `json:"description,omitempty"`
Type InvoiceType `json:"type"`
Metadata map[string]string `json:"metadata"`
Currency currencyx.Code `json:"currency,omitempty"`
Timezone timezone.Timezone `json:"timezone,omitempty"`
Status InvoiceStatus `json:"status"`
StatusDetails InvoiceStatusDetails `json:"statusDetail,omitempty"`
Period *Period `json:"period,omitempty"`
DueAt *time.Time `json:"dueDate,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
VoidedAt *time.Time `json:"voidedAt,omitempty"`
DraftUntil *time.Time `json:"draftUntil,omitempty"`
IssuedAt *time.Time `json:"issuedAt,omitempty"`
DeletedAt *time.Time `json:"deletedAt,omitempty"`
// Customer is either a snapshot of the contact information of the customer at the time of invoice being sent
// or the data from the customer entity (draft state)
// This is required so that we are not modifying the invoice after it has been sent to the customer.
Customer InvoiceCustomer `json:"customer"`
Supplier SupplierContact `json:"supplier"`
Workflow *InvoiceWorkflow `json:"workflow,omitempty"`
ExternalIDs InvoiceExternalIDs `json:"externalIds,omitempty"`
}
type InvoiceCustomer ¶
type InvoiceCustomer struct {
CustomerID string `json:"customerId,omitempty"`
Name string `json:"name"`
BillingAddress *models.Address `json:"billingAddress,omitempty"`
Timezone *timezone.Timezone `json:"timezone,omitempty"`
UsageAttribution CustomerUsageAttribution `json:"usageAttribution"`
}
func (*InvoiceCustomer) Validate ¶
func (i *InvoiceCustomer) Validate() error
type InvoiceExpand ¶
type InvoiceExpand struct {
Preceding bool
WorkflowApps bool
Lines bool
DeletedLines bool
SplitLines bool
// GatheringTotals is used to calculate the totals of the invoice when gathering, this is temporary
// until we implement the full progressive billing stack.
GatheringTotals bool
}
func (InvoiceExpand) SetDeletedLines ¶
func (e InvoiceExpand) SetDeletedLines(v bool) InvoiceExpand
func (InvoiceExpand) SetGatheringTotals ¶
func (e InvoiceExpand) SetGatheringTotals(v bool) InvoiceExpand
func (InvoiceExpand) SetLines ¶
func (e InvoiceExpand) SetLines(v bool) InvoiceExpand
func (InvoiceExpand) SetSplitLines ¶
func (e InvoiceExpand) SetSplitLines(v bool) InvoiceExpand
func (InvoiceExpand) Validate ¶
func (e InvoiceExpand) Validate() error
type InvoiceExternalIDs ¶
type InvoiceID ¶
type InvoiceID models.NamespacedID
type InvoiceLineAdapter ¶
type InvoiceLineAdapter interface {
UpsertInvoiceLines(ctx context.Context, input UpsertInvoiceLinesAdapterInput) ([]*Line, error)
ListInvoiceLines(ctx context.Context, input ListInvoiceLinesAdapterInput) ([]*Line, error)
AssociateLinesToInvoice(ctx context.Context, input AssociateLinesToInvoiceAdapterInput) ([]*Line, error)
GetInvoiceLine(ctx context.Context, input GetInvoiceLineAdapterInput) (*Line, error)
GetLinesForSubscription(ctx context.Context, input GetLinesForSubscriptionInput) ([]*Line, error)
GetInvoiceLineOwnership(ctx context.Context, input GetInvoiceLineOwnershipAdapterInput) (GetOwnershipAdapterResponse, error)
}
type InvoiceLineService ¶
type InvoiceLineService interface {
CreatePendingInvoiceLines(ctx context.Context, input CreateInvoiceLinesInput) ([]*Line, error)
GetInvoiceLine(ctx context.Context, input GetInvoiceLineInput) (*Line, error)
GetLinesForSubscription(ctx context.Context, input GetLinesForSubscriptionInput) ([]*Line, error)
UpdateInvoiceLine(ctx context.Context, input UpdateInvoiceLineInput) (*Line, error)
DeleteInvoiceLine(ctx context.Context, input DeleteInvoiceLineInput) error
}
type InvoiceLineStatus ¶
type InvoiceLineStatus string
const ( // InvoiceLineStatusValid is a valid invoice line. InvoiceLineStatusValid InvoiceLineStatus = "valid" // InvoiceLineStatusSplit is a split invoice line (the child lines will have this set as parent). InvoiceLineStatusSplit InvoiceLineStatus = "split" // InvoiceLineStatusDetailed is a detailed invoice line. InvoiceLineStatusDetailed InvoiceLineStatus = "detailed" )
func (InvoiceLineStatus) Values ¶
func (InvoiceLineStatus) Values() []string
type InvoiceLineType ¶
type InvoiceLineType string
const ( // InvoiceLineTypeFee is an item that represents a single charge without meter backing. InvoiceLineTypeFee InvoiceLineType = "flat_fee" // InvoiceLineTypeUsageBased is an item that is added to the invoice and is usage based. InvoiceLineTypeUsageBased InvoiceLineType = "usage_based" )
func (InvoiceLineType) Values ¶
func (InvoiceLineType) Values() []string
type InvoicePendingLinesInput ¶
type InvoicePendingLinesInput struct {
Customer customerentity.CustomerID
IncludePendingLines mo.Option[[]string]
AsOf *time.Time
}
func (InvoicePendingLinesInput) Validate ¶
func (i InvoicePendingLinesInput) Validate() error
type InvoiceService ¶
type InvoiceService interface {
ListInvoices(ctx context.Context, input ListInvoicesInput) (ListInvoicesResponse, error)
GetInvoiceByID(ctx context.Context, input GetInvoiceByIdInput) (Invoice, error)
InvoicePendingLines(ctx context.Context, input InvoicePendingLinesInput) ([]Invoice, error)
// AdvanceInvoice advances the invoice to the next stage, the advancement is stopped until:
// - an error is occurred
// - the invoice is in a state that cannot be advanced (e.g. waiting for draft period to expire)
// - the invoice is advanced to the final state
AdvanceInvoice(ctx context.Context, input AdvanceInvoiceInput) (Invoice, error)
ApproveInvoice(ctx context.Context, input ApproveInvoiceInput) (Invoice, error)
RetryInvoice(ctx context.Context, input RetryInvoiceInput) (Invoice, error)
DeleteInvoice(ctx context.Context, input DeleteInvoiceInput) error
// UpdateInvoiceLinesInternal updates the specified invoice lines and ensures that invoice states are properly syncronized
// This method is intended to be used by OpenMeter internal services only, as it allows for updating invoice line values,
// that are not allowed to be updated by external services.
//
// The call also ensures that the invoice's state is properly updated and invoice immutability is also considered.
UpdateInvoiceLinesInternal(ctx context.Context, input UpdateInvoiceLinesInternalInput) error
}
type InvoiceStatus ¶
type InvoiceStatus string
const ( // InvoiceStatusGathering is the status of an invoice that is gathering the items to be invoiced. InvoiceStatusGathering InvoiceStatus = "gathering" InvoiceStatusDraftCreated InvoiceStatus = "draft_created" InvoiceStatusDraftUpdating InvoiceStatus = "draft_updating" InvoiceStatusDraftManualApprovalNeeded InvoiceStatus = "draft_manual_approval_needed" InvoiceStatusDraftValidating InvoiceStatus = "draft_validating" InvoiceStatusDraftInvalid InvoiceStatus = "draft_invalid" InvoiceStatusDraftSyncing InvoiceStatus = "draft_syncing" InvoiceStatusDraftSyncFailed InvoiceStatus = "draft_sync_failed" InvoiceStatusDraftWaitingAutoApproval InvoiceStatus = "draft_waiting_auto_approval" InvoiceStatusDraftReadyToIssue InvoiceStatus = "draft_ready_to_issue" InvoiceStatusDeleteInProgress InvoiceStatus = "delete_in_progress" InvoiceStatusDeleteSyncing InvoiceStatus = "delete_syncing" InvoiceStatusDeleteFailed InvoiceStatus = "delete_failed" InvoiceStatusDeleted InvoiceStatus = "deleted" InvoiceStatusIssuing InvoiceStatus = "issuing_syncing" InvoiceStatusIssuingSyncFailed InvoiceStatus = "issuing_sync_failed" // InvoiceStatusIssued is the status of an invoice that has been issued. InvoiceStatusIssued InvoiceStatus = "issued" )
func (InvoiceStatus) IsFailed ¶
func (s InvoiceStatus) IsFailed() bool
func (InvoiceStatus) ShortStatus ¶
func (s InvoiceStatus) ShortStatus() string
func (InvoiceStatus) Validate ¶
func (s InvoiceStatus) Validate() error
func (InvoiceStatus) Values ¶
func (s InvoiceStatus) Values() []string
type InvoiceStatusDetails ¶
type InvoiceStatusDetails struct {
Immutable bool `json:"immutable"`
Failed bool `json:"failed"`
AvailableActions []InvoiceAction `json:"availableActions"`
}
type InvoiceType ¶
type InvoiceType string
const ( InvoiceTypeStandard InvoiceType = InvoiceType(bill.InvoiceTypeStandard) InvoiceTypeCreditNote InvoiceType = InvoiceType(bill.InvoiceTypeCreditNote) )
func (InvoiceType) Validate ¶
func (t InvoiceType) Validate() error
func (InvoiceType) Values ¶
func (t InvoiceType) Values() []string
type InvoiceWorkflow ¶
type InvoiceWorkflow struct {
AppReferences ProfileAppReferences `json:"appReferences"`
Apps *ProfileApps `json:"apps,omitempty"`
SourceBillingProfileID string `json:"sourceBillingProfileId,omitempty"`
Config WorkflowConfig `json:"config"`
}
type InvoicingApp ¶
type InvoicingApp interface {
// ValidateInvoice validates if the app can run for the given invoice
ValidateInvoice(ctx context.Context, invoice Invoice) error
// UpsertInvoice upserts the invoice on the remote system, the invoice is read-only, the app should not modify it
// the recommended behavior is that the invoices FlattenLinesByID is used to get all lines, then the app should
// syncronize all the fee lines and store the external IDs in the result.
UpsertInvoice(ctx context.Context, invoice Invoice) (*UpsertInvoiceResult, error)
// FinalizeInvoice finalizes the invoice on the remote system, starts the payment flow. It is safe to assume
// that the state machine have already performed an upsert as part of this state transition.
//
// If the payment is handled by a decoupled implementation (different app or app has strict separation of concerns)
// then the payment app will be called with FinalizePayment and that should return the external ID of the payment. (later)
FinalizeInvoice(ctx context.Context, invoice Invoice) (*FinalizeInvoiceResult, error)
// DeleteInvoice deletes the invoice on the remote system, the invoice is read-only, the app should not modify it
// the invoice deletion is only invoked for non-finalized invoices.
DeleteInvoice(ctx context.Context, invoice Invoice) error
}
type InvoicingConfig ¶
type InvoicingConfig struct {
AutoAdvance bool `json:"autoAdvance,omitempty"`
DraftPeriod datex.Period `json:"draftPeriod,omitempty"`
DueAfter datex.Period `json:"dueAfter,omitempty"`
}
InvoiceConfig groups fields related to invoice settings.
func (*InvoicingConfig) Validate ¶
func (c *InvoicingConfig) Validate() error
type InvoicingOverrideConfig ¶
type InvoicingOverrideConfig struct {
AutoAdvance *bool `json:"autoAdvance,omitempty"`
DraftPeriod *datex.Period `json:"draftPeriod,omitempty"`
DueAfter *datex.Period `json:"dueAfter,omitempty"`
}
func (*InvoicingOverrideConfig) Validate ¶
func (c *InvoicingOverrideConfig) Validate() error
type Line ¶
type Line struct {
LineBase `json:",inline"`
// TODO[OM-1060]: Make it a proper union type instead of having both fields as public
FlatFee *FlatFeeLine `json:"flatFee,omitempty"`
UsageBased *UsageBasedLine `json:"usageBased,omitempty"`
Children LineChildren `json:"children,omitempty"`
ParentLine *Line `json:"parent,omitempty"`
Discounts LineDiscounts `json:"discounts,omitempty"`
DBState *Line `json:"-"`
}
func (Line) ChildrenWithIDReuse ¶
func (c Line) ChildrenWithIDReuse(l []*Line) LineChildren
ChildrenWithIDReuse returns a new LineChildren instance with the given lines. If the line has a child with a unique reference ID, it will try to retain the database ID of the existing child to avoid a delete/create.
func (Line) CloneWithoutDependencies ¶
CloneWithoutDependencies returns a clone of the line without any external dependencies. Could be used for creating a new line without any references to the parent or children (or config IDs).
func (*Line) DisassociateChildren ¶
func (i *Line) DisassociateChildren()
DissacociateChildren removes the Children both from the DBState and the current line, so that the line can be safely persisted/managed without the children.
The childrens receive DBState objects, so that they can be safely persisted/managed without the parent.
func (Line) RemoveCircularReferences ¶
func (Line) RemoveMetaForCompare ¶
RemoveMetaForCompare returns a copy of the invoice without the fields that are not relevant for higher level tests that compare invoices. What gets removed: - Line's DB state - Line's dependencies are marked as resolved - Parent pointers are removed
func (*Line) SaveDBSnapshot ¶
func (i *Line) SaveDBSnapshot()
func (Line) ValidateFee ¶
func (Line) ValidateUsageBased ¶
func (Line) WithoutDBState ¶
type LineBase ¶
type LineBase struct {
Namespace string `json:"namespace"`
ID string `json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt *time.Time `json:"deletedAt,omitempty"`
Metadata map[string]string `json:"metadata"`
Name string `json:"name"`
Type InvoiceLineType `json:"type"`
Description *string `json:"description,omitempty"`
InvoiceID string `json:"invoiceID,omitempty"`
Currency currencyx.Code `json:"currency"`
// Lifecycle
Period Period `json:"period"`
InvoiceAt time.Time `json:"invoiceAt"`
// Relationships
ParentLineID *string `json:"parentLine,omitempty"`
Status InvoiceLineStatus `json:"status"`
ChildUniqueReferenceID *string `json:"childUniqueReferenceID,omitempty"`
TaxConfig *TaxConfig `json:"taxOverrides,omitempty"`
ExternalIDs LineExternalIDs `json:"externalIDs,omitempty"`
Subscription *SubscriptionReference `json:"subscription,omitempty"`
Totals Totals `json:"totals"`
}
LineBase represents the common fields for an invoice item.
type LineChildren ¶
TODO[OM-1016]: For events we need a json marshaler
func NewLineChildren ¶
func NewLineChildren(children []*Line) LineChildren
func (*LineChildren) Append ¶
func (c *LineChildren) Append(l ...*Line)
func (LineChildren) Clone ¶
func (c LineChildren) Clone() LineChildren
func (LineChildren) GetByID ¶
func (c LineChildren) GetByID(id string) *Line
func (LineChildren) Map ¶
func (c LineChildren) Map(fn func(*Line) *Line) LineChildren
func (*LineChildren) RemoveByID ¶
func (c *LineChildren) RemoveByID(id string) bool
func (*LineChildren) ReplaceByID ¶
func (c *LineChildren) ReplaceByID(id string, newLine *Line) bool
type LineDiscount ¶
type LineDiscount struct {
ID string `json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt *time.Time `json:"deletedAt,omitempty"`
Amount alpacadecimal.Decimal `json:"amount"`
Description *string `json:"description,omitempty"`
ChildUniqueReferenceID *string `json:"childUniqueReferenceId,omitempty"`
}
func (LineDiscount) Equal ¶
func (i LineDiscount) Equal(other LineDiscount) bool
type LineDiscounts ¶
type LineDiscounts struct {
mo.Option[[]LineDiscount]
}
TODO[OM-1016]: For events we need a json marshaler
func NewLineDiscounts ¶
func NewLineDiscounts(discounts []LineDiscount) LineDiscounts
func (LineDiscounts) ChildrenWithIDReuse ¶
func (c LineDiscounts) ChildrenWithIDReuse(l LineDiscounts) LineDiscounts
func (LineDiscounts) Map ¶
func (c LineDiscounts) Map(fn func(LineDiscount) LineDiscount) LineDiscounts
type LineExternalIDs ¶
type LineExternalIDs struct {
Invoicing string `json:"invoicing,omitempty"`
}
type LineID ¶
type LineID models.NamespacedID
type LineWithCustomer ¶
func (LineWithCustomer) Validate ¶
func (l LineWithCustomer) Validate() error
type ListInvoiceLinesAdapterInput ¶
type ListInvoiceLinesAdapterInput struct {
Namespace string
CustomerID string
InvoiceIDs []string
InvoiceStatuses []InvoiceStatus
InvoiceAtBefore *time.Time
IncludeDeleted bool
ParentLineIDs []string
ParentLineIDsIncludeParent bool
Statuses []InvoiceLineStatus
LineIDs []string
}
func (ListInvoiceLinesAdapterInput) Validate ¶
func (g ListInvoiceLinesAdapterInput) Validate() error
type ListInvoicesInput ¶
type ListInvoicesInput struct {
pagination.Page
Namespace string
IDs []string
Customers []string
// Statuses searches by short InvoiceStatus (e.g. draft, issued)
Statuses []string
// ExtendedStatuses searches by exact InvoiceStatus
ExtendedStatuses []InvoiceStatus
Currencies []currencyx.Code
IssuedAfter *time.Time
IssuedBefore *time.Time
Expand InvoiceExpand
OrderBy api.InvoiceOrderBy
Order sortx.Order
}
func (ListInvoicesInput) Validate ¶
func (i ListInvoicesInput) Validate() error
type ListInvoicesResponse ¶
type ListInvoicesResponse = pagination.PagedResponse[Invoice]
type ListProfilesInput ¶
type ListProfilesInput struct {
pagination.Page
Expand ProfileExpand
Namespace string
IncludeArchived bool
OrderBy api.BillingProfileOrderBy
Order sortx.Order
}
func (ListProfilesInput) Validate ¶
func (i ListProfilesInput) Validate() error
type ListProfilesResult ¶
type ListProfilesResult = pagination.PagedResponse[Profile]
type LockCustomerForUpdateAdapterInput ¶
type LockCustomerForUpdateAdapterInput = customerentity.CustomerID
type LockInvoicesForUpdateInput ¶
type LockInvoicesForUpdateInput = genericMultiInvoiceInput
type NotFoundError ¶
func (NotFoundError) Error ¶
func (e NotFoundError) Error() string
func (NotFoundError) Unwrap ¶
func (e NotFoundError) Unwrap() error
type PaymentConfig ¶
type PaymentConfig struct {
CollectionMethod CollectionMethod
}
func (*PaymentConfig) Validate ¶
func (c *PaymentConfig) Validate() error
type PaymentOverrideConfig ¶
type PaymentOverrideConfig struct {
CollectionMethod *CollectionMethod
}
func (*PaymentOverrideConfig) Validate ¶
func (c *PaymentOverrideConfig) Validate() error
type Period ¶
Period represents a time period, in billing the time period is always interpreted as [from, to) (i.e. from is inclusive, to is exclusive).
type Price ¶
type Price = productcatalog.Price
type Profile ¶
type Profile struct {
BaseProfile
// Optionaly expanded fields
Apps *ProfileApps `json:"-"`
}
func (Profile) Merge ¶
func (p Profile) Merge(o *CustomerOverride) Profile
type ProfileAdapter ¶
type ProfileAdapter interface {
CreateProfile(ctx context.Context, input CreateProfileInput) (*BaseProfile, error)
ListProfiles(ctx context.Context, input ListProfilesInput) (pagination.PagedResponse[BaseProfile], error)
GetProfile(ctx context.Context, input GetProfileInput) (*BaseProfile, error)
GetDefaultProfile(ctx context.Context, input GetDefaultProfileInput) (*BaseProfile, error)
DeleteProfile(ctx context.Context, input DeleteProfileInput) error
UpdateProfile(ctx context.Context, input UpdateProfileAdapterInput) (*BaseProfile, error)
}
type ProfileAppReferences ¶
type ProfileAppReferences struct {
Tax AppReference `json:"tax"`
Invoicing AppReference `json:"invoicing"`
Payment AppReference `json:"payment"`
}
func (ProfileAppReferences) Validate ¶
func (i ProfileAppReferences) Validate() error
type ProfileApps ¶
type ProfileExpand ¶
type ProfileExpand struct {
Apps bool
}
func (ProfileExpand) Validate ¶
func (e ProfileExpand) Validate() error
type ProfileService ¶
type ProfileService interface {
CreateProfile(ctx context.Context, param CreateProfileInput) (*Profile, error)
GetDefaultProfile(ctx context.Context, input GetDefaultProfileInput) (*Profile, error)
GetProfile(ctx context.Context, input GetProfileInput) (*Profile, error)
ListProfiles(ctx context.Context, input ListProfilesInput) (ListProfilesResult, error)
DeleteProfile(ctx context.Context, input DeleteProfileInput) error
UpdateProfile(ctx context.Context, input UpdateProfileInput) (*Profile, error)
ProvisionDefaultBillingProfile(ctx context.Context, namespace string) error
}
type ProfileWithCustomerDetails ¶
type ProfileWithCustomerDetails struct {
Profile Profile `json:"profile"`
Customer customerentity.Customer `json:"customer"`
}
func (ProfileWithCustomerDetails) Validate ¶
func (p ProfileWithCustomerDetails) Validate() error
type RetryInvoiceInput ¶
type RetryInvoiceInput = InvoiceID
type Service ¶
type Service interface {
ProfileService
CustomerOverrideService
InvoiceLineService
InvoiceService
}
type SubscriptionReference ¶
type SupplierContact ¶
type SupplierContact struct {
ID string `json:"id"`
Name string `json:"name"`
Address models.Address `json:"address"`
TaxCode *string `json:"taxCode,omitempty"`
}
func (SupplierContact) Validate ¶
func (c SupplierContact) Validate() error
Validate checks if the supplier contact is valid for invoice generation (e.g. Country is required)
type TaxConfig ¶
type TaxConfig = productcatalog.TaxConfig
type Totals ¶
type Totals struct {
// Amount is the total amount value of the line before taxes, discounts and commitments
Amount alpacadecimal.Decimal `json:"amount"`
// ChargesTotal is the amount of value of the line that are due to additional charges
ChargesTotal alpacadecimal.Decimal `json:"chargesTotal"`
// DiscountsTotal is the amount of value of the line that are due to discounts
DiscountsTotal alpacadecimal.Decimal `json:"discountsTotal"`
// TaxesInclusiveTotal is the total amount of taxes that are included in the line
TaxesInclusiveTotal alpacadecimal.Decimal `json:"taxesInclusiveTotal"`
// TaxesExclusiveTotal is the total amount of taxes that are excluded from the line
TaxesExclusiveTotal alpacadecimal.Decimal `json:"taxesExclusiveTotal"`
// TaxesTotal is the total amount of taxes that are included in the line
TaxesTotal alpacadecimal.Decimal `json:"taxesTotal"`
// Total is the total amount value of the line after taxes, discounts and commitments
Total alpacadecimal.Decimal `json:"total"`
}
func (Totals) CalculateTotal ¶
func (t Totals) CalculateTotal() alpacadecimal.Decimal
type UpdateAfterDeleteError ¶
type UpdateAfterDeleteError genericError
func (UpdateAfterDeleteError) Error ¶
func (e UpdateAfterDeleteError) Error() string
func (UpdateAfterDeleteError) Unwrap ¶
func (e UpdateAfterDeleteError) Unwrap() error
type UpdateCustomerOverrideAdapterInput ¶
type UpdateCustomerOverrideAdapterInput struct {
UpdateCustomerOverrideInput
ResetDeletedAt bool
}
func (UpdateCustomerOverrideAdapterInput) Validate ¶
func (i UpdateCustomerOverrideAdapterInput) Validate() error
type UpdateCustomerOverrideInput ¶
type UpdateCustomerOverrideInput struct {
Namespace string `json:"namespace"`
CustomerID string `json:"customerID"`
UpdatedAt time.Time `json:"updatedAt"`
ProfileID string `json:"billingProfileID"`
Collection CollectionOverrideConfig `json:"collection"`
Invoicing InvoicingOverrideConfig `json:"invoicing"`
Payment PaymentOverrideConfig `json:"payment"`
}
func (UpdateCustomerOverrideInput) Validate ¶
func (u UpdateCustomerOverrideInput) Validate() error
type UpdateInvoiceAdapterInput ¶
type UpdateInvoiceAdapterInput = Invoice
type UpdateInvoiceLineAdapterInput ¶
type UpdateInvoiceLineAdapterInput Line
type UpdateInvoiceLineBaseInput ¶
type UpdateInvoiceLineBaseInput struct {
InvoiceAt mo.Option[time.Time]
Metadata mo.Option[map[string]string]
Name mo.Option[string]
Period mo.Option[Period]
TaxConfig mo.Option[*TaxConfig]
}
func (UpdateInvoiceLineBaseInput) Apply ¶
func (u UpdateInvoiceLineBaseInput) Apply(l *Line) error
func (UpdateInvoiceLineBaseInput) Validate ¶
func (u UpdateInvoiceLineBaseInput) Validate() error
type UpdateInvoiceLineFlatFeeInput ¶
type UpdateInvoiceLineFlatFeeInput struct {
PerUnitAmount mo.Option[alpacadecimal.Decimal]
Quantity mo.Option[alpacadecimal.Decimal]
PaymentTerm mo.Option[productcatalog.PaymentTermType]
}
func (UpdateInvoiceLineFlatFeeInput) Apply ¶
func (u UpdateInvoiceLineFlatFeeInput) Apply(l *FlatFeeLine) error
func (UpdateInvoiceLineFlatFeeInput) Validate ¶
func (u UpdateInvoiceLineFlatFeeInput) Validate() error
type UpdateInvoiceLineInput ¶
type UpdateInvoiceLineInput struct {
// Mandatory fields for update
Line LineID
Type InvoiceLineType
LineBase UpdateInvoiceLineBaseInput
UsageBased UpdateInvoiceLineUsageBasedInput
FlatFee UpdateInvoiceLineFlatFeeInput
}
func (UpdateInvoiceLineInput) Validate ¶
func (u UpdateInvoiceLineInput) Validate() error
type UpdateInvoiceLineUsageBasedInput ¶
type UpdateInvoiceLineUsageBasedInput struct {
Price *Price
}
func (UpdateInvoiceLineUsageBasedInput) Apply ¶
func (u UpdateInvoiceLineUsageBasedInput) Apply(l *UsageBasedLine) error
func (UpdateInvoiceLineUsageBasedInput) Validate ¶
func (u UpdateInvoiceLineUsageBasedInput) Validate() error
type UpdateInvoiceLinesInternalInput ¶
func (UpdateInvoiceLinesInternalInput) Validate ¶
func (i UpdateInvoiceLinesInternalInput) Validate() error
type UpdateProfileAdapterInput ¶
type UpdateProfileAdapterInput struct {
TargetState BaseProfile
WorkflowConfigID string
}
func (UpdateProfileAdapterInput) Validate ¶
func (i UpdateProfileAdapterInput) Validate() error
type UpdateProfileInput ¶
type UpdateProfileInput BaseProfile
func (UpdateProfileInput) Validate ¶
func (i UpdateProfileInput) Validate() error
type UpsertCustomerOverrideAdapterInput ¶
type UpsertCustomerOverrideAdapterInput = customerentity.CustomerID
type UpsertInvoiceLinesAdapterInput ¶
func (UpsertInvoiceLinesAdapterInput) Validate ¶
func (c UpsertInvoiceLinesAdapterInput) Validate() error
type UpsertInvoiceResult ¶
type UpsertInvoiceResult = UpsertResults
func NewUpsertInvoiceResult ¶
func NewUpsertInvoiceResult() *UpsertInvoiceResult
type UpsertResults ¶
type UpsertResults struct {
// contains filtered or unexported fields
}
func NewUpsertResults ¶
func NewUpsertResults() *UpsertResults
func (*UpsertResults) AddLineExternalID ¶
func (u *UpsertResults) AddLineExternalID(lineID string, externalID string)
func (*UpsertResults) GetExternalID ¶
func (u *UpsertResults) GetExternalID() (string, bool)
func (*UpsertResults) GetInvoiceNumber ¶
func (u *UpsertResults) GetInvoiceNumber() (string, bool)
func (*UpsertResults) GetLineExternalID ¶
func (u *UpsertResults) GetLineExternalID(lineID string) (string, bool)
func (*UpsertResults) GetLineExternalIDs ¶
func (u *UpsertResults) GetLineExternalIDs() map[string]string
func (*UpsertResults) SetExternalID ¶
func (u *UpsertResults) SetExternalID(externalID string)
func (*UpsertResults) SetInvoiceNumber ¶
func (u *UpsertResults) SetInvoiceNumber(invoiceNumber string)
type UsageBasedLine ¶
type UsageBasedLine struct {
ConfigID string `json:"configId"`
// Price is the price of the usage based line. Note: this should be a pointer or marshaling will fail for
// empty prices.
Price *Price `json:"price"`
FeatureKey string `json:"featureKey"`
Quantity *alpacadecimal.Decimal `json:"quantity"`
PreLinePeriodQuantity *alpacadecimal.Decimal `json:"preLinePeriodQuantity,omitempty"`
}
func (UsageBasedLine) Clone ¶
func (i UsageBasedLine) Clone() *UsageBasedLine
func (UsageBasedLine) Equal ¶
func (i UsageBasedLine) Equal(other *UsageBasedLine) bool
func (UsageBasedLine) Validate ¶
func (i UsageBasedLine) Validate() error
type ValidationError ¶
type ValidationError genericError
func (ValidationError) Error ¶
func (e ValidationError) Error() string
func (ValidationError) Unwrap ¶
func (e ValidationError) Unwrap() error
type ValidationIssue ¶
type ValidationIssue struct {
ID string `json:"id,omitempty"`
CreatedAt time.Time `json:"createdAt,omitempty"`
UpdatedAt time.Time `json:"updatedAt,omitempty"`
DeletedAt *time.Time `json:"deletedAt,omitempty"`
Severity ValidationIssueSeverity `json:"severity"`
Message string `json:"message"`
Code string `json:"code,omitempty"`
Component ComponentName `json:"component,omitempty"`
Path string `json:"path,omitempty"`
}
func NewValidationError ¶
func NewValidationError(code, message string) ValidationIssue
func NewValidationWarning ¶
func NewValidationWarning(code, message string) ValidationIssue
func (ValidationIssue) EncodeAsErrorExtension ¶
func (i ValidationIssue) EncodeAsErrorExtension() map[string]interface{}
func (ValidationIssue) Error ¶
func (i ValidationIssue) Error() string
type ValidationIssueSeverity ¶
type ValidationIssueSeverity string
const ( ValidationIssueSeverityCritical ValidationIssueSeverity = "critical" ValidationIssueSeverityWarning ValidationIssueSeverity = "warning" ValidationComponentOpenMeter = "openmeter" )
func (ValidationIssueSeverity) Values ¶
func (ValidationIssueSeverity) Values() []string
type ValidationIssues ¶
type ValidationIssues []ValidationIssue
func ToValidationIssues ¶
func ToValidationIssues(errIn error) (ValidationIssues, error)
ToValidationIssues converts an error into a list of validation issues If the error is nil, it returns nil If any error in the error tree is not wrapped in ValidationWithComponent or ValidationWithFieldPrefix and not an instance of ValidationIssue, it will return an error. This behavior allows us to have critical errors that are not validation issues.
func (ValidationIssues) AsError ¶
func (v ValidationIssues) AsError() error
func (ValidationIssues) Clone ¶
func (v ValidationIssues) Clone() ValidationIssues
func (ValidationIssues) Map ¶
func (v ValidationIssues) Map(f func(ValidationIssue, int) ValidationIssue) ValidationIssues
func (ValidationIssues) RemoveMetaForCompare ¶
func (v ValidationIssues) RemoveMetaForCompare() ValidationIssues
type VersionedCustomerUsageAttribution ¶
type VersionedCustomerUsageAttribution struct {
CustomerUsageAttribution `json:",inline"`
Type string `json:"type"`
}
type WorkflowConfig ¶
type WorkflowConfig struct {
ID string `json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt *time.Time `json:"deletedAt"`
Timezone *timezone.Timezone `json:"timezone,omitempty"`
Collection CollectionConfig `json:"collection"`
Invoicing InvoicingConfig `json:"invoicing"`
Payment PaymentConfig `json:"payment"`
}
func (WorkflowConfig) Validate ¶
func (c WorkflowConfig) Validate() error
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
lineservice
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. |