client

package
v0.0.0-...-8da493b Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FilterAllDates = iota - 1
	FilterThisMonth
	FilterLastMonth
	FilterThisYear
	FilterLastYear
)

Filter enum for dates.

View Source
const (
	FilterAllStatus = iota - 1
	FilterClearStatus
	FilterPendingStatus
)

Filter enum for states.

View Source
const (
	EvntTypTrUpdate = iota // The transaction list has changed, refresh.
)

Variables

View Source
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.

View Source
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

func NewClient() (*Client, error)

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

func (client *Client) AddAttachment(id string, path string) error

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

func (client *Client) GetAccountList() []string

GetAccountList returns a sorted list of accounts.

func (*Client) GetBalances

func (client *Client) GetBalances(dfilter int) ([][]string, error)

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.

type Event

type Event struct {
	Typ int
}

Jump to

Keyboard shortcuts

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