transactions

package
v1.0.0-beta.228 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GroupInputs

func GroupInputs(namespace string, annotations models.Annotations, inputs ...ledger.TransactionInput) ledger.TransactionGroupInput

func ResolveTransactions

func ResolveTransactions(
	ctx context.Context,
	deps ResolverDependencies,
	scope ResolutionScope,
	templates ...TransactionTemplate,
) ([]ledger.TransactionInput, error)

ResolveTransactions resolves a list of transaction templates into a list of transaction inputs

func TemplateCode

func TemplateCode(template TransactionTemplate) string

func WithAnnotations

func WithAnnotations(input ledger.TransactionInput, annotations models.Annotations) ledger.TransactionInput

Types

type AttributeCustomerAdvanceReceivableCostBasisTemplate

type AttributeCustomerAdvanceReceivableCostBasisTemplate struct {
	At        time.Time
	Amount    alpacadecimal.Decimal
	Currency  currencyx.Code
	CostBasis *alpacadecimal.Decimal
}

AttributeCustomerAdvanceReceivableCostBasisTemplate attributes existing open advance receivable (`cost_basis=nil`) into a known purchase cost-basis bucket.

func (AttributeCustomerAdvanceReceivableCostBasisTemplate) Validate

type AuthorizeCustomerReceivablePaymentTemplate

type AuthorizeCustomerReceivablePaymentTemplate struct {
	At        time.Time
	Amount    alpacadecimal.Decimal
	Currency  currencyx.Code
	CostBasis *alpacadecimal.Decimal
}

AuthorizeCustomerReceivablePaymentTemplate moves open receivable into the authorized receivable route without moving funds across the external cash boundary.

func (AuthorizeCustomerReceivablePaymentTemplate) Validate

type ConvertCurrencyTemplate

type ConvertCurrencyTemplate struct {
	At           time.Time
	TargetAmount alpacadecimal.Decimal
	CostBasis    alpacadecimal.Decimal

	SourceCurrency currencyx.Code
	TargetCurrency currencyx.Code
	// Optional, defaults to ledger.DefaultCustomerFBOPriority.
	CreditPriority *int
}

func (ConvertCurrencyTemplate) Validate

func (t ConvertCurrencyTemplate) Validate() error

type CorrectionInput

type CorrectionInput struct {
	At     time.Time
	Amount alpacadecimal.Decimal

	OriginalTransaction ledger.Transaction
	OriginalGroup       ledger.TransactionGroup
}

type CorrectionScope

type CorrectionScope = CorrectionInput

func (CorrectionScope) Validate

func (i CorrectionScope) Validate() error

type CoverCustomerReceivableTemplate

type CoverCustomerReceivableTemplate struct {
	At        time.Time
	Amount    alpacadecimal.Decimal
	Currency  currencyx.Code
	CostBasis *alpacadecimal.Decimal
	// Optional, defaults to 100.
	CreditPriority *int
}

CoverCustomerReceivableTemplate covers a customer receivable account from FBO account

func (CoverCustomerReceivableTemplate) Validate

type CustomerTransactionTemplate

type CustomerTransactionTemplate interface {
	TransactionTemplate
	// contains filtered or unexported methods
}

CustomerTransactionTemplate is a template for customer scoped transactions

type EntryInput

type EntryInput struct {
	// contains filtered or unexported fields
}

func (*EntryInput) Amount

func (e *EntryInput) Amount() alpacadecimal.Decimal

func (*EntryInput) PostingAddress

func (e *EntryInput) PostingAddress() ledger.PostingAddress

type IssueCustomerReceivableTemplate

type IssueCustomerReceivableTemplate struct {
	At        time.Time
	Amount    alpacadecimal.Decimal
	Currency  currencyx.Code
	CostBasis *alpacadecimal.Decimal
	// Optional, defaults to ledger.DefaultCustomerFBOPriority.
	CreditPriority *int
}

IssueCustomerReceivableTemplate is a transaction increasing the customer's balance against an outstanding receivable account

func (IssueCustomerReceivableTemplate) Validate

type OrgTransactionTemplate

type OrgTransactionTemplate interface {
	TransactionTemplate
	// contains filtered or unexported methods
}

OrgTransactionTemplate is a template for organization scoped transactions

type PostingAmount

type PostingAmount struct {
	Address ledger.PostingAddress
	Amount  alpacadecimal.Decimal
}

PostingAmount is a preselected amount to post against an address.

type RecognizeEarningsFromAttributableAccruedTemplate

type RecognizeEarningsFromAttributableAccruedTemplate struct {
	At       time.Time
	Amount   alpacadecimal.Decimal
	Currency currencyx.Code
}

RecognizeEarningsFromAttributableAccruedTemplate recognizes up to Amount from accrued routes that already have a known cost basis. Unknown-cost accrued balances are skipped.

func (RecognizeEarningsFromAttributableAccruedTemplate) Validate

type ResolutionScope

type ResolutionScope struct {
	CustomerID customer.CustomerID
	Namespace  string
}

ResolutionScope is the scope for which we resolve the transaction templates

func (ResolutionScope) Validate

func (s ResolutionScope) Validate() error

type ResolverDependencies

type ResolverDependencies struct {
	AccountService ledger.AccountResolver
	AccountCatalog ledger.AccountCatalog
	BalanceQuerier ledger.BalanceQuerier
}

ResolverDependencies are the dependencies required to resolve transactions

type SettleCustomerReceivableFromPaymentTemplate

type SettleCustomerReceivableFromPaymentTemplate struct {
	At        time.Time
	Amount    alpacadecimal.Decimal
	Currency  currencyx.Code
	CostBasis *alpacadecimal.Decimal
}

SettleCustomerReceivableFromPaymentTemplate records settled payment funds by clearing authorized receivable from wash.

func (SettleCustomerReceivableFromPaymentTemplate) Validate

type TransactionGroupInput

type TransactionGroupInput struct {
	// contains filtered or unexported fields
}

func (*TransactionGroupInput) Annotations

func (t *TransactionGroupInput) Annotations() models.Annotations

func (*TransactionGroupInput) Namespace

func (t *TransactionGroupInput) Namespace() string

func (*TransactionGroupInput) Transactions

func (t *TransactionGroupInput) Transactions() []ledger.TransactionInput

type TransactionInput

type TransactionInput struct {
	// contains filtered or unexported fields
}

func (*TransactionInput) Annotations

func (t *TransactionInput) Annotations() models.Annotations

func (*TransactionInput) AsGroupInput

func (t *TransactionInput) AsGroupInput(namespace string, annotations models.Annotations) ledger.TransactionGroupInput

func (*TransactionInput) BookedAt

func (t *TransactionInput) BookedAt() time.Time

func (*TransactionInput) EntryInputs

func (t *TransactionInput) EntryInputs() []ledger.EntryInput

type TransactionTemplate

type TransactionTemplate interface {
	Validate() error
	// contains filtered or unexported methods
}

type TransactionTemplateCode

type TransactionTemplateCode string
const (
	TemplateCodeIssueCustomerReceivable                     TransactionTemplateCode = "customer.receivable.issue"
	TemplateCodeAuthorizeCustomerReceivablePayment          TransactionTemplateCode = "customer.receivable.payment.authorize"
	TemplateCodeSettleCustomerReceivableFromPayment         TransactionTemplateCode = "customer.receivable.payment.settle"
	TemplateCodeAttributeCustomerAdvanceReceivableCostBasis TransactionTemplateCode = "customer.receivable.advance.attribute"
	TemplateCodeCoverCustomerReceivable                     TransactionTemplateCode = "customer.receivable.cover"
	TemplateCodeTransferCustomerFBOToAccrued                TransactionTemplateCode = "customer.fbo.collect"
	TemplateCodeTransferCustomerFBOAdvanceToAccrued         TransactionTemplateCode = "customer.fbo.advance.collect"
	TemplateCodeTransferCustomerReceivableToAccrued         TransactionTemplateCode = "customer.receivable.collect"
	TemplateCodeTranslateCustomerAccruedCostBasis           TransactionTemplateCode = "customer.accrued.cost_basis.translate"
	TemplateCodeRecognizeEarningsFromAttributableAccrued    TransactionTemplateCode = "customer.accrued.earnings.recognize"
	TemplateCodeConvertCurrency                             TransactionTemplateCode = "customer.fbo.currency.convert"
)

type TransferCustomerFBOAdvanceToAccruedTemplate

type TransferCustomerFBOAdvanceToAccruedTemplate struct {
	At             time.Time
	Amount         alpacadecimal.Decimal
	Currency       currencyx.Code
	CostBasis      *alpacadecimal.Decimal
	CreditPriority *int
}

TransferCustomerFBOAdvanceToAccruedTemplate moves value from the synthetic advance-backed customer FBO route into the matching accrued route.

func (TransferCustomerFBOAdvanceToAccruedTemplate) Validate

type TransferCustomerFBOToAccruedTemplate

type TransferCustomerFBOToAccruedTemplate struct {
	At       time.Time
	Currency currencyx.Code
	Sources  []PostingAmount
}

TransferCustomerFBOToAccruedTemplate moves preselected customer FBO value into the customer's accrued account.

func (TransferCustomerFBOToAccruedTemplate) Validate

type TransferCustomerReceivableToAccruedTemplate

type TransferCustomerReceivableToAccruedTemplate struct {
	At        time.Time
	Amount    alpacadecimal.Decimal
	Currency  currencyx.Code
	CostBasis *alpacadecimal.Decimal
}

TransferCustomerReceivableToAccruedTemplate acknowledges usage by moving it from receivable into the customer's accrued account.

func (TransferCustomerReceivableToAccruedTemplate) Validate

type TranslateCustomerAccruedCostBasisTemplate

type TranslateCustomerAccruedCostBasisTemplate struct {
	At            time.Time
	Amount        alpacadecimal.Decimal
	Currency      currencyx.Code
	FromCostBasis *alpacadecimal.Decimal
	ToCostBasis   *alpacadecimal.Decimal
}

TranslateCustomerAccruedCostBasisTemplate moves accrued balance between cost-basis buckets without changing account type or currency.

func (TranslateCustomerAccruedCostBasisTemplate) Validate

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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