Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrUnknownCommand = errors.New("unknown command") ErrNonZeroAmount = errors.New("kmm: amount must be greater than zero") ErrInvalidPeriod = errors.New("kmm: period must be minutely, daily, weekly, monthly") ErrInsufficientFunds = errors.New("kmm: insufficient funds") ErrExceedWithinPeriod = errors.New("kmm: withdrawal would exceed max amount allowed in current period") )
View Source
var ( Types = map[string]*types.Type{ "deposit-funds": {Init: func() any { return &DepositFunds{} }}, "funds-deposited": {Init: func() any { return &FundsDeposited{} }}, "withdraw-funds": {Init: func() any { return &WithdrawFunds{} }}, "funds-withdrawn": {Init: func() any { return &FundsWithdrawn{} }}, "set-budget": {Init: func() any { return &SetBudget{} }}, "budget-set": {Init: func() any { return &BudgetSet{} }}, "remove-budget": {Init: func() any { return &RemoveBudget{} }}, "budget-removed": {Init: func() any { return &BudgetRemoved{} }}, "account": {Init: func() any { return NewAccount() }}, "current-funds": {Init: func() any { return &CurrentFunds{} }}, "budget-period": {Init: func() any { return &BudgetPeriod{} }}, } )
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { CurrentFunds decimal.Decimal // Policy related. MaxWithdrawAmount decimal.Decimal PolicyPeriod Period PeriodStartTime time.Time NextPeriodStartTime time.Time FundsWithdrawnInPeriod decimal.Decimal // contains filtered or unexported fields }
Account aggregate which primarily decides on whether a withdrawal is allowed given the current funds and if a policy is set.
The DepositFunds command doesn't even need an aggregate since there is no validation other than command validation that the amount is a positive value (which is done prior to the command being received here).
The Set/RemoveWithdrawPolicy are in the same category and does not really need any aggregated state for them to be accepted.
func NewAccount ¶
func NewAccount() *Account
type BudgetPeriod ¶
type BudgetRemoved ¶
type CurrentFunds ¶
type DepositFunds ¶
func (*DepositFunds) Validate ¶
func (c *DepositFunds) Validate() error
type FundsDeposited ¶
type FundsWithdrawn ¶
type RemoveBudget ¶
type RemoveBudget struct{}
type WithdrawFunds ¶
func (*WithdrawFunds) Validate ¶
func (c *WithdrawFunds) Validate() error
Click to show internal directories.
Click to hide internal directories.