amounts

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterAccount added in v0.0.16

func FilterAccount(r *regexp.Regexp) filter.Filter[Key]

func FilterCommodity added in v0.0.16

func FilterCommodity(r *regexp.Regexp) filter.Filter[Key]

func FilterDates added in v0.0.16

func FilterDates(t time.Time) filter.Filter[Key]

func FilterOther added in v0.0.16

func FilterOther(r *regexp.Regexp) filter.Filter[Key]

func Identity added in v0.0.16

func Identity[T any](t T) T

func SortByAccount added in v0.0.16

func SortByAccount(jctx journal.Context, w map[*journal.Account]float64) compare.Compare[Key]

func SortByCommodity added in v0.0.16

func SortByCommodity(k1, k2 Key) compare.Order

func SortByDate added in v0.0.16

func SortByDate(k1, k2 Key) compare.Order

Types

type Amounts

type Amounts map[Key]decimal.Decimal

Amounts keeps track of amounts by account and commodity.

func (Amounts) Add added in v0.0.16

func (am Amounts) Add(k Key, d decimal.Decimal)

func (Amounts) Amount

func (am Amounts) Amount(k 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 added in v0.0.16

func (am Amounts) Commodities() map[*journal.Commodity]struct{}

func (Amounts) CommoditiesSorted added in v0.0.16

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

func (Amounts) Dates added in v0.0.16

func (am Amounts) Dates() map[time.Time]struct{}

func (Amounts) DatesSorted added in v0.0.16

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

func (Amounts) Index added in v0.0.16

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

func (Amounts) Minus

func (am Amounts) Minus(a Amounts) Amounts

Minus mutably subtracts.

func (Amounts) Plus added in v0.0.16

func (am Amounts) Plus(a Amounts) Amounts

Plus mutably adds.

func (Amounts) SumBy added in v0.0.16

func (am Amounts) SumBy(f func(k Key) bool, m func(k Key) Key) Amounts

func (Amounts) SumIntoBy added in v0.0.16

func (am Amounts) SumIntoBy(as Amounts, f func(k Key) bool, m func(k Key) Key)

func (Amounts) SumOver added in v0.0.16

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

type Key added in v0.0.16

type Key struct {
	Date           time.Time
	Account, Other *journal.Account
	Commodity      *journal.Commodity
	Valuation      *journal.Commodity
}

Key represents a position.

func AccountCommodityKey added in v0.0.16

func AccountCommodityKey(a *journal.Account, c *journal.Commodity) Key

func AccountKey added in v0.0.16

func AccountKey(a *journal.Account) Key

func CommodityKey added in v0.0.16

func CommodityKey(c *journal.Commodity) Key

func DateCommodityKey added in v0.0.16

func DateCommodityKey(d time.Time, c *journal.Commodity) Key

func DateKey added in v0.0.16

func DateKey(d time.Time) Key

type KeyMapper added in v0.0.16

type KeyMapper struct {
	Date                 func(time.Time) time.Time
	Account, Other       func(*journal.Account) *journal.Account
	Commodity, Valuation func(*journal.Commodity) *journal.Commodity
}

func (KeyMapper) Build added in v0.0.16

func (km KeyMapper) Build() Mapper

type Mapper added in v0.0.16

type Mapper func(Key) Key

Jump to

Keyboard shortcuts

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