amounts

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccountMatches

func AccountMatches(regexes []*regexp.Regexp) predicate.Predicate[Key]

func CommodityMatches

func CommodityMatches(regexes []*regexp.Regexp) predicate.Predicate[Key]

func FilterDates

func FilterDates(pred predicate.Predicate[time.Time]) predicate.Predicate[Key]

func OtherAccountMatches

func OtherAccountMatches(regexes []*regexp.Regexp) predicate.Predicate[Key]

Types

type Amounts

type Amounts map[Key]decimal.Decimal

Amounts keeps track of amounts by account and commodity.

func (Amounts) Add

func (am Amounts) Add(key Key, value decimal.Decimal)

func (Amounts) Amount

func (am Amounts) Amount(key Key) decimal.Decimal

Amount returns the amount for the given key.

func (Amounts) Clone

func (am Amounts) Clone() Amounts

Clone clones these amounts.

func (Amounts) Commodities

func (am Amounts) Commodities() set.Set[*model.Commodity]

func (Amounts) CommoditiesSorted

func (am Amounts) CommoditiesSorted() []*model.Commodity

func (Amounts) Dates

func (am Amounts) Dates() set.Set[time.Time]

func (Amounts) DatesSorted

func (am Amounts) DatesSorted() []time.Time

func (Amounts) Index

func (am Amounts) Index(cmp compare.Compare[Key]) []Key

func (Amounts) Minus

func (am Amounts) Minus(other Amounts)

Minus mutably subtracts.

func (Amounts) Plus

func (am Amounts) Plus(other Amounts)

Plus mutably adds.

func (Amounts) SumBy

func (am Amounts) SumBy(pred func(k Key) bool, mapr func(k Key) Key) Amounts

func (Amounts) SumIntoBy

func (am Amounts) SumIntoBy(dest Amounts, pred func(k Key) bool, mapr func(k Key) Key)

func (Amounts) SumOver

func (am Amounts) SumOver(pred func(k Key) bool) decimal.Decimal

type Key

type Key struct {
	Date           time.Time
	Account, Other *model.Account
	Commodity      *model.Commodity
	Valuation      *model.Commodity
	Description    string
}

Key represents a position.

func AccountCommodityKey

func AccountCommodityKey(account *model.Account, commodity *model.Commodity) Key

func AccountKey

func AccountKey(account *model.Account) Key

func CommodityKey

func CommodityKey(commodity *model.Commodity) Key

func DateCommodityKey

func DateCommodityKey(date time.Time, commodity *model.Commodity) Key

func DateKey

func DateKey(date time.Time) Key

type KeyMapper

type KeyMapper struct {
	Date                 mapper.Mapper[time.Time]
	Account, Other       mapper.Mapper[*model.Account]
	Commodity, Valuation mapper.Mapper[*model.Commodity]
	Description          mapper.Mapper[string]
}

func (KeyMapper) Build

func (km KeyMapper) Build() mapper.Mapper[Key]

Jump to

Keyboard shortcuts

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