routingrules

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: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultValidator = Validator{
	Rules: []RoutingRule{
		RequireUniqueSubAccountsRule{},
		AllowedAccountSetsRule{
			Sets: [][]ledger.AccountType{
				{ledger.AccountTypeCustomerFBO, ledger.AccountTypeCustomerReceivable},
				{ledger.AccountTypeCustomerReceivable},
				{ledger.AccountTypeCustomerFBO},
				{ledger.AccountTypeCustomerAccrued},
				{ledger.AccountTypeCustomerFBO, ledger.AccountTypeCustomerAccrued},
				{ledger.AccountTypeCustomerReceivable, ledger.AccountTypeCustomerAccrued},
				{ledger.AccountTypeCustomerReceivable, ledger.AccountTypeWash},
				{ledger.AccountTypeCustomerAccrued, ledger.AccountTypeEarnings},
				{ledger.AccountTypeCustomerFBO, ledger.AccountTypeBrokerage},
			},
		},
		RequireFlowDirectionRule{
			From: ledger.AccountTypeCustomerFBO,
			To:   ledger.AccountTypeCustomerAccrued,
		},
		RequireFlowDirectionRule{
			From: ledger.AccountTypeCustomerReceivable,
			To:   ledger.AccountTypeCustomerAccrued,
		},
		RequireFlowDirectionRule{
			From: ledger.AccountTypeCustomerAccrued,
			To:   ledger.AccountTypeEarnings,
		},
		RequireFlowDirectionRule{
			From: ledger.AccountTypeWash,
			To:   ledger.AccountTypeCustomerReceivable,
		},
		RequireAccountAuthorizationStatusRule{
			WhenHasAccountTypes: []ledger.AccountType{
				ledger.AccountTypeWash,
				ledger.AccountTypeCustomerReceivable,
			},
			AccountType: ledger.AccountTypeCustomerReceivable,
			Expected:    ledger.TransactionAuthorizationStatusAuthorized,
		},
		RequireReceivableAuthorizationStageRule{},
		RequireFBOCostBasisTranslationRule{},
		RequireAccruedCostBasisTranslationRule{},
		RequireSameRouteRule{
			Left:  ledger.AccountTypeCustomerFBO,
			Right: ledger.AccountTypeCustomerReceivable,
			Fields: []RouteField{
				RouteFieldCurrency,
				RouteFieldTaxCode,
				RouteFieldFeatures,
				RouteFieldCostBasis,
			},
		},
		RequireSameRouteRule{
			Left:  ledger.AccountTypeCustomerFBO,
			Right: ledger.AccountTypeCustomerAccrued,
			Fields: []RouteField{
				RouteFieldCurrency,
				RouteFieldCostBasis,
			},
		},
		RequireSameRouteRule{
			Left:  ledger.AccountTypeCustomerReceivable,
			Right: ledger.AccountTypeCustomerAccrued,
			Fields: []RouteField{
				RouteFieldCurrency,
				RouteFieldCostBasis,
			},
		},
		RequireSameRouteRule{
			Left:  ledger.AccountTypeCustomerAccrued,
			Right: ledger.AccountTypeEarnings,
			Fields: []RouteField{
				RouteFieldCurrency,
				RouteFieldCostBasis,
			},
		},
		RequireSameRouteRule{
			Left:  ledger.AccountTypeCustomerReceivable,
			Right: ledger.AccountTypeWash,
			Fields: []RouteField{
				RouteFieldCurrency,
				RouteFieldCostBasis,
			},
		},
	},
}

Functions

This section is empty.

Types

type AllowedAccountSetsRule

type AllowedAccountSetsRule struct {
	Sets [][]ledger.AccountType
}

func (AllowedAccountSetsRule) Validate

func (r AllowedAccountSetsRule) Validate(tx TxView) error

type EntryView

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

func (EntryView) AccountType

func (e EntryView) AccountType() ledger.AccountType

func (EntryView) Amount

func (e EntryView) Amount() alpacadecimal.Decimal

func (EntryView) Entry

func (e EntryView) Entry() ledger.EntryInput

func (EntryView) Route

func (e EntryView) Route() ledger.Route

type FuncRule

type FuncRule func(tx TxView) error

func (FuncRule) Validate

func (f FuncRule) Validate(tx TxView) error

type RequireAccountAuthorizationStatusRule

type RequireAccountAuthorizationStatusRule struct {
	WhenHasAccountTypes []ledger.AccountType
	AccountType         ledger.AccountType
	Expected            ledger.TransactionAuthorizationStatus
}

func (RequireAccountAuthorizationStatusRule) Validate

type RequireAccruedCostBasisTranslationRule

type RequireAccruedCostBasisTranslationRule struct{}

func (RequireAccruedCostBasisTranslationRule) Validate

type RequireFBOCostBasisTranslationRule

type RequireFBOCostBasisTranslationRule struct{}

func (RequireFBOCostBasisTranslationRule) Validate

type RequireFlowDirectionRule

type RequireFlowDirectionRule struct {
	From ledger.AccountType
	To   ledger.AccountType
}

func (RequireFlowDirectionRule) Validate

func (r RequireFlowDirectionRule) Validate(tx TxView) error

type RequireReceivableAuthorizationStageRule

type RequireReceivableAuthorizationStageRule struct{}

func (RequireReceivableAuthorizationStageRule) Validate

type RequireSameRouteRule

type RequireSameRouteRule struct {
	Left   ledger.AccountType
	Right  ledger.AccountType
	Fields []RouteField
}

func (RequireSameRouteRule) Validate

func (r RequireSameRouteRule) Validate(tx TxView) error

type RequireUniqueSubAccountsRule

type RequireUniqueSubAccountsRule struct{}

func (RequireUniqueSubAccountsRule) Validate

func (r RequireUniqueSubAccountsRule) Validate(tx TxView) error

type RouteField

type RouteField string
const (
	RouteFieldCurrency                       RouteField = "currency"
	RouteFieldTaxCode                        RouteField = "tax_code"
	RouteFieldFeatures                       RouteField = "features"
	RouteFieldCostBasis                      RouteField = "cost_basis"
	RouteFieldCreditPriority                 RouteField = "credit_priority"
	RouteFieldTransactionAuthorizationStatus RouteField = "transaction_authorization_status"
)

type RoutingRule

type RoutingRule interface {
	Validate(tx TxView) error
}

type TxView

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

func NewTxView

func NewTxView(entries []ledger.EntryInput) (TxView, error)

func (TxView) AccountTypes

func (t TxView) AccountTypes() []ledger.AccountType

func (TxView) Entries

func (t TxView) Entries() []EntryView

func (TxView) EntriesOf

func (t TxView) EntriesOf(accountType ledger.AccountType) []EntryView

func (TxView) HasAccountType

func (t TxView) HasAccountType(accountType ledger.AccountType) bool

func (TxView) HasAccountTypes

func (t TxView) HasAccountTypes(accountTypes ...ledger.AccountType) bool

type Validator

type Validator struct {
	Rules []RoutingRule
}

func (Validator) ValidateEntries

func (v Validator) ValidateEntries(entries []ledger.EntryInput) error

Jump to

Keyboard shortcuts

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