Documentation ¶
Index ¶
- Constants
- type Account
- type AccountOption
- type AccountType
- type GetTransactionsOptions
- type Model
- func (m *Model) AddAccount(acc Account)
- func (m *Model) AddTransaction(tr *Transaction) error
- func (m *Model) GetAccessToken(input string) (string, error)
- func (m *Model) GetAccount(input string) (Account, error)
- func (m *Model) GetAccountId(alias string) string
- func (m *Model) GetAccounts() []Account
- func (m *Model) GetAliases() map[string]string
- func (m *Model) GetCurrentBalance(accId string) (float64, error)
- func (m *Model) GetTransactionById(id string) (Transaction, error)
- func (m *Model) GetTransactionsByAccount(accId string, ops ...GetTransactionsOptions) ([]Transaction, error)
- func (m *Model) IsValidAccountAlias(input string) bool
- func (m *Model) IsValidAccountId(input string) bool
- func (m *Model) RemoveAccount(input string) error
- func (m *Model) RemoveTransaction(tr *Transaction) error
- func (m *Model) RemoveTransactionById(id string) error
- func (m *Model) RepairAccounts()
- func (m *Model) SetAlias(id string, alias string) error
- func (m *Model) SetAnchor(account string, anchor []string) error
- func (m *Model) UpdateTransaction(id string, ops ...UpdateTransactionOptions) error
- type Transaction
- type TransactionOption
- type UpdateTransactionOptions
- func WithAccountUpdate(accId string) UpdateTransactionOptions
- func WithAmountUpdate(amount float64) UpdateTransactionOptions
- func WithCategoryUpdate(category string) UpdateTransactionOptions
- func WithDateUpdate(date time.Time) UpdateTransactionOptions
- func WithDescUpdate(desc string) UpdateTransactionOptions
- func WithPayeeUpdate(payee string) UpdateTransactionOptions
Constants ¶
View Source
const ( UnknownAccount = "unknown" Checking = "checking" Savings = "savings" CreditCard = "creditCard" Investment = "investment" PersonalLoan = "personalLoan" )
View Source
const (
DbFilename = "oregano_data.db"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { // Unique identifier for account within this program. // May be copied from Plaid or generated by this program. // Required field. Id string `bun:",pk"` // English nickname for account within this program. // Optional field that defaults to empty string. Alias string `bun:",unique"` // Plaid generated key for getting data on this account. // Defaults to empty string if account was manually created. PlaidToken string Type AccountType // Transactions []*Transaction // The known value of this account at the time specified // in `AnchorTime`. Optional field that defaults to 0 AnchorBalance float64 `json:"AnchorBalance"` // The time specified for the known value `AnchorBalance`. // Optional field that defaults to time.Now() AnchorTime time.Time `json:"AnchorTime"` }
func NewAccount ¶
func NewAccount(options ...AccountOption) *Account
func (*Account) GetAnchorBalance ¶
func (*Account) GetAnchorTime ¶
func (*Account) LooseEquals ¶
type AccountOption ¶
type AccountOption func(*Account)
func WithAccountType ¶
func WithAccountType(accType AccountType) AccountOption
func WithAlias ¶
func WithAlias(alias string) AccountOption
func WithAnchor ¶
func WithAnchor(balance float64, time time.Time) AccountOption
func WithPlaidIds ¶
func WithPlaidIds(itemId string, accessToken string) AccountOption
type AccountType ¶
type AccountType string
func ParseAccountType ¶
func ParseAccountType(input string) (AccountType, error)
type GetTransactionsOptions ¶
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
func NewModelFromDB ¶
func (*Model) AddAccount ¶
func (*Model) AddTransaction ¶
func (m *Model) AddTransaction(tr *Transaction) error
func (*Model) GetAccessToken ¶
given a string that is an id or an alias, return the matching Account's PlaidToken
func (*Model) GetAccountId ¶
Given the alias for an account, return the id of that account. If alias does not exist, returns empty string
func (*Model) GetAccounts ¶
func (*Model) GetAliases ¶
func (*Model) GetTransactionById ¶
func (m *Model) GetTransactionById(id string) (Transaction, error)
func (*Model) GetTransactionsByAccount ¶
func (m *Model) GetTransactionsByAccount(accId string, ops ...GetTransactionsOptions) ([]Transaction, error)
func (*Model) IsValidAccountAlias ¶
func (*Model) IsValidAccountId ¶
func (*Model) RemoveAccount ¶
func (*Model) RemoveTransaction ¶
func (m *Model) RemoveTransaction(tr *Transaction) error
func (*Model) RemoveTransactionById ¶
func (*Model) RepairAccounts ¶
func (m *Model) RepairAccounts()
iterate over accounts, ensuring consistency in data
func (*Model) UpdateTransaction ¶
func (m *Model) UpdateTransaction(id string, ops ...UpdateTransactionOptions) error
type Transaction ¶
type Transaction struct { // Unique identifier for this transaction within // this application. Required field. Id string // The account belonging to the user which the money // is being pulled from. Required field. Assumed to be a valid alias AccountId string // The 'account' which money is being sent to, typically // a business. Required field. Payee string // The value of this transaction. A negative value indicates // money moving into the account. Note that this follows // the convention of a credit card, which is the opposite // convention of a savings account. Required field. Amount float64 // The date and time at which this transaction // took place. Required field which defaults to // current time in local time zone. Date time.Time // The category to which this transaction should be sorted // by. Optional field which defaults to empty string. // TODO: Details remain to be figured out for parent/sub- // categories and how they are parsed and stored Category string // The description assigned by the institution // typically will actually match the payee, with // some formatting that is not preferrable. // Optional field which defaults to empty string. InstDescription string // The description assigned by the user, to provide // specifics about this individual transaction. // Optional field which defaults to empty string. Description string }
A representation of a single transaction that took place between two accounts at a specific point in time
func NewTransaction ¶
func NewTransaction(accountId string, payee string, amount float64, options ...TransactionOption) *Transaction
func (*Transaction) LooseEquals ¶
func (t *Transaction) LooseEquals(other *Transaction) bool
Returns whether or not all fields, excepting uuid, match
func (*Transaction) String ¶
func (t *Transaction) String() string
type TransactionOption ¶
type TransactionOption func(*Transaction)
func WithCategory ¶
func WithCategory(category string) TransactionOption
func WithDate ¶
func WithDate(date time.Time) TransactionOption
func WithDescription ¶
func WithDescription(description string) TransactionOption
func WithInstDescription ¶
func WithInstDescription(instDescription string) TransactionOption
type UpdateTransactionOptions ¶
type UpdateTransactionOptions struct {
// contains filtered or unexported fields
}
func WithAccountUpdate ¶
func WithAccountUpdate(accId string) UpdateTransactionOptions
func WithAmountUpdate ¶
func WithAmountUpdate(amount float64) UpdateTransactionOptions
func WithCategoryUpdate ¶
func WithCategoryUpdate(category string) UpdateTransactionOptions
func WithDateUpdate ¶
func WithDateUpdate(date time.Time) UpdateTransactionOptions
func WithDescUpdate ¶
func WithDescUpdate(desc string) UpdateTransactionOptions
func WithPayeeUpdate ¶
func WithPayeeUpdate(payee string) UpdateTransactionOptions
Click to show internal directories.
Click to hide internal directories.