transaction

package
v0.0.0-...-97d844a Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package transaction. A transaction aggregates the value from a movement, the date on which was made and the entity which benefit from the movement.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidTransactionID ...
	ErrInvalidTransactionID = errors.New("invalid transaction ID")

	// ErrInvalidDate ...
	ErrInvalidDate = errors.New("invalid transaction date")

	// ErrInvalidSeller ...
	ErrInvalidSeller = errors.New("invalid transaction seller ID")

	// ErrInvalidValue ...
	ErrInvalidValue = errors.New("invalid transaction value")
)
View Source
var ErrInvalidMoneyValue = errors.New("invalid money value")

ErrInvalidMoneyValue ...

Functions

This section is empty.

Types

type Entity

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

Entity represents a transaction

func New

func New(id uint64, date time.Time, seller *seller.Entity, value *Money) (*Entity, error)

New creates a new transaction

func (*Entity) GoString

func (t *Entity) GoString() string

GoString to satisfy fmt.GoStringer

func (*Entity) ID

func (t *Entity) ID() uint64

ID returns the identification of the transaction

func (*Entity) Seller

func (t *Entity) Seller() *seller.Entity

Seller of the transaction

func (*Entity) Value

func (t *Entity) Value() *Money

Value of the transaction

type Money

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

Money value object

func NewMoney

func NewMoney(value int64) (*Money, error)

NewMoney creates an instance of money

func (*Money) Add

func (m *Money) Add(money *Money) (*Money, error)

Add an instance of money an returns another representing the result

func (*Money) String

func (m *Money) String() string

String to satisfy the fmt.Stringer

func (*Money) Value

func (m *Money) Value() int64

Jump to

Keyboard shortcuts

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