Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ScanXML ¶
func ScanXML(r io.Reader, opts ...ScanOption) error
ScanXML reads a GnuCash XML document from r. Options can be passed to configure its behavior.
func ScanXMLFile ¶
func ScanXMLFile(p string, opts ...ScanOption) error
ScanXMLFile is a wrapper around ScanXML that reads a file at p. If the file is gzip-compressed, it is automatically decompressed.
Types ¶
type Account ¶
type Account struct { // ID is a GUID identifying this account. ID string // Name is a short name describing this account, e.g. "Credit Card" or "Parking". Name string // Desc is a longer description of the account. Desc string // Type describes how this account is used. Type AccountType // Commodity is the ID of the commodity held in this account, e.g. "USD". Commodity string // SCU is the "smallest commodity unit". // // https://code.gnucash.org/docs/STABLE/Account_8h.html: "The SCU [signifies] the smallest // non-zero amount that can be stored in the account. It is represented as the integer // denominator of a fraction. Thus, for example, a SCU of 12 means that 1/12 of something is the // smallest amount that can be stored in the account. SCU's can be any value; they do not need // to be decimal." // // For USD, this is 100, indicating that there are 100 cents in a dollar. SCU int // Parent points to this account's parent account. The root account's parent is nil. Parent *Account // contains filtered or unexported fields }
type AccountFilter ¶
type AccountFilter struct { // Only contains names of accounts to consider for inclusion (along with their children); // all unmatched accounts will be automatically excluded. If Only is empty, all accounts // will be considered for inclusion. Only []string // Exclude contains names of accounts to exclude (along with their children). Exclude []string // Collapse contains names of accounts whose children should be collapsed into the named account. Collapse []string }
AccountFilter describes how accounts should be filtered.
type AccountType ¶
type AccountType int
AccountType describes how an account is used.
This is based on the GNCAccountType enum described at https://code.gnucash.org/docs/STABLE/group__Account.html.
const ( AccountAsset AccountType = iota AccountBank AccountCash AccountCredit AccountCurrency AccountEquity AccountExpense AccountIncome AccountLiability AccountMutual AccountPayable AccountReceivable AccountRoot AccountStock AccountTrading )
type Amount ¶
type Amount struct { // Num is the number of SCUs present in this amount. // For USD (with an SCU of 100), Num is 1000 for a $10.00 amount. Num int // SCU is the "smallest currency unit". For USD, it is 100. SCU int }
Amount describes a monetary amount in a specific currency.
func (Amount) MarshalJSON ¶
type Date ¶
Date contains a possibly-partial date, with unset fields set to 0.
func (Date) ToYearMonth ¶
type ScanOption ¶
type ScanOption func(*scanConfig)
ScanOption can be passed to ScanXML to configure its behavior.
func ScanAccountFilter ¶
func ScanAccountFilter(f AccountFilter) ScanOption
ScanAccountFilter filters accounts and transaction splits as described by f. If a transaction has no remaining splits after filtering, it will be excluded.
func ScanAccountFunc ¶
func ScanAccountFunc(f func(*Account) error) ScanOption
ScanAccountFunc adds a function that will be called for each account. If the function returns a non-nil error, scanning will be aborted.
func ScanMaxTransactionDate ¶
func ScanMaxTransactionDate(d Date) ScanOption
ScanMaxTransactionDate excludes transactions whose date comes after d.
func ScanMinTransactionDate ¶
func ScanMinTransactionDate(d Date) ScanOption
ScanMinTransactionDate excludes transactions whose date precedes d.
func ScanTransactionFunc ¶
func ScanTransactionFunc(f func(*Transaction) error) ScanOption
ScanTransactionFunc adds a function that will be called for each transaction. If the function returns a non-nil error, scanning will be aborted. Note that transactions will be passed in the event that they're read from the file, which probably won't match the order in which they were posted.
type Split ¶
type Split struct { // ID is a GUID identifying this split. ID string // Value is the split's value in the transaction's currency. Value Amount // Quantity is the split's value in Account's currency. Quantity Amount // Account is the account to/from which Quantity was moved. Account *Account }
Split describes a source or recipient of value in a transaction.
type Transaction ¶
type Transaction struct { // ID is a GUID identifying this transaction. ID string // Date is the date on which the transaction was posted. Date Date // Desc describes the transaction. Desc string // Currency is the ID of the commodity in which this transaction took place, e.g. "USD". Currency string // Splits describes where the value came from and went to. Splits []Split }
Transaction describes value being moved between two or more accounts.
func (Transaction) String ¶
func (t Transaction) String() string
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
dump-transactions
Package main implements a command-line program for dumping GnuCash transactions.
|
Package main implements a command-line program for dumping GnuCash transactions. |