gnucash

package
v0.0.0-...-35d49a2 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID           string         `json:"id"`
	Name         string         `json:"name"`
	Type         string         `json:"type"`
	Parent       *Account       `json:"-"`
	Children     []*Account     `json:"-"`
	Transactions []*Transaction `json:"-"`
}

Account is a node of the accounts hierarchy. Each account has its own list of transactions

func (*Account) Descendants

func (a *Account) Descendants(filter AccountFilter) []*Account

Descendants returns a list of sub-accounts matching the filter, using account a as the starting point of the search

func (*Account) WalkBFS

func (a *Account) WalkBFS(walkFunc WalkAccountFunc) []*Account

WalkBFS traverses the tree of accounts using Breadth-first search algorithm. Starting at node a, returns the list of accounts for which walkFunc is true.

type AccountFilter

type AccountFilter struct {
	ID   string
	Name string
	Type string
}

AccountFilter is the type to express filter condition for Descendants method. Note that it is not possible to filter accounts with Name empty

type DBStatistics

type DBStatistics struct {
	File         string
	Accounts     int
	Transactions int
	LoadDate     string
	LoadTime     string
}

type Database

type Database struct {
	RootAccount *Account
	Statistics  DBStatistics
	Warnings    []error
	// contains filtered or unexported fields
}

func Load

func Load(r io.Reader) (*Database, error)

Load loads a Database from a Gnucash XML document stream

func LoadFile

func LoadFile(path string) (*Database, error)

LoadFile loads a Database from a GnuCash file (compressed or not)

func (*Database) Account

func (db *Database) Account(id string) *Account

type Transaction

type Transaction struct {
	Num   string  `json:"-"`
	Date  string  `json:"-"` // YYYY-MM-DD
	Value float64 `json:"-"`
}

Transaction keeps data for a transaction

type WalkAccountFunc

type WalkAccountFunc func(act *Account) bool

WalkAccountFunc is the type of the function called for each account visited by WalkBFS

Jump to

Keyboard shortcuts

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