v0.0.16 Latest Latest

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




This section is empty.


This section is empty.


This section is empty.


type AST

type AST struct {
	Context journal.Context
	Days    map[time.Time]*Day
	// contains filtered or unexported fields

AST represents an unprocessed abstract syntax tree.

func New

func New(ctx journal.Context) *AST

New creates a new AST

func (*AST) AddAssertion

func (ast *AST) AddAssertion(a *Assertion)

AddAssertion adds an Assertion directive.

func (*AST) AddClose

func (ast *AST) AddClose(c *Close)

AddClose adds an Close directive.

func (*AST) AddOpen

func (ast *AST) AddOpen(o *Open)

AddOpen adds an Open directive.

func (*AST) AddPrice

func (ast *AST) AddPrice(p *Price)

AddPrice adds an Price directive.

func (*AST) AddTransaction

func (ast *AST) AddTransaction(t *Transaction)

AddTransaction adds an Transaction directive.

func (*AST) AddValue

func (ast *AST) AddValue(v *Value)

AddValue adds an Value directive.

func (*AST) Day

func (ast *AST) Day(d time.Time) *Day

Day returns the Day for the given date.

func (*AST) Max added in v0.0.16

func (ast *AST) Max() time.Time

func (*AST) Min added in v0.0.16

func (ast *AST) Min() time.Time

func (*AST) SortedDays

func (ast *AST) SortedDays() []*Day

SortedDays returns all days ordered by date.

type Accrual

type Accrual struct {
	Interval date.Interval
	T0, T1   time.Time
	Account  *journal.Account

Accrual represents an accrual.

func (Accrual) Expand

func (a Accrual) Expand(t *Transaction) []*Transaction

Expand expands an accrual transaction.

type Assertion

type Assertion struct {
	Date      time.Time
	Account   *journal.Account
	Amount    decimal.Decimal
	Commodity *journal.Commodity

Assertion represents a balance assertion.

type Close

type Close struct {
	Date    time.Time
	Account *journal.Account

Close represents a close command.

type Currency

type Currency struct {
	Date time.Time

Currency declares that a commodity is a currency.

type Day

type Day struct {
	Date         time.Time
	Prices       []*Price
	Assertions   []*Assertion
	Values       []*Value
	Openings     []*Open
	Transactions []*Transaction
	Closings     []*Close

	Amounts, Value amounts.Amounts

	Normalized journal.NormalizedPrices

	Performance *Performance

Day groups all commands for a given date.

func (*Day) Less

func (d *Day) Less(d2 *Day) bool

Less establishes an ordering on Day.

type Directive

type Directive interface {
	Position() Range

Directive is an element in a journal with a position.

type Include

type Include struct {
	Path string

Include represents an include directive.

type Lot

type Lot struct {
	Date      time.Time
	Label     string
	Price     float64
	Commodity *journal.Commodity

Lot represents a lot.

type Open

type Open struct {
	Date    time.Time
	Account *journal.Account

Open represents an open command.

type Performance added in v0.0.15

type Performance struct {
	V0, V1, Inflow, Outflow, InternalInflow, InternalOutflow map[*journal.Commodity]float64
	PortfolioInflow, PortfolioOutflow                        float64

Performance holds aggregate information used to compute portfolio performance.

type Period added in v0.0.16

type Period struct {
	Period date.Period

	Amounts, Values           amounts.Amounts
	DeltaAmounts, DeltaValues amounts.Amounts
	PrevAmounts, PrevValues   amounts.Amounts

	Days []*Day

Period represents a period.

type Posting

type Posting struct {
	Amount, Value decimal.Decimal
	Credit, Debit *journal.Account
	Commodity     *journal.Commodity
	Targets       []*journal.Commodity
	Lot           *Lot

Posting represents a posting.

func NewPosting

func NewPosting(crAccount, drAccount *journal.Account, commodity *journal.Commodity, amt decimal.Decimal) Posting

NewPosting creates a new posting from the given parameters. If amount is negative, it will be inverted and the accounts reversed.

func NewPostingWithTargets

func NewPostingWithTargets(crAccount, drAccount *journal.Account, commodity *journal.Commodity, amt decimal.Decimal, targets []*journal.Commodity) Posting

NewPostingWithTargets creates a new posting from the given parameters. If amount is negative, it will be inverted and the accounts reversed.

func NewValuePosting added in v0.0.15

func NewValuePosting(crAccount, drAccount *journal.Account, commodity *journal.Commodity, val decimal.Decimal, targets []*journal.Commodity) Posting

NewValuePosting creates a value adjustment posting.

func (Posting) Equal

func (p Posting) Equal(p2 Posting) bool

Equal determines a measure of equality.

func (Posting) Less

func (p Posting) Less(p2 Posting) bool

Less determines an order on postings.

type Price

type Price struct {
	Date      time.Time
	Commodity *journal.Commodity
	Target    *journal.Commodity
	Price     decimal.Decimal

Price represents a price command.

type Range

type Range struct {
	Path       string
	Start, End scanner.Location

Range describes a range of locations in a file.

func (Range) Position

func (r Range) Position() Range

Position returns the Range itself.

type Tag

type Tag string

Tag represents a tag for a transaction or booking.

type Transaction

type Transaction struct {
	// contains filtered or unexported fields

Transaction represents a transaction.

func (Transaction) Accrual added in v0.0.15

func (t Transaction) Accrual() *Accrual

Accrual returns the accrual.

func (Transaction) Commodities

func (t Transaction) Commodities() map[*journal.Commodity]bool

Commodities returns the commodities in this transaction.

func (Transaction) Date

func (t Transaction) Date() time.Time

Date returns the transaction date.

func (Transaction) Description

func (t Transaction) Description() string

Description returns the description.

func (*Transaction) FilterPostings added in v0.0.15

func (t *Transaction) FilterPostings(f journal.Filter) []Posting

FilterPostings returns a list of postings matching the supplied filter.

func (*Transaction) Less

func (t *Transaction) Less(t2 *Transaction) bool

Less defines an order on transactions.

func (Transaction) Position added in v0.0.15

func (t Transaction) Position() Range

Position returns the source location.

func (Transaction) Postings

func (t Transaction) Postings() []Posting

Postings returns the postings.

func (Transaction) Tags

func (t Transaction) Tags() []Tag

Tags returns the tags.

func (Transaction) ToBuilder added in v0.0.15

func (t Transaction) ToBuilder() TransactionBuilder

ToBuilder creates a new builder based on this transaction.

type TransactionBuilder added in v0.0.15

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.0.15

func (tb TransactionBuilder) Build() *Transaction

Build builds a transactions.

type Value

type Value struct {
	Date      time.Time
	Account   *journal.Account
	Amount    decimal.Decimal
	Commodity *journal.Commodity

Value represents a value directive.


Path Synopsis

Jump to

Keyboard shortcuts

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