Documentation
¶
Index ¶
- Constants
- func TotalAmount(in getTotalAmountInput) alpacadecimal.Decimal
- type AddDiscountInput
- type DetailedLine
- type DetailedLines
- type GatheringLineAccessor
- type GenerateDetailedLinesOption
- type GenerateDetailedLinesOptions
- type GenerateDetailedLinesResult
- type PriceAccessor
- type ResolveBillablePeriodInput
- type Service
- type StandardLineAccessor
- type Usage
Constants ¶
View Source
const ( UsageChildUniqueReferenceID = "usage" MinSpendChildUniqueReferenceID = "min-spend" // TODO[later]: Per type unique reference IDs are to be deprecated, we should use the generic names for // lines with one child. (e.g. graduated can stay for now, as it has multiple children) FlatPriceChildUniqueReferenceID = "flat-price" UnitPriceUsageChildUniqueReferenceID = "unit-price-usage" UnitPriceMaxSpendChildUniqueReferenceID = "unit-price-max-spend" DynamicPriceUsageChildUniqueReferenceID = "dynamic-price-usage" VolumeFlatPriceChildUniqueReferenceID = "volume-flat-price" VolumeUnitPriceChildUniqueReferenceID = "volume-tiered-price" GraduatedTieredPriceUsageChildUniqueReferenceID = "graduated-tiered-%d-price-usage" GraduatedTieredFlatPriceChildUniqueReferenceID = "graduated-tiered-%d-flat-price" RateCardDiscountChildUniqueReferenceID = "rateCardDiscount/correlationID=%s" )
Variables ¶
This section is empty.
Functions ¶
func TotalAmount ¶
func TotalAmount(in getTotalAmountInput) alpacadecimal.Decimal
Types ¶
type AddDiscountInput ¶
type AddDiscountInput struct {
BilledAmountBeforeLine alpacadecimal.Decimal
MaxSpend alpacadecimal.Decimal
Currency currencyx.Calculator
}
type DetailedLine ¶
type DetailedLine struct {
Name string `json:"name"`
Quantity alpacadecimal.Decimal `json:"quantity"`
PerUnitAmount alpacadecimal.Decimal `json:"perUnitAmount"`
ChildUniqueReferenceID string `json:"childUniqueReferenceID"`
Period *timeutil.ClosedPeriod `json:"period,omitempty"`
// PaymentTerm is the payment term for the detailed line, defaults to arrears
PaymentTerm productcatalog.PaymentTermType `json:"paymentTerm,omitempty"`
Category stddetailedline.Category `json:"category,omitempty"`
AmountDiscounts billing.AmountLineDiscountsManaged `json:"amountDiscounts,omitempty"`
CreditsApplied billing.CreditsApplied `json:"creditsApplied,omitempty"`
Totals totals.Totals `json:"totals,omitempty"`
}
func (DetailedLine) AddDiscountForOverage ¶
func (i DetailedLine) AddDiscountForOverage(in AddDiscountInput) DetailedLine
func (DetailedLine) TotalAmount ¶
func (i DetailedLine) TotalAmount(currency currencyx.Calculator) alpacadecimal.Decimal
func (DetailedLine) Validate ¶
func (i DetailedLine) Validate() error
type DetailedLines ¶
type DetailedLines []DetailedLine
func (DetailedLines) Sum ¶
func (i DetailedLines) Sum(currency currencyx.Calculator) alpacadecimal.Decimal
type GatheringLineAccessor ¶
type GatheringLineAccessor interface {
PriceAccessor
GetSplitLineGroupID() *string
GetInvoiceAt() time.Time
GetID() string
}
type GenerateDetailedLinesOption ¶
type GenerateDetailedLinesOption func(*GenerateDetailedLinesOptions)
func WithCreditsMutatorDisabled ¶
func WithCreditsMutatorDisabled() GenerateDetailedLinesOption
func WithMinimumCommitmentIgnored ¶
func WithMinimumCommitmentIgnored() GenerateDetailedLinesOption
type GenerateDetailedLinesOptions ¶
type GenerateDetailedLinesOptions struct {
IgnoreMinimumCommitment bool
DisableCreditsMutator bool
}
func NewGenerateDetailedLinesOptions ¶
func NewGenerateDetailedLinesOptions(opts ...GenerateDetailedLinesOption) GenerateDetailedLinesOptions
type GenerateDetailedLinesResult ¶
type GenerateDetailedLinesResult struct {
DetailedLines DetailedLines
// FinalUsage is the final usage of the line after all the discounts have been applied
FinalUsage *Usage
// FinalStandardLineDiscounts is the final standard line discounts for the line after all the discounts have been applied
FinalStandardLineDiscounts billing.StandardLineDiscounts
// Totals is the totals of the line after all the calculations have been applied
Totals totals.Totals
}
type PriceAccessor ¶
type PriceAccessor interface {
GetPrice() *productcatalog.Price
GetServicePeriod() timeutil.ClosedPeriod
GetFeatureKey() string
}
type ResolveBillablePeriodInput ¶
type ResolveBillablePeriodInput struct {
AsOf time.Time
ProgressiveBilling bool
Line GatheringLineAccessor
FeatureMeters feature.FeatureMeters
}
func (ResolveBillablePeriodInput) Validate ¶
func (i ResolveBillablePeriodInput) Validate() error
type Service ¶
type Service interface {
ResolveBillablePeriod(in ResolveBillablePeriodInput) (*timeutil.ClosedPeriod, error)
GenerateDetailedLines(in StandardLineAccessor, opts ...GenerateDetailedLinesOption) (GenerateDetailedLinesResult, error)
}
type StandardLineAccessor ¶
type StandardLineAccessor interface {
PriceAccessor
// GetCurrency returns the currency of the line
GetCurrency() currencyx.Code
// GetMeteredUsage returns the metered usage of the line for the current service period
GetMeteredQuantity() (*alpacadecimal.Decimal, error)
// GetMeteredPreLinePeriodUsage returns the metered usage of the line for the previous service period
GetMeteredPreLinePeriodQuantity() (*alpacadecimal.Decimal, error)
// GetCreditsApplied returns the list of credits to be applied for the line
GetCreditsApplied() billing.CreditsApplied
// GetName returns the name of the line
GetName() string
// GetRateCardDiscounts returns the rate card discounts for the line
GetRateCardDiscounts() billing.Discounts
// GetUnitConfig returns the optional unit conversion to apply to the raw metered
// quantity before pricing. Nil means no conversion (rating is unchanged).
GetUnitConfig() *productcatalog.UnitConfig
// GetStandardLineDiscounts returns the standard line discounts for the line
GetStandardLineDiscounts() billing.StandardLineDiscounts
// Progressive billing related information
// IsProgressivelyBilled returns true if the line is progressively billed
IsProgressivelyBilled() bool
// GetProgressivelyBilledServicePeriod returns the full service period of the line (if the line is progressively billed, or matches the service period)
GetProgressivelyBilledServicePeriod() (timeutil.ClosedPeriod, error)
// GetPreviouslyBilledAmount returns the amount that has already been billed for the line before the current line
GetPreviouslyBilledAmount() (alpacadecimal.Decimal, error)
}
type Usage ¶
type Usage struct {
Quantity alpacadecimal.Decimal
PreLinePeriodQuantity alpacadecimal.Decimal
}
Click to show internal directories.
Click to hide internal directories.