omoney

package
v0.0.0-...-a480952 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

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) GetAnchor

func (acc *Account) GetAnchor() (float64, time.Time)

func (*Account) GetAnchorBalance

func (acc *Account) GetAnchorBalance() float64

func (*Account) GetAnchorTime

func (acc *Account) GetAnchorTime() time.Time

func (*Account) LooseEquals

func (a *Account) LooseEquals(other *Account) bool

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 GetTransactionsOptions struct {
	Count     int
	StartDate *time.Time
	EndDate   *time.Time
}

type Model

type Model struct {
	// contains filtered or unexported fields
}

func NewModelFromDB

func NewModelFromDB(filepath string) (*Model, error)

func (*Model) AddAccount

func (m *Model) AddAccount(acc Account)

func (*Model) AddTransaction

func (m *Model) AddTransaction(tr *Transaction) error

func (*Model) GetAccessToken

func (m *Model) GetAccessToken(input string) (string, error)

given a string that is an id or an alias, return the matching Account's PlaidToken

func (*Model) GetAccount

func (m *Model) GetAccount(input string) (Account, error)

func (*Model) GetAccountId

func (m *Model) GetAccountId(alias string) string

Given the alias for an account, return the id of that account. If alias does not exist, returns empty string

func (*Model) GetAccounts

func (m *Model) GetAccounts() []Account

func (*Model) GetAliases

func (m *Model) GetAliases() map[string]string

func (*Model) GetCurrentBalance

func (m *Model) GetCurrentBalance(accId string) (float64, error)

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 (m *Model) IsValidAccountAlias(input string) bool

func (*Model) IsValidAccountId

func (m *Model) IsValidAccountId(input string) bool

func (*Model) RemoveAccount

func (m *Model) RemoveAccount(input string) error

func (*Model) RemoveTransaction

func (m *Model) RemoveTransaction(tr *Transaction) error

func (*Model) RemoveTransactionById

func (m *Model) RemoveTransactionById(id string) error

func (*Model) RepairAccounts

func (m *Model) RepairAccounts()

iterate over accounts, ensuring consistency in data

func (*Model) SetAlias

func (m *Model) SetAlias(id string, alias string) error

func (*Model) SetAnchor

func (m *Model) SetAnchor(account string, anchor []string) error

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL