Documentation
¶
Index ¶
- func DeleteTransaction(database *mongo.Database, id primitive.ObjectID) error
- func SetAccountValue(database *mongo.Database, account *Account, value float64, ...) error
- func UpdateTransaction(database *mongo.Database, transaction *Transaction, name string, ...) error
- func UpdateTransactionCategoryActive(database *mongo.Database, id primitive.ObjectID, active bool) error
- type Account
- type AccountType
- type AccountValue
- type CategoryType
- type Transaction
- func CreateTransaction(database *mongo.Database, name string, date primitive.DateTime, amount float64, ...) (Transaction, error)
- func GetTransaction(database *mongo.Database, id primitive.ObjectID) (Transaction, error)
- func GetTransactionList(database *mongo.Database, filter *TransactionFilter) []Transaction
- type TransactionCategory
- func CreateTransactionCategory(database *mongo.Database, name string, catType CategoryType) (TransactionCategory, error)
- func GetActiveTransactionCategories(database *mongo.Database) []TransactionCategory
- func GetAllTransactionCategories(database *mongo.Database) []TransactionCategory
- func GetInactiveTransactionCategories(database *mongo.Database) []TransactionCategory
- func GetTransactionCategory(database *mongo.Database, id primitive.ObjectID) (TransactionCategory, error)
- func GetTransactionCategoryList(database *mongo.Database, filter bson.M) []TransactionCategory
- type TransactionFilter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteTransaction ¶
Delete a Transaction by _id
func SetAccountValue ¶
func SetAccountValue( database *mongo.Database, account *Account, value float64, vTime primitive.DateTime, ) error
Set Account value and current value
func UpdateTransaction ¶
func UpdateTransaction( database *mongo.Database, transaction *Transaction, name string, date primitive.DateTime, amount float64, category TransactionCategory, ) error
Update transaction (replace)
Types ¶
type Account ¶
type Account struct { Name string `bson:"name" json:"name"` Type AccountType `bson:"type" json:"type"` ID primitive.ObjectID `bson:"_id,omitempty" json:"_id"` Active bool `bson:"active" json:"active"` IncludeNetWork bool `bson:"include_net_worth" json:"include_net_worth"` StartDate primitive.DateTime `bson:"start_date" json:"start_date"` EndDate *primitive.DateTime `bson:"end_date" json:"end_date"` CurrentValue *AccountValue `bson:"current_value,omitempty" json:"current_value"` Values []*AccountValue `bson:"values" json:"values"` }
func CreateAccount ¶
func CreateAccount( database *mongo.Database, name string, acctType AccountType, includeNetWorth bool, startDate primitive.DateTime, ) (Account, error)
This function will create a new Account
func GetAccount ¶
Get a single account
type AccountType ¶
type AccountType string
These are the valid Account types
const ( TYPE_ACCOUNT_DEBIT AccountType = "debit" TYPE_ACCOUNT_CREDIT AccountType = "credit" TYPE_ACCOUNT_INVESTMENT AccountType = "investment" )
type AccountValue ¶
type AccountValue struct { Value float64 `bson:"value" json:"value"` Date primitive.DateTime `bson:"date" json:"date"` }
The following structs represent an Account and the nested Account Value
type CategoryType ¶
type CategoryType string
These are the valid Category types
const ( TYPE_DEBIT CategoryType = "debit" TYPE_CREDIT CategoryType = "credit" TYPE_TRANSFER CategoryType = "transfer" )
type Transaction ¶
type Transaction struct { Name string `bson:"name" json:"name"` Category TransactionCategory `bson:"category" json:"category"` Date primitive.DateTime `bson:"date" json:"date"` ID primitive.ObjectID `bson:"_id,omitempty" json:"_id"` Amount float64 `bson:"amount" json:"amount"` }
This is the transaction struct which represents the transaction type in the database
func CreateTransaction ¶
func CreateTransaction( database *mongo.Database, name string, date primitive.DateTime, amount float64, category TransactionCategory, ) (Transaction, error)
Create a Transaction
func GetTransaction ¶
Retrieve a single Transaction by _id
func GetTransactionList ¶
func GetTransactionList(database *mongo.Database, filter *TransactionFilter) []Transaction
type TransactionCategory ¶
type TransactionCategory struct { Name string `bson:"name" json:"name"` Type CategoryType `bson:"type" json:"type"` ID primitive.ObjectID `bson:"_id,omitempty" json:"_id"` Active bool `bson:"active" json:"active"` }
This is the struct which represents a category
func CreateTransactionCategory ¶
func CreateTransactionCategory(database *mongo.Database, name string, catType CategoryType) (TransactionCategory, error)
Function to create a TransactionCategory from a string name and type
func GetActiveTransactionCategories ¶
func GetActiveTransactionCategories(database *mongo.Database) []TransactionCategory
func GetAllTransactionCategories ¶
func GetAllTransactionCategories(database *mongo.Database) []TransactionCategory
func GetInactiveTransactionCategories ¶
func GetInactiveTransactionCategories(database *mongo.Database) []TransactionCategory
func GetTransactionCategory ¶
func GetTransactionCategory(database *mongo.Database, id primitive.ObjectID) (TransactionCategory, error)
Function to retrieve a single TransactionCategory by ObjectID
func GetTransactionCategoryList ¶
func GetTransactionCategoryList(database *mongo.Database, filter bson.M) []TransactionCategory
Functions to retrieve lists of TransactionCategory objects from the database