Documentation ¶
Index ¶
- func AddAccount(ledger string, account Account) error
- func AddCategory(ledger string, category Category) error
- func AddLedger()
- func AddTransaction(ledgerName string, transaction Transaction) error
- func FormatAccounts(accounts []*Account, prefix string) []string
- func FormatCategories(categories []*Category, prefix string) []string
- func GetChildCategoryIDs(categoryID int, categories []*Category) []int
- func GetCurrencyForLedger(ledgerName string) string
- func GetLedgersList() ([]string, error)
- func IsPlaceholderAccount(accounts []*Account, accountName string) bool
- func IsValidLedger(ledgerName string) bool
- func TransferFunds(fromLedger string, toLedger string, transactions []Transaction) error
- type Account
- type Category
- type Ledger
- type SplitTransaction
- type StatsData
- type Transaction
- func GetTransactionsForAccount(ledgerName string, account string, limit int) ([]Transaction, error)
- func GetTransactionsForCategory(ledgerName string, category string, limit int) ([]Transaction, error)
- func PromptForNewTransaction(ledgerName string, transactionType string) Transaction
- func PromptForNewTransfer(ledgerName string) (string, []Transaction)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddAccount ¶
AddAccount adds the given account to the database
func AddCategory ¶
AddCategory adds the given category to the database
func AddTransaction ¶
func AddTransaction(ledgerName string, transaction Transaction) error
AddTransaction adds a transaction to the database
func FormatAccounts ¶
FormatAccounts takes a slice of Account struct and returns a slice of string with account names prefixed with appropriate spaces to give it a nested list look
func FormatCategories ¶
FormatCategories takes a slice of Category struct and returns a slice of string with category names prefixed with appropriate spaces to give it a nested list look
func GetChildCategoryIDs ¶ added in v0.1.1
GetChildCategoryIDs returns a slice of IDs of all the child categories for the given category
func GetCurrencyForLedger ¶
func GetLedgersList ¶
func IsPlaceholderAccount ¶
IsPlaceholderAccount returns true if the given account is a placeholder account, false otherwise
func IsValidLedger ¶
func TransferFunds ¶
func TransferFunds(fromLedger string, toLedger string, transactions []Transaction) error
TransferFunds adds transfer transactions contained in a slice of Transaction struct to database
Types ¶
type Account ¶
type Account struct { ID int Name string Type string OpeningBalance float64 Balance float64 Placeholder int ParentID int Children []*Account }
An Account is a representation of a record from the accounts table
func FetchAccounts ¶
FetchAccounts fetches account records for the given ledger from the database and returns a slice of Account struct.
If placeholder is true, only records where placeholder is set to 1 is fetched.
If accountType is set to either asset or liability, only those records are fetched.
func PromptForNewAccount ¶
PromptForNewAccount gathers new account details from the user and returns an Account struct which can then be added to the database
type Category ¶
type Category struct { ID int Name string Type string Placeholder int ParentID int Children []*Category }
A Category is a representation of a record from the categories table
func FetchCategories ¶
FetchCategories fetches category records for the given ledger from the database and returns a slice of Category struct.
If placeholder is true, only records where placeholder is set to 1 is fetched.
If categoryType is set to either income or expense, only those records are fetched.
func PromptForNewCategory ¶
PromptForNewCategory gathers new category details from the user and returns an Category struct which can then be added to the database
type Ledger ¶
func FetchLedgers ¶
type SplitTransaction ¶
type SplitTransaction struct { ID int Date time.Time Notes string Credit float64 Debit float64 AccountID int Account string CategoryID int Category *string CurrencySymbol string ParentID int }
A SplitTransaction is a representation of a record from the split_transactions table
func GetSplitsForTransaction ¶
func GetSplitsForTransaction(ledgerName string, transactionID int) ([]SplitTransaction, error)
GetSplitsForTransaction fetches all split transactions for a given transaction id and returns them as a slice of SplitTransaction
type StatsData ¶ added in v0.1.1
A StatsData represents a period and an amount of money
func FetchCategoryStatsData ¶ added in v0.1.1
func FetchCategoryStatsData(ledgerName string, category string, period string, count int) ([]*StatsData, error)
FetchCategoryStatsData returns a slice of StatsData struct for the given period for the given category for the given count.
Period can be either "monthly" or "yearly"
type Transaction ¶
type Transaction struct { ID int Date time.Time Notes string Credit float64 Debit float64 AccountID int Account string CategoryID int Category *string CurrencySymbol string IsSplit int Splits []SplitTransaction }
A Transaction is a representation of a record from the transactions table
func GetTransactionsForAccount ¶ added in v0.1.1
func GetTransactionsForAccount(ledgerName string, account string, limit int) ([]Transaction, error)
GetTransactionsForAccount fetches transactions for the given account from the database and returns them as a slice of Transaction struct
func GetTransactionsForCategory ¶
func GetTransactionsForCategory(ledgerName string, category string, limit int) ([]Transaction, error)
GetTransactionsForCategory fetches transactions for the given category from the database and returns them as a slice of Transaction struct
func PromptForNewTransaction ¶
func PromptForNewTransaction(ledgerName string, transactionType string) Transaction
PromptForNewTransaction gathers details of new transaction from user into A Transaction struct, which can then be added to the database.
transactionType is either income or expense
func PromptForNewTransfer ¶
func PromptForNewTransfer(ledgerName string) (string, []Transaction)
PromptForNewTransfer gathers details of a new transfer from user into a slice of Transaction struct, which can then be added to the database