journal

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareDays added in v0.1.1

func CompareDays(d *Day, d2 *Day) compare.Order

Less establishes an ordering on Day.

func FromModelStream added in v0.1.2

func FromModelStream(modelCh <-chan []model.Directive) (<-chan *Builder, func(context.Context) error)

func Print added in v0.1.2

func Print(w io.Writer, j *Journal) error

PrintJournal prints a journal.

Types

type Builder added in v0.1.2

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

Builder represents an unprocessed

func FromPath added in v0.1.1

func FromPath(ctx context.Context, reg *model.Registry, path string) (*Builder, error)

func New added in v0.1.1

func New() *Builder

New creates a new Journal.

func (*Builder) Add added in v0.1.2

func (j *Builder) Add(d model.Directive) error

func (*Builder) Build added in v0.1.2

func (j *Builder) Build() *Journal

func (*Builder) Day added in v0.1.2

func (j *Builder) Day(d time.Time) *Day

Day returns the Day for the given date.

func (*Builder) Days added in v0.1.2

func (j *Builder) Days(dates []time.Time) []*Day

func (*Builder) Period added in v0.1.2

func (j *Builder) Period() date.Period

type Collection added in v0.1.1

type Collection interface {
	Insert(k amounts.Key, v decimal.Decimal)
}

type Day added in v0.1.1

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

	Normalized price.NormalizedPrices

	Performance *Performance
}

Day groups all commands for a given date.

type Journal

type Journal struct {
	Days []*Day
}

func (*Journal) Process added in v0.1.1

func (j *Journal) Process(ps ...*Processor) error

type Performance added in v0.1.1

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

Performance holds aggregate information used to compute portfolio performance.

func (Performance) String added in v0.1.2

func (p Performance) String() string

type Processor added in v0.1.2

type Processor struct {
	DayStart    func(*Day) error
	Price       func(*model.Price) error
	Open        func(*model.Open) error
	Transaction func(*model.Transaction) error
	Posting     func(*model.Transaction, *model.Posting) error
	Assertion   func(*model.Assertion) error
	Balance     func(*model.Assertion, *model.Balance) error
	Close       func(*model.Close) error
	DayEnd      func(*Day) error
}

func CloseAccounts added in v0.1.1

func CloseAccounts(j *Builder, reg *model.Registry, enable bool, partition date.Partition) *Processor

Balance balances the journal.

func ComputePrices added in v0.1.1

func ComputePrices(v *model.Commodity) *Processor

ComputePrices updates prices.

func Filter added in v0.0.14

func Filter(part date.Partition) *Processor

func Sort added in v0.1.1

func Sort() *Processor

Sort sorts the directives in this day.

func Valuate added in v0.1.2

func Valuate(reg *model.Registry, valuation *model.Commodity) *Processor

Balance balances the journal.

func (*Processor) Process added in v0.1.2

func (proc *Processor) Process(d *Day) error

type Query added in v0.1.1

type Query struct {
	Select    mapper.Mapper[amounts.Key]
	Where     predicate.Predicate[amounts.Key]
	Valuation *model.Commodity
}

func (Query) Into added in v0.1.2

func (query Query) Into(c Collection) *Processor

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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