Documentation
¶
Index ¶
- func ActionStockUnits(ledgerName string, stockTransaction StockTransaction) error
- func AddAccount(ledger string, account Account) error
- func AddCategory(ledger string, category Category) error
- func AddLedger()
- func AddStock(ledger string, stock Stock) error
- func AddTransaction(ledgerName string, transaction Transaction) error
- func DeleteTransaction(ledgerName string, transactionID int) error
- func FormatAccounts(accounts []*Account, prefix string) []string
- func FormatCategories(categories []*Category, prefix string) []string
- func GetAccountBalance(accounts []*Account, accountName string) float64
- func GetAccountID(accountName string, accounts []*Account) int
- func GetAccountType(accountName string, accounts []*Account) string
- func GetCategoryID(categoryName string, categories []*Category) int
- func GetCategoryType(categoryName string, categories []*Category) string
- func GetChildAccountIDs(accountID int, accounts []*Account) []int
- func GetChildCategoryIDs(categoryID int, categories []*Category) []int
- func GetCurrencyForLedger(ledgerName string) string
- func GetLedgersList() ([]string, error)
- func GetStockCodesList(stocks []*Stock) []string
- func GetStockID(stockName string, stocks []*Stock) int
- func GetStockNamesList(stocks []*Stock) []string
- func GetStockType(stockName string, stocks []*Stock) string
- func GetTransactionNotesForKeywords(ledgerName string, keywords string, filterTransferTn bool) ([]string, error)
- func GoldStocksFound(stocks []*Stock) bool
- func IsPlaceHolderAccount(accountName string, accounts []*Account) bool
- func IsPlaceHolderCategory(categoryID int, categories []*Category) bool
- func IsValidLedger(ledgerName string) bool
- func ToggleStockStatus(ledgerName string, stockID int, currStatus string) error
- func TransferFunds(fromLedger string, toLedger string, transactions []Transaction) error
- func UpdateGoldPrice(ledgerName string) error
- func UpdateNAVs(ledgerName string, stockCodesList []string) error
- type Account
- type Category
- type InvestmentStatus
- type Ledger
- type SplitTransaction
- type StatsData
- type Stock
- type StockTransaction
- type Transaction
- func GetTransaction(ledgerName string, transactionID int) (Transaction, error)
- func GetTransactionsForAccount(ledgerName string, accountName string, limit int) ([]Transaction, error)
- func GetTransactionsForCategory(ledgerName string, category string, limit int) ([]Transaction, error)
- func GetTransactionsForKeywords(ledgerName string, keywords string) ([]Transaction, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActionStockUnits ¶ added in v0.10.0
func ActionStockUnits(ledgerName string, stockTransaction StockTransaction) error
ActionStockUnits adds stock purchase/redeem related transactions to the database
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 DeleteTransaction ¶ added in v0.5.0
DeleteTransaction deletes a transaction from the database and updates the account balance
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 GetAccountBalance ¶ added in v0.13.0
getAccountBalance calculates the total balance for a given account accumulates balances from all child accounts if its a placeholder account
func GetAccountID ¶ added in v0.7.0
GetAccountID returns the account id of the given account
func GetAccountType ¶ added in v0.9.0
GetAccountType returns the account type of the given account
func GetCategoryID ¶ added in v0.7.0
GetCategoryID returns the category id of the given category name
func GetCategoryType ¶ added in v0.9.0
GetCategoryType returns the category type of the given category name
func GetChildAccountIDs ¶ added in v0.3.0
GetChildAccountIDs returns a slice of IDs of all the child accounts for the given account
func GetChildCategoryIDs ¶
GetChildCategoryIDs returns a slice of IDs of all the child categories for the given category
func GetCurrencyForLedger ¶
func GetLedgersList ¶
func GetStockCodesList ¶ added in v0.10.0
GetStockCodesList returns a slice of string with stock codes
func GetStockID ¶ added in v0.10.0
GetStockID returns the stock id of the given stock
func GetStockNamesList ¶ added in v0.10.0
GetStockNamesList returns a slice of string with stock names
func GetStockType ¶ added in v0.10.0
GetStockType returns the stock type of the given stock
func GetTransactionNotesForKeywords ¶ added in v0.15.0
func GetTransactionNotesForKeywords(ledgerName string, keywords string, filterTransferTn bool) ([]string, error)
GetTransactionNotesForKeywords fetches transaction notes matching the keywords and returns them as a slice of string
func GoldStocksFound ¶ added in v0.10.2
func IsPlaceHolderAccount ¶ added in v0.9.0
IsPlaceHolderAccount returns true if the given account is a placeholder account, false otherwise
func IsPlaceHolderCategory ¶ added in v0.7.1
IsPlaceHolderCategory returns true if the given category is a placeholder category, false otherwise
func IsValidLedger ¶
func ToggleStockStatus ¶ added in v0.10.0
func TransferFunds ¶
func TransferFunds(fromLedger string, toLedger string, transactions []Transaction) error
TransferFunds adds transfer transactions contained in a slice of Transaction struct to database
func UpdateGoldPrice ¶ added in v0.10.2
func UpdateNAVs ¶ added in v0.10.0
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.
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.
type InvestmentStatus ¶ added in v0.12.0
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 ¶
A StatsData represents a period and an amount of money
func FetchCategoryStatsData ¶
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 Stock ¶ added in v0.10.0
type Stock struct { ID int Name string Type string Code string Plan string Status string Units float64 Invested float64 }
A stock is a representation of a record from the stocks table
type StockTransaction ¶ added in v0.10.0
type StockTransaction struct { TransactionType string StockID int StockName string Date time.Time Units float64 Amount float64 BankAccountID int BankName *string }
func GetTransactionsForStock ¶ added in v0.10.0
func GetTransactionsForStock(ledgerName string, stockID int) ([]StockTransaction, error)
GetTransactionsForStock fetches transactions for the given stock from the database and returns them as a slice of StockTransaction struct
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 GetTransaction ¶ added in v0.5.0
func GetTransaction(ledgerName string, transactionID int) (Transaction, error)
GetTransaction returns a transaction matching given transaction id in a Transaction struct
func GetTransactionsForAccount ¶
func GetTransactionsForAccount(ledgerName string, accountName 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 GetTransactionsForKeywords ¶ added in v0.4.0
func GetTransactionsForKeywords(ledgerName string, keywords string) ([]Transaction, error)
GetTransactionsForKeywords fetches transactions matching the keywords and returns them as a slice of Transaction struct