Documentation ¶
Index ¶
- Constants
- func AccountLcp(ss []string) string
- func FitAccountname(name string, maxwidth int) string
- func FitPayee(payee string, maxwidth int) string
- func JoinAccounts(segments []string) string
- func SplitAccount(name string) []string
- func Vector2scalar(nodes []parsec.ParsecNode) parsec.ParsecNode
- func Ydate(year int) parsec.Parser
- type Account
- func (acc *Account) Balance(obj interface{}) (balance api.Commoditiser)
- func (acc *Account) Balanced() bool
- func (acc *Account) Balances() []api.Commoditiser
- func (acc *Account) Clone(ndb *Datastore) *Account
- func (acc *Account) Credit(obj interface{}) (balance api.Commoditiser)
- func (acc *Account) Credits() []api.Commoditiser
- func (acc *Account) Debit(obj interface{}) (balance api.Commoditiser)
- func (acc *Account) Debits() []api.Commoditiser
- func (acc *Account) Directive() string
- func (acc *Account) Firstpass(db *Datastore, trans *Transaction, p *Posting) error
- func (acc *Account) FmtBalances(db api.Datastorer, trans api.Transactor, p api.Poster, _ api.Accounter) [][]string
- func (acc *Account) FmtDCBalances(db api.Datastorer, trans api.Transactor, p api.Poster, _ api.Accounter) [][]string
- func (acc *Account) FmtEquity(db api.Datastorer, trans api.Transactor, p api.Poster, _ api.Accounter) [][]string
- func (acc *Account) FmtPassbook(db api.Datastorer, trans api.Transactor, p api.Poster, _ api.Accounter) [][]string
- func (acc *Account) FmtRegister(db api.Datastorer, trans api.Transactor, p api.Poster, _ api.Accounter) [][]string
- func (acc *Account) HasPosting() bool
- func (acc *Account) IsExpense() bool
- func (acc *Account) IsIncome() bool
- func (acc *Account) Name() string
- func (acc *Account) Notes() []string
- func (acc *Account) Secondpass(db *Datastore, trans *Transaction, p *Posting) error
- func (acc *Account) String() string
- func (acc *Account) Yledger(db *Datastore) parsec.Parser
- func (acc *Account) Ypostaccn(db *Datastore) parsec.Parser
- type Comment
- type Commodity
- func (comm *Commodity) Amount() float64
- func (comm *Commodity) ApplyAmount(other api.Commoditiser) error
- func (comm *Commodity) BalanceEqual(other api.Commoditiser) (bool, error)
- func (comm *Commodity) Clone(ndb api.Datastorer) api.Commoditiser
- func (comm *Commodity) Currency() bool
- func (comm *Commodity) Directive() string
- func (comm *Commodity) Firstpass(db *Datastore, trans *Transaction, p *Posting) error
- func (comm *Commodity) IsCredit() bool
- func (comm *Commodity) IsDebit() bool
- func (comm *Commodity) MakeSimilar(amount float64) api.Commoditiser
- func (comm *Commodity) Name() string
- func (comm *Commodity) Notes() []string
- func (comm *Commodity) Secondpass(db *Datastore, trans *Transaction, p *Posting) error
- func (comm *Commodity) String() string
- func (comm *Commodity) Ybalprice(db *Datastore) parsec.Parser
- func (comm *Commodity) Ycommodityname(db *Datastore) parsec.Parser
- func (comm *Commodity) Ycostprice(db *Datastore) parsec.Parser
- func (comm *Commodity) Ycurrencyname(db *Datastore) parsec.Parser
- func (comm *Commodity) Yledger(db *Datastore) parsec.Parser
- func (comm *Commodity) Ylotprice(db *Datastore) parsec.Parser
- func (comm *Commodity) Yname(db *Datastore) parsec.Parser
- type DB
- type Datastore
- func (db *Datastore) Accountnames() []string
- func (db *Datastore) Addjournal(journalfile string, data []byte)
- func (db *Datastore) AggregateTotal(trans api.Transactor, p api.Poster) error
- func (db *Datastore) Applytill(till time.Time)
- func (db *Datastore) Balance(obj interface{}) (balance api.Commoditiser)
- func (db *Datastore) Balances() []api.Commoditiser
- func (db *Datastore) Clone(nreporter api.Reporter) api.Datastorer
- func (db *Datastore) Commoditynames() []string
- func (db *Datastore) Credit(obj interface{}) (balance api.Commoditiser)
- func (db *Datastore) Credits() []api.Commoditiser
- func (db *Datastore) CurrentJournal() string
- func (db *Datastore) Debit(obj interface{}) (balance api.Commoditiser)
- func (db *Datastore) Debits() []api.Commoditiser
- func (db *Datastore) Firstpass(obj interface{}) (err error)
- func (db *Datastore) Firstpassok()
- func (db *Datastore) FmtBalances(_ api.Datastorer, trans api.Transactor, p api.Poster, acc api.Accounter) [][]string
- func (db *Datastore) FmtDCBalances(_ api.Datastorer, trans api.Transactor, p api.Poster, acc api.Accounter) [][]string
- func (db *Datastore) FmtEquity(_ api.Datastorer, trans api.Transactor, _ api.Poster, _ api.Accounter) [][]string
- func (db *Datastore) FmtPassbook(_ api.Datastorer, trans api.Transactor, _ api.Poster, _ api.Accounter) [][]string
- func (db *Datastore) FmtRegister(_ api.Datastorer, trans api.Transactor, p api.Poster, acc api.Accounter) [][]string
- func (db *Datastore) GetAccount(name string) api.Accounter
- func (db *Datastore) GetCommodity(name string) api.Commoditiser
- func (db *Datastore) Hasjournal(data []byte) bool
- func (db *Datastore) IsAccountDeclared(name string) bool
- func (db *Datastore) IsCommodityDeclared(name string) bool
- func (db *Datastore) IsPayeeDeclared(name string) bool
- func (db *Datastore) PrintAccounts()
- func (db *Datastore) Secondpass() error
- func (db *Datastore) Secondpassok()
- type Directive
- func (d *Directive) Firstpass(db *Datastore) error
- func (d *Directive) Includefile() string
- func (d *Directive) Secondpass(db *Datastore) error
- func (d *Directive) Type() string
- func (d *Directive) Yledger(db *Datastore) parsec.Parser
- func (d *Directive) Yledgerblock(db *Datastore, block []string) (int, error)
- type DoubleEntry
- func (de *DoubleEntry) AddBalance(commodity api.Commoditiser) error
- func (de *DoubleEntry) Balance(obj interface{}) (comm api.Commoditiser)
- func (de *DoubleEntry) Balances() []api.Commoditiser
- func (de *DoubleEntry) Clone() *DoubleEntry
- func (de *DoubleEntry) Credit(obj interface{}) (comm api.Commoditiser)
- func (de *DoubleEntry) Credits() []api.Commoditiser
- func (de *DoubleEntry) Debit(obj interface{}) (comm api.Commoditiser)
- func (de *DoubleEntry) Debits() []api.Commoditiser
- func (de *DoubleEntry) IsBalanced() bool
- type KV
- type ParsePhase
- type Payee
- type Posting
- func (p *Posting) Account() api.Accounter
- func (p *Posting) Balanceprice() api.Commoditiser
- func (p *Posting) Clone(ndb *Datastore, ntrans *Transaction) *Posting
- func (p *Posting) Commodity() api.Commoditiser
- func (p *Posting) Costprice() api.Commoditiser
- func (p *Posting) Firstpass(db *Datastore, trans *Transaction) error
- func (p *Posting) FmtBalances(db api.Datastorer, trans api.Transactor, _ api.Poster, _ api.Accounter) [][]string
- func (p *Posting) FmtEquity(db api.Datastorer, trans api.Transactor, _ api.Poster, _ api.Accounter) [][]string
- func (p *Posting) FmtPassbook(db api.Datastorer, trans api.Transactor, _ api.Poster, _ api.Accounter) [][]string
- func (p *Posting) FmtRegister(db api.Datastorer, trans api.Transactor, _ api.Poster, _ api.Accounter) [][]string
- func (p *Posting) IsCredit() bool
- func (p *Posting) IsDebit() bool
- func (p *Posting) Lotprice() api.Commoditiser
- func (p *Posting) Payee() string
- func (p *Posting) Secondpass(db *Datastore, trans *Transaction) error
- func (p *Posting) Yledger(db *Datastore) parsec.Parser
- type Price
- type Tags
- type Transaction
- func (trans *Transaction) Addlines(lines ...string)
- func (trans *Transaction) Clone(ndb *Datastore) *Transaction
- func (trans *Transaction) Crc64() uint64
- func (trans *Transaction) Date() time.Time
- func (trans *Transaction) Firstpass(db *Datastore) error
- func (trans *Transaction) GetPostings() []api.Poster
- func (trans *Transaction) Journalfile() string
- func (trans *Transaction) Lineno() int
- func (trans *Transaction) Payee() string
- func (trans *Transaction) Printlines() []string
- func (trans *Transaction) Secondpass(db *Datastore) error
- func (trans *Transaction) SetLineno(lineno int)
- func (trans *Transaction) Yledger(db *Datastore) parsec.Parser
- func (trans *Transaction) Yledgerblock(db *Datastore, block []string) (int, error)
Constants ¶
const ( // PostUncleared notion for a posting. PostUncleared = "uncleared" // PostCleared notion for a posting. PostCleared = "cleared" // PostPending notion for a posting. PostPending = "pending" )
Variables ¶
This section is empty.
Functions ¶
func AccountLcp ¶
AccountLcp return longest common prefix for account names.
func FitAccountname ¶
FitAccountname for formatting.
func Vector2scalar ¶
func Vector2scalar(nodes []parsec.ParsecNode) parsec.ParsecNode
Vector2scalar convert vector of arity ONE to scalar.
Types ¶
type Account ¶
type Account struct {
// contains filtered or unexported fields
}
Account implements api.Accounter{} interface.
func NewAccount ¶
NewAccount create a new instance of Account{}.
func (*Account) Balance ¶
func (acc *Account) Balance(obj interface{}) (balance api.Commoditiser)
func (*Account) Balances ¶
func (acc *Account) Balances() []api.Commoditiser
func (*Account) Credit ¶
func (acc *Account) Credit(obj interface{}) (balance api.Commoditiser)
func (*Account) Credits ¶
func (acc *Account) Credits() []api.Commoditiser
func (*Account) Debit ¶
func (acc *Account) Debit(obj interface{}) (balance api.Commoditiser)
func (*Account) Debits ¶
func (acc *Account) Debits() []api.Commoditiser
func (*Account) Firstpass ¶
func (acc *Account) Firstpass( db *Datastore, trans *Transaction, p *Posting) error
func (*Account) FmtBalances ¶
func (acc *Account) FmtBalances( db api.Datastorer, trans api.Transactor, p api.Poster, _ api.Accounter) [][]string
func (*Account) FmtDCBalances ¶
func (acc *Account) FmtDCBalances( db api.Datastorer, trans api.Transactor, p api.Poster, _ api.Accounter) [][]string
func (*Account) FmtEquity ¶
func (acc *Account) FmtEquity( db api.Datastorer, trans api.Transactor, p api.Poster, _ api.Accounter) [][]string
func (*Account) FmtPassbook ¶
func (acc *Account) FmtPassbook( db api.Datastorer, trans api.Transactor, p api.Poster, _ api.Accounter) [][]string
func (*Account) FmtRegister ¶
func (acc *Account) FmtRegister( db api.Datastorer, trans api.Transactor, p api.Poster, _ api.Accounter) [][]string
func (*Account) HasPosting ¶
func (*Account) Secondpass ¶
func (acc *Account) Secondpass( db *Datastore, trans *Transaction, p *Posting) error
type Comment ¶
type Comment struct {
// contains filtered or unexported fields
}
Comment type
func (*Comment) Secondpass ¶
type Commodity ¶
type Commodity struct {
// contains filtered or unexported fields
}
Commodity that can be exchanged between accounts.
func NewCommodity ¶
NewCommodity return an new commodity instance.
func (*Commodity) ApplyAmount ¶
func (comm *Commodity) ApplyAmount(other api.Commoditiser) error
func (*Commodity) BalanceEqual ¶
func (comm *Commodity) BalanceEqual(other api.Commoditiser) (bool, error)
func (*Commodity) Clone ¶
func (comm *Commodity) Clone(ndb api.Datastorer) api.Commoditiser
func (*Commodity) Firstpass ¶
func (comm *Commodity) Firstpass( db *Datastore, trans *Transaction, p *Posting) error
func (*Commodity) MakeSimilar ¶
func (comm *Commodity) MakeSimilar(amount float64) api.Commoditiser
func (*Commodity) Secondpass ¶
func (comm *Commodity) Secondpass( db *Datastore, trans *Transaction, p *Posting) error
func (*Commodity) Ybalprice ¶
Ybalprice return a parser-combinator that can parse a commodity in balance-price format, like: =<comm>
func (*Commodity) Ycommodityname ¶
Ycommodityname parse commodity, non-currency name, as simple token or as double-quoted token.
func (*Commodity) Ycostprice ¶
Ycostprice return a parser-combinator that can parse a commodity in costprice format, like: @ <comm>
func (*Commodity) Ycurrencyname ¶
Ycurrencyname parse commodity as currency as simple token or as double-quoted token.
func (*Commodity) Yledger ¶
Yledger return a parser-combinator that can parse a commodity amount/name.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB impelements array based sorted key-value entries.
type Datastore ¶
type Datastore struct {
// contains filtered or unexported fields
}
Datastore managing accounts, commodities, transactions and posting and every thing else that are related.
func NewDatastore ¶
NewDatastore return a new datastore.
func (*Datastore) Accountnames ¶
func (*Datastore) Addjournal ¶
func (*Datastore) AggregateTotal ¶
func (*Datastore) Balance ¶
func (db *Datastore) Balance(obj interface{}) (balance api.Commoditiser)
func (*Datastore) Balances ¶
func (db *Datastore) Balances() []api.Commoditiser
func (*Datastore) Commoditynames ¶
func (*Datastore) Credit ¶
func (db *Datastore) Credit(obj interface{}) (balance api.Commoditiser)
func (*Datastore) Credits ¶
func (db *Datastore) Credits() []api.Commoditiser
func (*Datastore) CurrentJournal ¶
func (*Datastore) Debit ¶
func (db *Datastore) Debit(obj interface{}) (balance api.Commoditiser)
func (*Datastore) Debits ¶
func (db *Datastore) Debits() []api.Commoditiser
func (*Datastore) FmtBalances ¶
func (db *Datastore) FmtBalances( _ api.Datastorer, trans api.Transactor, p api.Poster, acc api.Accounter) [][]string
func (*Datastore) FmtDCBalances ¶
func (db *Datastore) FmtDCBalances( _ api.Datastorer, trans api.Transactor, p api.Poster, acc api.Accounter) [][]string
func (*Datastore) FmtEquity ¶
func (db *Datastore) FmtEquity( _ api.Datastorer, trans api.Transactor, _ api.Poster, _ api.Accounter) [][]string
func (*Datastore) FmtPassbook ¶
func (db *Datastore) FmtPassbook( _ api.Datastorer, trans api.Transactor, _ api.Poster, _ api.Accounter) [][]string
func (*Datastore) FmtRegister ¶
func (db *Datastore) FmtRegister( _ api.Datastorer, trans api.Transactor, p api.Poster, acc api.Accounter) [][]string
func (*Datastore) GetCommodity ¶
func (db *Datastore) GetCommodity(name string) api.Commoditiser
func (*Datastore) Hasjournal ¶
func (*Datastore) IsAccountDeclared ¶
func (*Datastore) IsCommodityDeclared ¶
func (*Datastore) IsPayeeDeclared ¶
func (*Datastore) PrintAccounts ¶
func (db *Datastore) PrintAccounts()
PrintAccounts is a debug api for application.
func (*Datastore) Secondpass ¶
func (*Datastore) Secondpassok ¶
func (db *Datastore) Secondpassok()
Secondpassok to track parsephase
type Directive ¶
type Directive struct {
// contains filtered or unexported fields
}
Directive can handle all directives in ledger journal.
func NewDirective ¶
func NewDirective() *Directive
NewDirective create a new Directive instance, one instance to be created for handling each directive in the journal file.
func (*Directive) Includefile ¶
func (*Directive) Secondpass ¶
type DoubleEntry ¶
type DoubleEntry struct {
// contains filtered or unexported fields
}
func NewDoubleEntry ¶
func NewDoubleEntry(name string) *DoubleEntry
func (*DoubleEntry) AddBalance ¶
func (de *DoubleEntry) AddBalance(commodity api.Commoditiser) error
func (*DoubleEntry) Balance ¶
func (de *DoubleEntry) Balance(obj interface{}) (comm api.Commoditiser)
func (*DoubleEntry) Balances ¶
func (de *DoubleEntry) Balances() []api.Commoditiser
func (*DoubleEntry) Clone ¶
func (de *DoubleEntry) Clone() *DoubleEntry
func (*DoubleEntry) Credit ¶
func (de *DoubleEntry) Credit(obj interface{}) (comm api.Commoditiser)
func (*DoubleEntry) Credits ¶
func (de *DoubleEntry) Credits() []api.Commoditiser
func (*DoubleEntry) Debit ¶
func (de *DoubleEntry) Debit(obj interface{}) (comm api.Commoditiser)
func (*DoubleEntry) Debits ¶
func (de *DoubleEntry) Debits() []api.Commoditiser
func (*DoubleEntry) IsBalanced ¶
func (de *DoubleEntry) IsBalanced() bool
type ParsePhase ¶
type ParsePhase int
ParsePhase state to be tracked at datastore.
const ( // DBSTART is parsing started. DBSTART ParsePhase = iota + 1 // DBFIRSTPASS is all Firstpass() calls are completed. DBFIRSTPASS // DBSECONDPASS is all Secondpass() calls are completed. DBSECONDPASS )
type Posting ¶
type Posting struct {
// contains filtered or unexported fields
}
Posting instance for every single posting within a transaction.
func NewPosting ¶
func NewPosting(trans *Transaction) *Posting
NewPosting create a new posting instance.
func (*Posting) Balanceprice ¶
func (p *Posting) Balanceprice() api.Commoditiser
func (*Posting) Commodity ¶
func (p *Posting) Commodity() api.Commoditiser
func (*Posting) Costprice ¶
func (p *Posting) Costprice() api.Commoditiser
func (*Posting) FmtBalances ¶
func (p *Posting) FmtBalances( db api.Datastorer, trans api.Transactor, _ api.Poster, _ api.Accounter) [][]string
func (*Posting) FmtEquity ¶
func (p *Posting) FmtEquity( db api.Datastorer, trans api.Transactor, _ api.Poster, _ api.Accounter) [][]string
func (*Posting) FmtPassbook ¶
func (p *Posting) FmtPassbook( db api.Datastorer, trans api.Transactor, _ api.Poster, _ api.Accounter) [][]string
func (*Posting) FmtRegister ¶
func (p *Posting) FmtRegister( db api.Datastorer, trans api.Transactor, _ api.Poster, _ api.Accounter) [][]string
func (*Posting) Lotprice ¶
func (p *Posting) Lotprice() api.Commoditiser
func (*Posting) Secondpass ¶
func (p *Posting) Secondpass(db *Datastore, trans *Transaction) error
type Price ¶
type Price struct {
// contains filtered or unexported fields
}
Price equivalence between commodities, TBD...
func (*Price) Secondpass ¶
type Tags ¶
type Tags struct {
// contains filtered or unexported fields
}
Tags from journal within a posting and/or a transactions.
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction instance for every transaction in the journal file.
func NewTransaction ¶
func NewTransaction(journalfile string) *Transaction
NewTransaction create a new transaction object.
func (*Transaction) Addlines ¶
func (trans *Transaction) Addlines(lines ...string)
func (*Transaction) Clone ¶
func (trans *Transaction) Clone(ndb *Datastore) *Transaction
func (*Transaction) Crc64 ¶
func (trans *Transaction) Crc64() uint64
func (*Transaction) Date ¶
func (trans *Transaction) Date() time.Time
func (*Transaction) Firstpass ¶
func (trans *Transaction) Firstpass(db *Datastore) error
func (*Transaction) GetPostings ¶
func (trans *Transaction) GetPostings() []api.Poster
func (*Transaction) Journalfile ¶
func (trans *Transaction) Journalfile() string
func (*Transaction) Lineno ¶
func (trans *Transaction) Lineno() int
Lineno get lineno in journal file for this transaction.
func (*Transaction) Payee ¶
func (trans *Transaction) Payee() string
func (*Transaction) Printlines ¶
func (trans *Transaction) Printlines() []string
func (*Transaction) Secondpass ¶
func (trans *Transaction) Secondpass(db *Datastore) error
func (*Transaction) SetLineno ¶
func (trans *Transaction) SetLineno(lineno int)
SetLineno in journal file for this transaction.
func (*Transaction) Yledger ¶
func (trans *Transaction) Yledger(db *Datastore) parsec.Parser
Yledger return a parser-combinator that can parse first line of a transaction.
func (*Transaction) Yledgerblock ¶
func (trans *Transaction) Yledgerblock( db *Datastore, block []string) (int, error)
Yledgerblock return a parser combinaty that can parse all the posting within the transaction.