ast

package
v0.0.14 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AST

type AST struct {
	Context journal.Context
	Days    map[time.Time]*Day
}

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) SortedDays

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

SortedDays returns all days ordered by date.

type Accrual

type Accrual struct {
	Range
	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 {
	Range
	Date      time.Time
	Account   *journal.Account
	Amount    decimal.Decimal
	Commodity *journal.Commodity
}

Assertion represents a balance assertion.

type Close

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

Close represents a close command.

type Currency

type Currency struct {
	Range
	*journal.Commodity
}

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
}

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 {
	Range
	Date time.Time
	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 {
	Range
	Date    time.Time
	Account *journal.Account
}

Open represents an open command.

type Posting

type Posting struct {
	Amount        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 (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.

func (Posting) Matches

func (p Posting) Matches(b journal.Filter) bool

Matches returns whether this filter matches the given Posting.

type Price

type Price struct {
	Range
	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 {
	Range
	Date        time.Time
	Description string
	Tags        []Tag
	Postings    []Posting
	AddOns      []interface{}
}

Transaction represents a transaction.

func (Transaction) Clone

func (t Transaction) Clone() *Transaction

Clone clones a transaction.

func (Transaction) Commodities

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

Commodities returns the commodities in this transaction.

func (*Transaction) Less

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

Less defines an order on transactions.

type Value

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

Value represents a value directive.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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