journal

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

AccountTypes is an array with the ordered accont types.

Functions

This section is empty.

Types

type Account added in v0.0.14

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

Account represents an account which can be used in bookings.

func (Account) Children added in v0.0.14

func (a Account) Children() []*Account

Children returns the children of this account.

func (Account) Descendents added in v0.0.14

func (a Account) Descendents() []*Account

Descendents returns all the descendents of this account, not including the account itself.

func (Account) IsAL added in v0.0.14

func (a Account) IsAL() bool

IsAL returns whether this account is an asset or liability account.

func (Account) Level added in v0.0.14

func (a Account) Level() int

Level returns the name of this account.

func (*Account) Map added in v0.0.14

func (a *Account) Map(m Mapping) *Account

Map maps an account to itself or to one of its ancestors.

func (Account) Name added in v0.0.14

func (a Account) Name() string

Name returns the name of this account.

func (Account) Parent added in v0.0.14

func (a Account) Parent() *Account

Parent returns the parent of this account.

func (Account) Segment added in v0.0.14

func (a Account) Segment() string

Segment returns the name of this account.

func (*Account) Split added in v0.0.14

func (a *Account) Split() []string

Split returns the account name split into segments.

func (Account) String added in v0.0.14

func (a Account) String() string

func (Account) Type added in v0.0.14

func (a Account) Type() AccountType

Type returns the account type.

func (Account) WriteTo added in v0.0.14

func (a Account) WriteTo(w io.Writer) (int64, error)

WriteTo writes the account to the writer.

type AccountType added in v0.0.14

type AccountType int

AccountType is the type of an account.

const (
	// ASSETS represents an asset account.
	ASSETS AccountType = iota
	// LIABILITIES represents a liability account.
	LIABILITIES
	// EQUITY represents an equity account.
	EQUITY
	// INCOME represents an income account.
	INCOME
	// EXPENSES represents an expenses account.
	EXPENSES
)

func (AccountType) String added in v0.0.14

func (t AccountType) String() string

type Accounts added in v0.0.14

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

Accounts is a thread-safe collection of accounts.

func NewAccounts added in v0.0.14

func NewAccounts() *Accounts

NewAccounts creates a new thread-safe collection of accounts.

func (*Accounts) Get added in v0.0.14

func (as *Accounts) Get(name string) (*Account, error)

Get returns an account.

func (*Accounts) PostOrder added in v0.0.14

func (as *Accounts) PostOrder() []*Account

PostOrder iterates over accounts in post-order.

func (*Accounts) PreOrder added in v0.0.14

func (as *Accounts) PreOrder() []*Account

PreOrder iterates over accounts in post-order.

func (*Accounts) SortedPreOrder added in v0.0.14

func (as *Accounts) SortedPreOrder(weights map[*Account]float64) []*Account

SortedPreOrder sorts every level according to the weights supplied. The given weights must be dense.

type Commodities added in v0.0.14

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

Commodities is a thread-safe collection of commodities.

func NewCommodities added in v0.0.14

func NewCommodities() *Commodities

NewCommodities creates a new thread-safe collection of commodities.

func (*Commodities) Enumerate added in v0.0.14

func (cs *Commodities) Enumerate() <-chan *Commodity

Enumerate enumerates the commodities.

func (*Commodities) Get added in v0.0.14

func (cs *Commodities) Get(name string) (*Commodity, error)

Get creates a new commodity.

func (*Commodities) TagCurrency added in v0.0.14

func (cs *Commodities) TagCurrency(name string) error

TagCurrency tags the commodity as a currency.

type Commodity added in v0.0.14

type Commodity struct {
	IsCurrency bool
	// contains filtered or unexported fields
}

Commodity represents a currency or security.

func (Commodity) MarshalJSON added in v0.0.14

func (c Commodity) MarshalJSON() ([]byte, error)

MarshalJSON marshals a commodity to JSON.

func (Commodity) String added in v0.0.14

func (c Commodity) String() string

type Context added in v0.0.14

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

Context has context for this ledger, namely a collection of referenced accounts and

func NewContext added in v0.0.14

func NewContext() Context

NewContext creates a new, empty context.

func (Context) Account added in v0.0.14

func (ctx Context) Account(name string) *Account

Account returns a commodity or panics.

func (Context) Accounts added in v0.0.14

func (ctx Context) Accounts() *Accounts

Accounts returns the accounts.

func (Context) Commodities added in v0.0.14

func (ctx Context) Commodities() *Commodities

Commodities returns the commodities.

func (Context) Commodity added in v0.0.14

func (ctx Context) Commodity(name string) *Commodity

Commodity returns a commodity or panics.

func (Context) GetAccount added in v0.0.14

func (ctx Context) GetAccount(name string) (*Account, error)

GetAccount returns an account.

func (Context) GetCommodity added in v0.0.14

func (ctx Context) GetCommodity(name string) (*Commodity, error)

GetCommodity returns a commodity.

func (Context) TBDAccount added in v0.0.14

func (ctx Context) TBDAccount() *Account

TBDAccount returns the TBD account.

func (Context) ValuationAccount added in v0.0.14

func (ctx Context) ValuationAccount() *Account

ValuationAccount returns the account for automatic valuation bookings.

func (Context) ValuationAccountFor added in v0.0.14

func (ctx Context) ValuationAccountFor(a *Account) *Account

ValuationAccountFor returns the valuation account which corresponds to the given Asset or Liability account.

type Filter added in v0.0.14

type Filter struct {
	Accounts, Commodities *regexp.Regexp
}

Filter represents a filter for commodities and accounts.

func (Filter) MatchAccount added in v0.0.14

func (b Filter) MatchAccount(a *Account) bool

MatchAccount returns whether this filter matches the given account.

func (Filter) MatchCommodity added in v0.0.14

func (b Filter) MatchCommodity(c *Commodity) bool

MatchCommodity returns whether this filter matches the given commodity.

type Mapping added in v0.0.14

type Mapping []Rule

Mapping is a set of mapping rules.

func (Mapping) String added in v0.0.14

func (m Mapping) String() string

type NormalizedPrices added in v0.0.14

type NormalizedPrices map[*Commodity]decimal.Decimal

NormalizedPrices is a map representing the price of commodities in some base commodity.

func (NormalizedPrices) Valuate added in v0.0.14

Valuate valuates the given amount.

type Prices added in v0.0.14

type Prices map[*Commodity]map[*Commodity]decimal.Decimal

Prices stores the price for a commodity to a target commodity Outer map: target commodity Inner map: commodity value: price in (target commodity / commodity)

func (Prices) Insert added in v0.0.14

func (p Prices) Insert(commodity *Commodity, price decimal.Decimal, target *Commodity)

Insert inserts a new price.

func (Prices) Normalize added in v0.0.14

func (p Prices) Normalize(c *Commodity) NormalizedPrices

Normalize creates a normalized price map for the given commodity.

type Rule added in v0.0.14

type Rule struct {
	Level int
	Regex *regexp.Regexp
}

Rule is a rule to shorten accounts which match the given regex.

func (Rule) String added in v0.0.14

func (r Rule) String() string

Directories

Path Synopsis
ast

Jump to

Keyboard shortcuts

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