Documentation ¶
Index ¶
- Variables
- func CompareAccountTypes(t1, t2 AccountType) compare.Order
- func CompareAccounts(a1, a2 *Account) compare.Order
- func CompareCommodities(c1, c2 *Commodity) compare.Order
- func CompareDays(d *Day, d2 *Day) compare.Order
- func ComparePostings(p, p2 *Posting) compare.Order
- func CompareTransactions(t *Transaction, t2 *Transaction) compare.Order
- func CompareWeighted(jctx Context, w map[*Account]float64) compare.Compare[*Account]
- func FilterAccount(r []*regexp.Regexp) filter.Filter[Key]
- func FilterCommodity(rx []*regexp.Regexp) filter.Filter[Key]
- func FilterDates(f filter.Filter[time.Time]) filter.Filter[Key]
- func FilterOther(r []*regexp.Regexp) filter.Filter[Key]
- func MapCommodity(t bool) func(*Commodity) *Commodity
- func NoOp[T any](_ T) error
- func RemapAccount(jctx Context, rs regex.Regexes) mapper.Mapper[*Account]
- func ShortenAccount(jctx Context, m AccountMapping) mapper.Mapper[*Account]
- type Account
- type AccountMapping
- type AccountType
- type Accounts
- func (as *Accounts) Ancestors(a *Account) []*Account
- func (as *Accounts) Children(a *Account) []*Account
- func (as *Accounts) Get(name string) (*Account, error)
- func (as *Accounts) NthParent(a *Account, n int) *Account
- func (as *Accounts) Parent(a *Account) *Account
- func (as *Accounts) SwapType(a *Account) *Account
- type Accrual
- type Amounts
- func (am Amounts) Add(k Key, d decimal.Decimal)
- func (am Amounts) Amount(k Key) decimal.Decimal
- func (am Amounts) Clone() Amounts
- func (am Amounts) Commodities() set.Set[*Commodity]
- func (am Amounts) CommoditiesSorted() []*Commodity
- func (am Amounts) Dates() set.Set[time.Time]
- func (am Amounts) DatesSorted() []time.Time
- func (am Amounts) Index(cmp compare.Compare[Key]) []Key
- func (am Amounts) Minus(a Amounts) Amounts
- func (am Amounts) Plus(a Amounts) Amounts
- func (am Amounts) SumBy(f func(k Key) bool, m func(k Key) Key) Amounts
- func (am Amounts) SumIntoBy(as Amounts, f func(k Key) bool, m func(k Key) Key)
- func (am Amounts) SumOver(f func(k Key) bool) decimal.Decimal
- type Assertion
- type Close
- type Collection
- type Commodities
- type Commodity
- type Context
- func (ctx Context) Account(name string) *Account
- func (ctx Context) Accounts() *Accounts
- func (ctx Context) Commodities() *Commodities
- func (ctx Context) Commodity(name string) *Commodity
- func (ctx Context) GetAccount(name string) (*Account, error)
- func (ctx Context) GetCommodity(name string) (*Commodity, error)
- func (ctx Context) TBDAccount() *Account
- func (ctx Context) ValuationAccount() *Account
- func (ctx Context) ValuationAccountFor(a *Account) *Account
- type Currency
- type Day
- type DayFn
- type Directive
- type Error
- type Include
- type Journal
- func (j *Journal) AddAssertion(a *Assertion)
- func (j *Journal) AddClose(c *Close)
- func (j *Journal) AddOpen(o *Open)
- func (j *Journal) AddPrice(p *Price)
- func (j *Journal) AddTransaction(t *Transaction)
- func (j *Journal) AddValue(v *Value)
- func (j *Journal) Day(d time.Time) *Day
- func (j *Journal) Max() time.Time
- func (j *Journal) Min() time.Time
- func (j *Journal) Period() date.Period
- func (j *Journal) Process(fs ...func(*Day) error) (*Ledger, error)
- func (j *Journal) ToLedger() *Ledger
- type Key
- type KeyMapper
- type Ledger
- type Lot
- type NormalizedPrices
- type Open
- type Parser
- type Performance
- type Posting
- type PostingBuilder
- type PostingBuilders
- type Price
- type Prices
- type Printer
- type Range
- type RecursiveParser
- type Rule
- type Tag
- type Transaction
- type TransactionBuilder
- type Value
Constants ¶
This section is empty.
Variables ¶
var AccountTypes = []AccountType{ASSETS, LIABILITIES, EQUITY, INCOME, EXPENSES}
AccountTypes is an array with the ordered accont types.
Functions ¶
func CompareAccountTypes ¶ added in v0.0.16
func CompareAccountTypes(t1, t2 AccountType) compare.Order
func CompareAccounts ¶ added in v0.1.1
func CompareCommodities ¶ added in v0.0.16
func CompareDays ¶ added in v0.1.1
Less establishes an ordering on Day.
func ComparePostings ¶ added in v0.1.1
Less determines an order on postings.
func CompareTransactions ¶ added in v0.1.1
func CompareTransactions(t *Transaction, t2 *Transaction) compare.Order
Less defines an order on transactions.
func CompareWeighted ¶ added in v0.0.16
func MapCommodity ¶ added in v0.0.16
func RemapAccount ¶ added in v0.1.1
func ShortenAccount ¶ added in v0.1.1
func ShortenAccount(jctx Context, m AccountMapping) mapper.Mapper[*Account]
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) IsAL ¶ added in v0.0.14
IsAL returns whether this account is an asset or liability account.
func (Account) IsIE ¶ added in v0.1.1
IsIE returns whether this account is an income or expense account.
func (Account) Type ¶ added in v0.0.14
func (a Account) Type() AccountType
Type returns the account type.
type AccountMapping ¶ added in v0.1.1
type AccountMapping []Rule
AccountMapping is a set of mapping rules.
func (AccountMapping) String ¶ added in v0.1.1
func (m AccountMapping) String() string
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) Ancestors ¶ added in v0.0.16
Ancestors returns the chain of ancestors of a, including a.
type Accrual ¶ added in v0.1.1
Accrual represents an accrual.
func (Accrual) Expand ¶ added in v0.1.1
func (a Accrual) Expand(t *Transaction) []*Transaction
Expand expands an accrual transaction.
type Amounts ¶ added in v0.1.1
Amounts keeps track of amounts by account and commodity.
func (Amounts) CommoditiesSorted ¶ added in v0.1.1
func (Amounts) DatesSorted ¶ added in v0.1.1
type Assertion ¶ added in v0.1.1
type Assertion struct { Range Date time.Time Account *Account Amount decimal.Decimal Commodity *Commodity }
Assertion represents a balance assertion.
type Collection ¶ added in v0.1.1
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) 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.
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) Commodities ¶ added in v0.0.14
func (ctx Context) Commodities() *Commodities
Commodities returns the commodities.
func (Context) GetAccount ¶ added in v0.0.14
GetAccount returns an account.
func (Context) GetCommodity ¶ added in v0.0.14
GetCommodity returns a commodity.
func (Context) TBDAccount ¶ added in v0.0.14
TBDAccount returns the TBD account.
func (Context) ValuationAccount ¶ added in v0.0.14
ValuationAccount returns the account for automatic valuation bookings.
func (Context) ValuationAccountFor ¶ added in v0.0.14
ValuationAccountFor returns the valuation account which corresponds to the given Asset or Liability account.
type Day ¶ added in v0.1.1
type Day struct { Date time.Time Prices []*Price Assertions []*Assertion Values []*Value Openings []*Open Transactions []*Transaction Closings []*Close Normalized NormalizedPrices Performance *Performance }
Day groups all commands for a given date.
type DayFn ¶ added in v0.1.1
func CloseAccounts ¶ added in v0.1.1
Balance balances the journal.
func ComputePrices ¶ added in v0.1.1
ComputePrices updates prices.
type Directive ¶ added in v0.1.1
type Directive interface {
Position() Range
}
Directive is an element in a journal with a position.
type Error ¶ added in v0.1.1
type Error struct {
// contains filtered or unexported fields
}
Error is a processing error, with a reference to a directive with a source location.
type Journal ¶
type Journal struct { Context Context Days map[time.Time]*Day // contains filtered or unexported fields }
Journal represents an unprocessed
func (*Journal) AddAssertion ¶ added in v0.1.1
AddAssertion adds an Assertion directive.
func (*Journal) AddTransaction ¶ added in v0.1.1
func (j *Journal) AddTransaction(t *Transaction)
AddTransaction adds an Transaction directive.
type Key ¶ added in v0.1.1
type Key struct { Date time.Time Account, Other *Account Commodity *Commodity Valuation *Commodity Description string }
Key represents a position.
func AccountCommodityKey ¶ added in v0.1.1
func AccountKey ¶ added in v0.1.1
func CommodityKey ¶ added in v0.1.1
type KeyMapper ¶ added in v0.1.1
type NormalizedPrices ¶ added in v0.0.14
NormalizedPrices is a map representing the price of commodities in some base commodity.
func NewNormalizedPrices ¶ added in v0.1.1
func NewNormalizedPrices() NormalizedPrices
type Parser ¶ added in v0.1.1
type Parser struct {
// contains filtered or unexported fields
}
Parser parses a journal
func ParserFromPath ¶ added in v0.1.1
ParserFromPath creates a new parser for the given file.
type Performance ¶ added in v0.1.1
type Performance struct {
V0, V1, Inflow, Outflow, InternalInflow, InternalOutflow map[*Commodity]float64
PortfolioInflow, PortfolioOutflow float64
}
Performance holds aggregate information used to compute portfolio performance.
type Posting ¶ added in v0.1.1
type Posting struct {
Amount, Value decimal.Decimal
Account, Other *Account
Commodity *Commodity
Targets []*Commodity
Lot *Lot
}
Posting represents a posting.
type PostingBuilder ¶ added in v0.1.1
type PostingBuilder struct {
Amount, Value decimal.Decimal
Credit, Debit *Account
Commodity *Commodity
Targets []*Commodity
Lot *Lot
}
func (PostingBuilder) Build ¶ added in v0.1.1
func (pb PostingBuilder) Build() []*Posting
type PostingBuilders ¶ added in v0.1.1
type PostingBuilders []PostingBuilder
func (PostingBuilders) Build ¶ added in v0.1.1
func (pbs PostingBuilders) Build() []*Posting
type Price ¶ added in v0.1.1
type Price struct { Range Date time.Time Commodity *Commodity Target *Commodity Price decimal.Decimal }
Price represents a price command.
type Prices ¶ added in v0.0.14
type Prices map[*Commodity]NormalizedPrices
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) Normalize ¶ added in v0.0.14
func (pr Prices) Normalize(t *Commodity) NormalizedPrices
Normalize creates a normalized price map for the given commodity.
type Printer ¶ added in v0.1.1
type Printer struct {
Padding int
}
Printer prints directives.
func (*Printer) Initialize ¶ added in v0.1.1
Initialize initializes the padding of this printer.
func (Printer) PrintDirective ¶ added in v0.1.1
PrintDirective prints a directive to the given Writer.
type RecursiveParser ¶ added in v0.1.1
type RecursiveParser struct { File string Context Context // contains filtered or unexported fields }
RecursiveParser parses a file hierarchy recursively.
type Transaction ¶ added in v0.1.1
type Transaction struct { Range Range Date time.Time Description string Tags []Tag Postings []*Posting Accrual *Accrual }
Transaction represents a transaction.
func (Transaction) Position ¶ added in v0.1.1
func (t Transaction) Position() Range
Position returns the source location.
type TransactionBuilder ¶ added in v0.1.1
type TransactionBuilder struct { Range Range Date time.Time Description string Tags []Tag Postings []*Posting Accrual *Accrual }
TransactionBuilder builds transactions.
func (TransactionBuilder) Build ¶ added in v0.1.1
func (tb TransactionBuilder) Build() *Transaction
Build builds a transactions.