fifo

package
v0.0.0-...-50d9c68 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ERR_NO_ENTRY = iota
	ERR_INSUFFICIENT
)

Variables

This section is empty.

Functions

func IsFifoError

func IsFifoError(err error) bool

func IsFifoErrorInsufficient

func IsFifoErrorInsufficient(err error, code int) bool

func IsFifoErrorNoEntry

func IsFifoErrorNoEntry(err error, code int) bool

Types

type Asset

type Asset struct {
	Name    string
	Total   string
	Entries EntryList
}

type Entry

type Entry struct {
	Units          d.Decimal
	UnitsLeft      d.Decimal
	UnitCost       d.Decimal
	UnitCostEur    d.Decimal
	UnitFeeCostEur d.Decimal
	UnitFeeCost    d.Decimal
	Ts             time.Time
}

func NewEntry

func NewEntry(amount, valueC, feeC d.Decimal, ts time.Time) Entry

func (*Entry) Copy

func (e *Entry) Copy() Entry

type EntryList

type EntryList []Entry

func (EntryList) Copy

func (e EntryList) Copy() EntryList

func (EntryList) Print

func (e EntryList) Print() string

func (EntryList) Sort

func (e EntryList) Sort()

func (EntryList) TotalUnits

func (e EntryList) TotalUnits() d.Decimal

func (EntryList) TotalUnitsLeft

func (e EntryList) TotalUnitsLeft() d.Decimal

type Fifo

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

func NewFifo

func NewFifo() *Fifo

func (*Fifo) Add

func (f *Fifo) Add(assetName string, e Entry)

func (*Fifo) CouldTake

func (f *Fifo) CouldTake(assetName string, units d.Decimal, decimals int32) bool

func (*Fifo) HasUnits

func (f *Fifo) HasUnits(assetName string) bool

func (*Fifo) Print

func (f *Fifo) Print() string

func (*Fifo) Read

func (f *Fifo) Read(assetName string) Asset

func (*Fifo) Take

func (f *Fifo) Take(assetName string, units d.Decimal, decimals int32) (Asset, error)

type FifoError

type FifoError struct {
	Code           int
	RequiredAmount string
	MissingAmount  string
	// contains filtered or unexported fields
}

func NewFifoError

func NewFifoError(code int, err string) FifoError

func NewFifoTakeError

func NewFifoTakeError(code int, err string, reqAmount, missingAmount string) FifoError

func (FifoError) Error

func (f FifoError) Error() string

Jump to

Keyboard shortcuts

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