entity

package
v0.0.0-...-3bb572b Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID        uuid.UUID
	Customer  *Customer
	Balance   decimal.Decimal
	CreatedAt time.Time
	UpdatedAt time.Time
}

func NewAccount

func NewAccount(customer *Customer) (*Account, error)

func (*Account) Credit

func (a *Account) Credit(amount decimal.Decimal) error

func (*Account) Debit

func (a *Account) Debit(amount decimal.Decimal) error

type Customer

type Customer struct {
	ID        uuid.UUID
	Name      string
	Email     string
	CreatedAt time.Time
	UpdatedAt time.Time
}

func NewCustomer

func NewCustomer(name string, email string) (*Customer, error)

func (*Customer) Update

func (c *Customer) Update(name string, email string) error

func (*Customer) Validate

func (c *Customer) Validate() error

type Status

type Status string

type Transaction

type Transaction struct {
	ID          uuid.UUID
	FromAccount *Account
	ToAccount   *Account
	Status      Status
	Amount      decimal.Decimal
	CreatedAt   time.Time
}

func NewTransaction

func NewTransaction(fromAccount *Account, toAccount *Account, amount decimal.Decimal) (*Transaction, error)

func (*Transaction) Commit

func (t *Transaction) Commit() error

func (*Transaction) Validate

func (t *Transaction) Validate() error

Jump to

Keyboard shortcuts

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