ledger

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Accrual added in v0.0.7

type Accrual struct {
	Pos         model.Range
	Period      date.Period
	T0, T1      time.Time
	Account     *accounts.Account
	Transaction *Transaction
}

Accrual represents an accrual.

func (*Accrual) Expand added in v0.0.7

func (a *Accrual) Expand() ([]*Transaction, error)

Expand expands an accrual transaction.

func (*Accrual) Position added in v0.0.7

func (a *Accrual) Position() model.Range

Position returns the position.

type Assertion added in v0.0.7

type Assertion struct {
	Pos       model.Range
	Date      time.Time
	Account   *accounts.Account
	Amount    decimal.Decimal
	Commodity *commodities.Commodity
}

Assertion represents a balance assertion.

func (Assertion) Position added in v0.0.7

func (a Assertion) Position() model.Range

Position returns the model.Range.

type Builder

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

Builder maps dates to days

func NewBuilder

func NewBuilder(f Filter) *Builder

NewBuilder creates a new builder.

func (*Builder) AddAssertion

func (b *Builder) AddAssertion(a *Assertion)

AddAssertion adds an assertion directive.

func (*Builder) AddClosing

func (b *Builder) AddClosing(close *Close)

AddClosing adds a close directive.

func (*Builder) AddOpening

func (b *Builder) AddOpening(o *Open)

AddOpening adds an open directive.

func (*Builder) AddPrice

func (b *Builder) AddPrice(p *Price)

AddPrice adds a price directive.

func (*Builder) AddTransaction

func (b *Builder) AddTransaction(t *Transaction)

AddTransaction adds a transaction directive.

func (*Builder) AddValue

func (b *Builder) AddValue(a *Value)

AddValue adds an value directive.

func (*Builder) Build

func (b *Builder) Build() Ledger

Build creates a new

type Close added in v0.0.7

type Close struct {
	Pos     model.Range
	Date    time.Time
	Account *accounts.Account
}

Close represents a close command.

func (Close) Position added in v0.0.7

func (c Close) Position() model.Range

Position returns the position.

type Day added in v0.0.7

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.

type Directive added in v0.0.8

type Directive interface {
	Position() model.Range
}

Directive is an element in a journal with a position.

type Filter added in v0.0.8

type Filter struct {
	AccountsFilter, CommoditiesFilter *regexp.Regexp
}

Filter represents a filter creating a ledger.

type Include added in v0.0.7

type Include struct {
	Pos  model.Range
	Date time.Time
	Path string
}

Include represents an include directive.

func (Include) Position added in v0.0.7

func (i Include) Position() model.Range

Position returns the model.Range.

type Ledger

type Ledger []*Day

Ledger is a ledger.

func FromDirectives added in v0.0.8

func FromDirectives(filter Filter, results <-chan interface{}) (Ledger, error)

FromDirectives reads directives from the given channel and builds a Ledger if successful.

func (Ledger) MaxDate

func (l Ledger) MaxDate() (time.Time, bool)

MaxDate returns the maximum date for the given ledger.

func (Ledger) MinDate

func (l Ledger) MinDate() (time.Time, bool)

MinDate returns the minimum date for this ledger, as the first date on which an account is opened (ignoring prices, for example).

type Lot added in v0.0.7

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

Lot represents a lot.

type Open added in v0.0.7

type Open struct {
	Pos     model.Range
	Date    time.Time
	Account *accounts.Account
}

Open represents an open command.

func (Open) Position added in v0.0.7

func (o Open) Position() model.Range

Position returns the position.

type Posting added in v0.0.7

type Posting struct {
	Amount, Value decimal.Decimal
	Credit, Debit *accounts.Account
	Commodity     *commodities.Commodity
	Lot           *Lot
}

Posting represents a posting.

func NewPosting added in v0.0.7

func NewPosting(crAccount, drAccount *accounts.Account, commodity *commodities.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.

type Price added in v0.0.7

type Price struct {
	Pos       model.Range
	Date      time.Time
	Commodity *commodities.Commodity
	Target    *commodities.Commodity
	Price     decimal.Decimal
}

Price represents a price command.

func (Price) Position added in v0.0.7

func (p Price) Position() model.Range

Position returns the model.Range.

type Tag added in v0.0.7

type Tag string

Tag represents a tag for a transaction or booking.

type Transaction added in v0.0.7

type Transaction struct {
	Pos         model.Range
	Date        time.Time
	Description string
	Tags        []Tag
	Postings    []*Posting
}

Transaction represents a transaction.

func (Transaction) Position added in v0.0.7

func (t Transaction) Position() model.Range

Position returns the Position.

type Value added in v0.0.7

type Value struct {
	Pos       model.Range
	Date      time.Time
	Account   *accounts.Account
	Amount    decimal.Decimal
	Commodity *commodities.Commodity
}

Value represents a value directive.

func (Value) Position added in v0.0.7

func (v Value) Position() model.Range

Position returns the model.Range.

Jump to

Keyboard shortcuts

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