Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- func (client *Client) AddAttachment(id string, path string) error
- func (client *Client) AddTransaction(tr ledger.Transaction) error
- func (client *Client) AddTransactionEdit(tr ledger.Transaction) error
- func (client *Client) GetAccountList() []string
- func (client *Client) GetBalances(dfilter int) ([][]string, error)
- func (client *Client) GetTransactionWithHistory(id string) []ledger.Transaction
- func (client *Client) GetTransactions(dfilter int, sfilter int, tfilter map[string]bool) []ledger.Transaction
- type Event
Constants ¶
const ( FilterAllDates = iota - 1 FilterThisMonth FilterLastMonth FilterThisYear FilterLastYear )
Filter enum for dates.
const ( FilterAllStatus = iota - 1 FilterClearStatus FilterPendingStatus )
Filter enum for states.
const (
EvntTypTrUpdate = iota // The transaction list has changed, refresh.
)
Variables ¶
var MissingIDError = errors.New("Transaction missing ID.")
Returned by GetClient if, during loading, a transaction is found that does not have an ID. Since all transactions written by this system are given IDs this means a corrupted or badly manually edited file. Go fix your mistake and try again. Also used by AddTransactionEdit.
var MissingParentError = errors.New("Transaction edit does not have a parent.")
Returned by AddTransactionEdit if there is not a parent transaction for the edit.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // Events are sent on this channel. Events chan *Event // contains filtered or unexported fields }
Client does all the work of keeping a clear consistent view of the underlying transaction log for the UI. This handles loading and updating the log file, parsing and sorting all the data, and doing all the other calculating/transforming that may be needed.
func NewClient ¶
NewClient returns a client object or an error if the client was not able to initialize. Do not make multiple Clients! Each Client has associated, non-releasable resources!
func (*Client) AddAttachment ¶
AddAttachment adds a attachments to a transaction, specified by an id.
func (*Client) AddTransaction ¶
func (client *Client) AddTransaction(tr ledger.Transaction) error
AddTransaction writes a transaction to the log and adds it to the internal lists. The transaction object passed in will be modified to have an ID in the "ID" KV pair.
func (*Client) AddTransactionEdit ¶
func (client *Client) AddTransactionEdit(tr ledger.Transaction) error
AddTransactionEdit does the same basic thing as AddTransaction, except it ensures that the transaction being added replaces an existing one.
func (*Client) GetAccountList ¶
GetAccountList returns a sorted list of accounts.
func (*Client) GetBalances ¶
GetBalances returns a ready to display balance overview for all accounts with transactions that fit the filter. Each element in the slice is a display row consisting of two items, the name of the row with pre-applied indentation as needed and the pre-formatted value for the row.
func (*Client) GetTransactionWithHistory ¶
func (client *Client) GetTransactionWithHistory(id string) []ledger.Transaction
GetTransactionWithHistory returns all existing versions of a transaction in source order. The last transaction in the list is the one currently in effect. In case of a non-existent ID, nil is returned.
func (*Client) GetTransactions ¶
func (client *Client) GetTransactions(dfilter int, sfilter int, tfilter map[string]bool) []ledger.Transaction
GetTransactions returns the simplified transaction list (all edits resolved, etc), sorted by date and then source order. This list is further filtered by a time period, status, and tags.