resolvers

package
v1.0.0-beta.231 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const ErrCodeCustomerAccountConflict models.ErrorCode = "customer_account_conflict"

Variables

View Source
var ErrCustomerAccountConflict = models.NewValidationIssue(
	ErrCodeCustomerAccountConflict,
	"customer account mapping conflict, a mapping with the same customer and account type already exists",
	commonhttp.WithHTTPStatusCodeAttribute(http.StatusConflict),
)

Functions

func NewNamespaceHandler

func NewNamespaceHandler(provisioner businessAccountProvisioner) namespace.Handler

Types

type AccountResolver

type AccountResolver struct {
	AccountService ledgeraccount.Service
	Repo           CustomerAccountRepo
	Locker         *lockr.Locker
}

AccountResolver implements ledger.AccountResolver and manages customer ledger account provisioning.

func NewAccountResolver

func NewAccountResolver(cfg AccountResolverConfig) *AccountResolver

NewAccountResolver constructs a resolvers Service from the given config.

func (*AccountResolver) CreateCustomerAccounts

func (s *AccountResolver) CreateCustomerAccounts(ctx context.Context, customerID customer.CustomerID) (ledger.CustomerAccounts, error)

CreateCustomerAccounts creates FBO and Receivable ledger accounts for a new customer and stores the mappings in the linking table.

func (*AccountResolver) EnsureBusinessAccounts

func (s *AccountResolver) EnsureBusinessAccounts(ctx context.Context, namespace string) (ledger.BusinessAccounts, error)

func (*AccountResolver) GetBusinessAccounts

func (s *AccountResolver) GetBusinessAccounts(ctx context.Context, namespace string) (ledger.BusinessAccounts, error)

GetBusinessAccounts retrieves the shared business accounts for a namespace.

func (*AccountResolver) GetCustomerAccounts

func (s *AccountResolver) GetCustomerAccounts(ctx context.Context, customerID customer.CustomerID) (ledger.CustomerAccounts, error)

GetCustomerAccounts retrieves the FBO and Receivable accounts for a customer.

type AccountResolverConfig

type AccountResolverConfig struct {
	AccountService ledgeraccount.Service
	Repo           CustomerAccountRepo
	Locker         *lockr.Locker
}

AccountResolverConfig holds the dependencies for constructing a Service.

type CreateCustomerAccountInput

type CreateCustomerAccountInput struct {
	CustomerID  customer.CustomerID
	AccountType ledger.AccountType
	AccountID   string
}

type CustomerAccountAlreadyExistsError

type CustomerAccountAlreadyExistsError struct {
	CustomerID  customer.CustomerID
	AccountType ledger.AccountType
	AccountID   string
}

func AsCustomerAccountAlreadyExistsError

func AsCustomerAccountAlreadyExistsError(err error) (*CustomerAccountAlreadyExistsError, bool)

func (*CustomerAccountAlreadyExistsError) Error

func (*CustomerAccountAlreadyExistsError) ValidationErrors

type CustomerAccountRepo

type CustomerAccountRepo interface {
	entutils.TxCreator

	CreateCustomerAccount(ctx context.Context, input CreateCustomerAccountInput) error
	GetCustomerAccountIDs(ctx context.Context, customerID customer.CustomerID) (map[ledger.AccountType]string, error)
}

CustomerAccountRepo manages the linking table that maps customers to their ledger accounts.

type CustomerLedgerHook

type CustomerLedgerHook = models.ServiceHook[customer.Customer]

TODO: these hooks should be added to customer lifecycle

func NewCustomerLedgerHook

func NewCustomerLedgerHook(config CustomerLedgerHookConfig) (CustomerLedgerHook, error)

type CustomerLedgerHookConfig

type CustomerLedgerHookConfig struct {
	Service customerAccountProvisioner
	Tracer  trace.Tracer
}

type NoopCustomerLedgerHook

type NoopCustomerLedgerHook = models.NoopServiceHook[customer.Customer]

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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