credits

package
v1.0.0-beta.230 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseSuite

type BaseSuite struct {
	billingtest.BaseSuite

	Charges              charges.Service
	CreditPurchaseSvc    creditpurchase.Service
	UsageBasedSvc        usagebased.Service
	CustomerBalanceSvc   customerbalance.Service
	Ledger               ledger.Ledger
	BalanceQuerier       ledger.BalanceQuerier
	LedgerAccountService ledgeraccount.Service
	LedgerResolver       *ledgerresolvers.AccountResolver
	BreakageService      ledgerbreakage.Service
	FlatFeeHandler       flatfee.Handler
	LineageService       lineage.Service
	RevenueRecognizer    recognizer.Service
}

func (*BaseSuite) AssertLedgerSnapshotEqual

func (s *BaseSuite) AssertLedgerSnapshotEqual(expected, actual LedgerSnapshot)

func (*BaseSuite) AssertLedgerSnapshotUnchanged

func (s *BaseSuite) AssertLedgerSnapshotUnchanged(input LedgerSnapshotInput, expected LedgerSnapshot)

func (*BaseSuite) CreateCreditPurchaseIntent

func (s *BaseSuite) CreateCreditPurchaseIntent(input CreateCreditPurchaseIntentInput) charges.ChargeIntent

func (*BaseSuite) CreateLedgerBackedCustomer

func (s *BaseSuite) CreateLedgerBackedCustomer(ns string, subjectKey string) *customer.Customer

func (*BaseSuite) CreateLedgerSnapshot

func (s *BaseSuite) CreateLedgerSnapshot(input LedgerSnapshotInput) LedgerSnapshot

func (*BaseSuite) CreateMockChargeIntent

func (s *BaseSuite) CreateMockChargeIntent(input CreateMockChargeIntentInput) charges.ChargeIntent

func (*BaseSuite) MustBreakageBalanceAsOf

func (s *BaseSuite) MustBreakageBalanceAsOf(namespace string, code currencyx.Code, costBasis mo.Option[*alpacadecimal.Decimal], asOf time.Time) alpacadecimal.Decimal

func (*BaseSuite) MustCustomerAccruedBalance

func (s *BaseSuite) MustCustomerAccruedBalance(customerID customer.CustomerID, code currencyx.Code, costBasis mo.Option[*alpacadecimal.Decimal]) alpacadecimal.Decimal

MustCustomerAccruedBalance returns customer accrued balance in a currency. Pass mo.None() for all cost bases, mo.Some(nil) for the explicit nil-cost-basis route, or mo.Some(&costBasis) for one concrete cost-basis route.

func (*BaseSuite) MustCustomerAccruedBalanceForTaxCode

func (s *BaseSuite) MustCustomerAccruedBalanceForTaxCode(customerID customer.CustomerID, code currencyx.Code, costBasis mo.Option[*alpacadecimal.Decimal], taxCode mo.Option[*string]) alpacadecimal.Decimal

MustCustomerAccruedBalanceForTaxCode returns accrued balance filtered by cost basis and tax code.

func (*BaseSuite) MustCustomerAccruedBalanceForTaxConfig

func (s *BaseSuite) MustCustomerAccruedBalanceForTaxConfig(customerID customer.CustomerID, code currencyx.Code, costBasis mo.Option[*alpacadecimal.Decimal], taxCode mo.Option[*string], taxBehavior mo.Option[*ledger.TaxBehavior]) alpacadecimal.Decimal

MustCustomerAccruedBalanceForTaxConfig returns accrued balance filtered by cost basis, tax code, and tax behavior.

func (*BaseSuite) MustCustomerFBOBalance

func (s *BaseSuite) MustCustomerFBOBalance(customerID customer.CustomerID, code currencyx.Code, costBasis mo.Option[*alpacadecimal.Decimal]) alpacadecimal.Decimal

MustCustomerFBOBalance returns customer FBO balance in a currency. Pass mo.None() for all cost bases, mo.Some(nil) for the explicit nil-cost-basis route, or mo.Some(&costBasis) for one concrete cost-basis route.

func (*BaseSuite) MustCustomerFBOBalanceAsOf

func (s *BaseSuite) MustCustomerFBOBalanceAsOf(customerID customer.CustomerID, code currencyx.Code, costBasis mo.Option[*alpacadecimal.Decimal], asOf time.Time) alpacadecimal.Decimal

func (*BaseSuite) MustCustomerFBOBalanceForFeatures

func (s *BaseSuite) MustCustomerFBOBalanceForFeatures(customerID customer.CustomerID, code currencyx.Code, costBasis mo.Option[*alpacadecimal.Decimal], features mo.Option[[]string]) alpacadecimal.Decimal

func (*BaseSuite) MustCustomerFBOBalanceWithPriority

func (s *BaseSuite) MustCustomerFBOBalanceWithPriority(customerID customer.CustomerID, code currencyx.Code, costBasis mo.Option[*alpacadecimal.Decimal], priority int) alpacadecimal.Decimal

MustCustomerFBOBalanceWithPriority returns customer FBO balance in a currency filtered by a specific credit priority. Pass mo.None() for all cost bases, mo.Some(nil) for the explicit nil-cost-basis route, or mo.Some(&costBasis) for one concrete cost-basis route.

func (*BaseSuite) MustCustomerFBOBalanceWithPriorityAsOf

func (s *BaseSuite) MustCustomerFBOBalanceWithPriorityAsOf(customerID customer.CustomerID, code currencyx.Code, costBasis mo.Option[*alpacadecimal.Decimal], priority int, asOf *time.Time) alpacadecimal.Decimal

func (*BaseSuite) MustCustomerFBOBalanceWithPriorityForFeatures

func (s *BaseSuite) MustCustomerFBOBalanceWithPriorityForFeatures(customerID customer.CustomerID, code currencyx.Code, costBasis mo.Option[*alpacadecimal.Decimal], priority int, features mo.Option[[]string]) alpacadecimal.Decimal

func (*BaseSuite) MustCustomerReceivableBalance

func (s *BaseSuite) MustCustomerReceivableBalance(customerID customer.CustomerID, code currencyx.Code, costBasis mo.Option[*alpacadecimal.Decimal], status ledger.TransactionAuthorizationStatus) alpacadecimal.Decimal

MustCustomerReceivableBalance returns customer receivable balance in a currency for one authorization state. Pass mo.None() for all cost bases, mo.Some(nil) for the explicit nil-cost-basis route, or mo.Some(&costBasis) for one concrete route.

func (*BaseSuite) MustCustomerReceivableBalanceForFeatures

func (s *BaseSuite) MustCustomerReceivableBalanceForFeatures(customerID customer.CustomerID, code currencyx.Code, costBasis mo.Option[*alpacadecimal.Decimal], status ledger.TransactionAuthorizationStatus, features mo.Option[[]string]) alpacadecimal.Decimal

MustCustomerReceivableBalanceForFeatures returns customer receivable balance for one authorization state and feature route. It is used by backfill tests where aggregate receivable can net to zero while individual feature buckets do not.

func (*BaseSuite) MustCustomerReceivableBalanceForTaxCode

func (s *BaseSuite) MustCustomerReceivableBalanceForTaxCode(customerID customer.CustomerID, code currencyx.Code, costBasis mo.Option[*alpacadecimal.Decimal], status ledger.TransactionAuthorizationStatus, taxCode mo.Option[*string]) alpacadecimal.Decimal

MustCustomerReceivableBalanceForTaxCode returns customer receivable balance filtered by cost basis, authorization status, and tax code.

func (*BaseSuite) MustEarningsBalance

func (s *BaseSuite) MustEarningsBalance(namespace string, code currencyx.Code) alpacadecimal.Decimal

func (*BaseSuite) MustEarningsBalanceForCostBasis

func (s *BaseSuite) MustEarningsBalanceForCostBasis(namespace string, code currencyx.Code, costBasis mo.Option[*alpacadecimal.Decimal]) alpacadecimal.Decimal

MustEarningsBalanceForCostBasis returns earnings balance in a currency. Pass mo.None() for all cost bases, mo.Some(nil) for the explicit nil-cost-basis route, or mo.Some(&costBasis) for one concrete cost-basis route.

func (*BaseSuite) MustEarningsBalanceForTaxCode

func (s *BaseSuite) MustEarningsBalanceForTaxCode(namespace string, code currencyx.Code, costBasis mo.Option[*alpacadecimal.Decimal], taxCode mo.Option[*string]) alpacadecimal.Decimal

MustEarningsBalanceForTaxCode returns earnings balance filtered by both cost basis and tax code.

func (*BaseSuite) MustGetChargeByID

func (s *BaseSuite) MustGetChargeByID(chargeID meta.ChargeID) charges.Charge

func (*BaseSuite) MustRecognizeRevenue

func (s *BaseSuite) MustRecognizeRevenue(customerID customer.CustomerID, code currencyx.Code, amount alpacadecimal.Decimal)

func (*BaseSuite) MustRefundCharge

func (s *BaseSuite) MustRefundCharge(ctx context.Context, customerID customer.CustomerID, chargeID meta.ChargeID)

MustRefundCharge deletes a charge through the real refund-as-credits patch flow.

func (*BaseSuite) MustWashBalance

func (s *BaseSuite) MustWashBalance(namespace string, code currencyx.Code, costBasis mo.Option[*alpacadecimal.Decimal]) alpacadecimal.Decimal

MustWashBalance returns aggregate wash balance in a currency. Pass mo.None() for all cost bases, mo.Some(nil) for the explicit nil-cost-basis route, or mo.Some(&costBasis) for one concrete cost-basis route.

func (*BaseSuite) SetupSuite

func (s *BaseSuite) SetupSuite()

func (*BaseSuite) TearDownTest

func (s *BaseSuite) TearDownTest()

type CreateCreditPurchaseIntentInput

type CreateCreditPurchaseIntentInput struct {
	Customer       customer.CustomerID
	Currency       currencyx.Code
	Amount         alpacadecimal.Decimal
	EffectiveAt    *time.Time
	ExpiresAt      *time.Time
	Priority       *int
	ServicePeriod  timeutil.ClosedPeriod
	Settlement     creditpurchase.Settlement
	FeatureFilters creditpurchase.FeatureFilters
	TaxConfig      productcatalog.TaxCodeConfig
}

func (CreateCreditPurchaseIntentInput) Validate

type CreateMockChargeIntentInput

type CreateMockChargeIntentInput struct {
	Customer          customer.CustomerID
	Currency          currencyx.Code
	ServicePeriod     timeutil.ClosedPeriod
	Price             *productcatalog.Price
	FeatureKey        string
	Name              string
	SettlementMode    productcatalog.SettlementMode
	ManagedBy         billing.InvoiceLineManagedBy
	UniqueReferenceID string
	ProRating         productcatalog.ProRatingConfig
	TaxConfig         productcatalog.TaxCodeConfig
}

func (*CreateMockChargeIntentInput) Validate

func (i *CreateMockChargeIntentInput) Validate() error

type CreatePromotionalCreditFundingInput

type CreatePromotionalCreditFundingInput struct {
	Namespace      string
	Customer       customer.CustomerID
	Amount         alpacadecimal.Decimal
	At             time.Time
	ExpiresAt      *time.Time
	CostBasis      alpacadecimal.Decimal
	Priority       *int
	FeatureFilters creditpurchase.FeatureFilters
	TaxConfig      productcatalog.TaxCodeConfig
}

type CreatePromotionalCreditFundingResult

type CreatePromotionalCreditFundingResult struct {
	Charge         creditpurchase.Charge
	OpenReceivable alpacadecimal.Decimal
}

type LedgerSnapshot

type LedgerSnapshot struct {
	FBO                  alpacadecimal.Decimal
	OpenReceivable       alpacadecimal.Decimal
	AuthorizedReceivable alpacadecimal.Decimal
	Accrued              alpacadecimal.Decimal
	Wash                 alpacadecimal.Decimal
	Earnings             alpacadecimal.Decimal
}

type LedgerSnapshotInput

type LedgerSnapshotInput struct {
	Namespace string
	Customer  customer.CustomerID
	Currency  currencyx.Code
	CostBasis mo.Option[*alpacadecimal.Decimal]
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL