Documentation
¶
Overview ¶
Package findb contains the persistence layer for the fin package.
Index ¶
- Variables
- func ApplyRecurringEntries(t db.Transaction, store RecurringEntriesApplier, acctId int64, ...) (int, error)
- func ApplyRecurringEntriesDryRun(t db.Transaction, store RecurringEntriesRunner, acctId int64, ...) (int, error)
- func ApplyRecurringEntry(t db.Transaction, store RecurringEntryApplier, id int64) (bool, error)
- func EntriesByAccountId(t db.Transaction, store EntriesByAccountIdRunner, acctId int64, ...) error
- func LoginUser(t db.Transaction, store UpdateUserByNameRunner, userName string, ...) error
- func SkipRecurringEntry(t db.Transaction, store RecurringEntrySkipper, id int64) (bool, error)
- func UnreconciledEntries(t db.Transaction, store EntriesByAccountIdRunner, acctId int64, ...) error
- type AccountByIdRunner
- type AccountsRunner
- type ActiveAccountsRunner
- type AddAccountRunner
- type AddAllocationRunner
- type AddRecurringEntryRunner
- type AddUserRunner
- type AllocationsByYearRunner
- type DoEntryChangesRunner
- type EntriesByAccountIdRunner
- type EntriesRunner
- type EntryByIdRunner
- type EntryChanges
- type EntryListOptions
- type NoPermissionStore
- func (n NoPermissionStore) AccountById(t db.Transaction, acctId int64, account *fin.Account) error
- func (n NoPermissionStore) Accounts(t db.Transaction, consumer consume2.Consumer[fin.Account]) error
- func (n NoPermissionStore) ActiveAccounts(t db.Transaction) (accounts []*fin.Account, err error)
- func (n NoPermissionStore) AddAccount(t db.Transaction, Account *fin.Account) error
- func (n NoPermissionStore) AddAllocation(t db.Transaction, year, expenseId, amount int64) error
- func (n NoPermissionStore) AddRecurringEntry(t db.Transaction, entry *fin.RecurringEntry) error
- func (n NoPermissionStore) AddUser(t db.Transaction, user *fin.User) error
- func (n NoPermissionStore) AllocationsByYear(t db.Transaction, year int64) (map[int64]int64, error)
- func (n NoPermissionStore) DoEntryChanges(t db.Transaction, changes *EntryChanges) error
- func (n NoPermissionStore) Entries(t db.Transaction, options *EntryListOptions, ...) error
- func (n NoPermissionStore) EntryById(t db.Transaction, id int64, entry *fin.Entry) error
- func (n NoPermissionStore) RecurringEntries(t db.Transaction, consumer consume2.Consumer[fin.RecurringEntry]) error
- func (n NoPermissionStore) RecurringEntryById(t db.Transaction, id int64, entry *fin.RecurringEntry) error
- func (n NoPermissionStore) RemoveAccount(t db.Transaction, accountId int64) error
- func (n NoPermissionStore) RemoveAllocation(t db.Transaction, year, expenseId int64) error
- func (n NoPermissionStore) RemoveRecurringEntryById(t db.Transaction, id int64) error
- func (n NoPermissionStore) RemoveUserByName(t db.Transaction, name string) error
- func (n NoPermissionStore) UpdateAccount(t db.Transaction, account *fin.Account) error
- func (n NoPermissionStore) UpdateAccountImportSD(t db.Transaction, accountId int64, date time.Time) error
- func (n NoPermissionStore) UpdateRecurringEntry(t db.Transaction, entry *fin.RecurringEntry) error
- func (n NoPermissionStore) UpdateUser(t db.Transaction, user *fin.User) error
- func (n NoPermissionStore) UserById(t db.Transaction, id int64, user *fin.User) error
- func (n NoPermissionStore) UserByName(t db.Transaction, name string, user *fin.User) error
- func (n NoPermissionStore) Users(t db.Transaction, consumer consume2.Consumer[fin.User]) error
- type RecurringEntriesApplier
- type RecurringEntriesRunner
- type RecurringEntryApplier
- type RecurringEntryByIdRunner
- type RecurringEntrySkipper
- type RemoveAccountRunner
- type RemoveAllocationRunner
- type RemoveRecurringEntryByIdRunner
- type RemoveUserByNameRunner
- type UpdateAccountImportSDRunner
- type UpdateAccountRunner
- type UpdateRecurringEntryRunner
- type UpdateUserByNameRunner
- type UpdateUserRunner
- type UserByIdRunner
- type UserByNameRunner
- type UsersRunner
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func ApplyRecurringEntries ¶
func ApplyRecurringEntries( t db.Transaction, store RecurringEntriesApplier, acctId int64, currentDate time.Time) (int, error)
ApplyRecurringEntries applies all outstanding recurring entries and returns how many new entries were added to the database as a result. If there are no outstanding recurring entries, this function does nothing and returns 0. Note that ApplyRecurringEntries is idempotent. t is the database transaction and must be non-nil. store is the database store. If acctId is non-zero, ApplyRecurringEntries applies only the outstanding recurring entries pertaining to that account. currentDate is the current date.
func ApplyRecurringEntriesDryRun ¶
func ApplyRecurringEntriesDryRun( t db.Transaction, store RecurringEntriesRunner, acctId int64, currentDate time.Time) (int, error)
ApplyRecurringEntriesDryRun returns out how many new entries would be added to the database if ApplyRecurringEntries were run. t is the database transaction. store is the database store. If acctId is non-zero, ApplyRecurringEntriesDryRun considers only the outstanding recurring entries pertaining to that account. currentDate is the current date.
func ApplyRecurringEntry ¶
func ApplyRecurringEntry( t db.Transaction, store RecurringEntryApplier, id int64) (bool, error)
ApplyRecurringEntry advances the recurring entry with given id creating one new entry for it. t is the database transaction and must be non-nil. Returns true if the entry was applied or false if the NumLeft field has already reached 0.
func EntriesByAccountId ¶
func EntriesByAccountId( t db.Transaction, store EntriesByAccountIdRunner, acctId int64, account *fin.Account, consumer consume2.Consumer[fin.EntryBalance]) error
EntriesByAccountId gets entries by account id from most to least recent. acctId is the account ID; account, which can be nil, is where Account object is stored; consumer consumes the fin.EntryBalance values. t must be non-nil.
func LoginUser ¶
func LoginUser( t db.Transaction, store UpdateUserByNameRunner, userName string, password string, currentTime time.Time, user *fin.User) error
LoginUser logs in a user. Caller responsible for setting any cookies resulting from login. On success, LoginUser sets logged in user at user. If userName is wrong, LoginUser returns NoSuchId. If password is wrong, LoginUser returns WrongPassword.
func SkipRecurringEntry ¶
func SkipRecurringEntry( t db.Transaction, store RecurringEntrySkipper, id int64) (bool, error)
SkipRecurringEntry advances the recurring entry with given id without creating a new entry for it. t is the database transaction and must be non-nil. Returns true if the entry was skipped or false if the NumLeft field has already reached 0.
func UnreconciledEntries ¶
func UnreconciledEntries( t db.Transaction, store EntriesByAccountIdRunner, acctId int64, account *fin.Account, consumer consume2.Consumer[fin.Entry]) error
UnreconciledEntries gets unreconciled entries by account Id from most to least recent. t is the database transaction and must be non-nil; store is the database store; acctId is the account ID; account, which can be nil, is where Account object is stored; consumer consumes the fin.Entry values.
Types ¶
type AccountByIdRunner ¶
type AccountsRunner ¶
type ActiveAccountsRunner ¶
type ActiveAccountsRunner interface { // ActiveAccounts fetches all active accounts sorted by name. ActiveAccounts(t db.Transaction) (accounts []*fin.Account, err error) }
type AddAccountRunner ¶
type AddAccountRunner interface { // AddAccount adds a new account. AddAccount(t db.Transaction, Account *fin.Account) error }
type AddAllocationRunner ¶
type AddAllocationRunner interface { // AddAllocation adds an envelope allocation. AddAllocation(t db.Transaction, year, expenseId, amount int64) error }
type AddRecurringEntryRunner ¶
type AddRecurringEntryRunner interface { // AddRecurringEntry adds a new recurring entry. AddRecurringEntry(t db.Transaction, entry *fin.RecurringEntry) error }
type AddUserRunner ¶
type AddUserRunner interface { // AddUser adds a new user. AddUser(t db.Transaction, user *fin.User) error }
type AllocationsByYearRunner ¶
type AllocationsByYearRunner interface { // AllocationsByYear returns the envelope allocations by year. In the // returned map, the keys are the expenseIds, and the values are the // allocations in pennies. Note that expenseId=4 corresponds to catId=0:4 AllocationsByYear(t db.Transaction, year int64) (map[int64]int64, error) }
type DoEntryChangesRunner ¶
type DoEntryChangesRunner interface { // DoEntryChanges adds, updates, and deletes entries in bulk. DoEntryChanges(t db.Transaction, changes *EntryChanges) error }
type EntriesByAccountIdRunner ¶
type EntriesByAccountIdRunner interface { EntriesRunner AccountByIdRunner }
type EntriesRunner ¶
type EntriesRunner interface { // Entries gets entries from most to least recent. // options is additional options for getting entries, may be nil; // consumer consumes the fin.Entry values. If // options.Unreviewed == true, then Entries computes the etag for // each fetched entry. Entries(t db.Transaction, options *EntryListOptions, consumer consume2.Consumer[fin.Entry]) error }
type EntryByIdRunner ¶
type EntryChanges ¶
type EntryChanges struct { // Adds is entries to add Adds []*fin.Entry // The key is the entry id; the value does the update in-place. Updates map[int64]fin.EntryUpdater // Deletes is the ids of the entries to delete. Deletes []int64 // It is used to detect concurrent updates. // The key is the entry id; the value is the etag of the original entry. // This field is optional, but if present it must contain the etag of // each entry being updated. Etags map[int64]uint64 }
EntryChanges represents changes to entries.
type EntryListOptions ¶
type EntryListOptions struct { // If set, entries listed are on or after this date. Start *time.Time // If set, entries listed are before this date End *time.Time // If true, show only unreviewed entries Unreviewed bool }
EntryListOptions represents options to list entries.
type NoPermissionStore ¶
type NoPermissionStore struct { }
NoPermissionStore always returns NoPermissionError
func (NoPermissionStore) AccountById ¶
func (n NoPermissionStore) AccountById( t db.Transaction, acctId int64, account *fin.Account) error
func (NoPermissionStore) Accounts ¶
func (n NoPermissionStore) Accounts( t db.Transaction, consumer consume2.Consumer[fin.Account]) error
func (NoPermissionStore) ActiveAccounts ¶
func (n NoPermissionStore) ActiveAccounts( t db.Transaction) (accounts []*fin.Account, err error)
func (NoPermissionStore) AddAccount ¶
func (n NoPermissionStore) AddAccount( t db.Transaction, Account *fin.Account) error
func (NoPermissionStore) AddAllocation ¶
func (n NoPermissionStore) AddAllocation( t db.Transaction, year, expenseId, amount int64) error
func (NoPermissionStore) AddRecurringEntry ¶
func (n NoPermissionStore) AddRecurringEntry( t db.Transaction, entry *fin.RecurringEntry) error
func (NoPermissionStore) AddUser ¶
func (n NoPermissionStore) AddUser(t db.Transaction, user *fin.User) error
func (NoPermissionStore) AllocationsByYear ¶
func (n NoPermissionStore) AllocationsByYear(t db.Transaction, year int64) ( map[int64]int64, error)
func (NoPermissionStore) DoEntryChanges ¶
func (n NoPermissionStore) DoEntryChanges( t db.Transaction, changes *EntryChanges) error
func (NoPermissionStore) Entries ¶
func (n NoPermissionStore) Entries(t db.Transaction, options *EntryListOptions, consumer consume2.Consumer[fin.Entry]) error
func (NoPermissionStore) EntryById ¶
func (n NoPermissionStore) EntryById( t db.Transaction, id int64, entry *fin.Entry) error
func (NoPermissionStore) RecurringEntries ¶
func (n NoPermissionStore) RecurringEntries( t db.Transaction, consumer consume2.Consumer[fin.RecurringEntry]) error
func (NoPermissionStore) RecurringEntryById ¶
func (n NoPermissionStore) RecurringEntryById( t db.Transaction, id int64, entry *fin.RecurringEntry) error
func (NoPermissionStore) RemoveAccount ¶
func (n NoPermissionStore) RemoveAccount( t db.Transaction, accountId int64) error
func (NoPermissionStore) RemoveAllocation ¶
func (n NoPermissionStore) RemoveAllocation( t db.Transaction, year, expenseId int64) error
func (NoPermissionStore) RemoveRecurringEntryById ¶
func (n NoPermissionStore) RemoveRecurringEntryById( t db.Transaction, id int64) error
func (NoPermissionStore) RemoveUserByName ¶
func (n NoPermissionStore) RemoveUserByName(t db.Transaction, name string) error
func (NoPermissionStore) UpdateAccount ¶
func (n NoPermissionStore) UpdateAccount( t db.Transaction, account *fin.Account) error
func (NoPermissionStore) UpdateAccountImportSD ¶
func (n NoPermissionStore) UpdateAccountImportSD( t db.Transaction, accountId int64, date time.Time) error
func (NoPermissionStore) UpdateRecurringEntry ¶
func (n NoPermissionStore) UpdateRecurringEntry( t db.Transaction, entry *fin.RecurringEntry) error
func (NoPermissionStore) UpdateUser ¶
func (n NoPermissionStore) UpdateUser(t db.Transaction, user *fin.User) error
func (NoPermissionStore) UserById ¶
func (n NoPermissionStore) UserById(t db.Transaction, id int64, user *fin.User) error
func (NoPermissionStore) UserByName ¶
func (n NoPermissionStore) UserByName(t db.Transaction, name string, user *fin.User) error
func (NoPermissionStore) Users ¶
func (n NoPermissionStore) Users( t db.Transaction, consumer consume2.Consumer[fin.User]) error
type RecurringEntriesApplier ¶
type RecurringEntriesApplier interface { DoEntryChangesRunner UpdateRecurringEntryRunner RecurringEntriesRunner }
type RecurringEntriesRunner ¶
type RecurringEntriesRunner interface { // RecurringEntries gets all the recurring entries sorted by date // in ascending order. RecurringEntries( t db.Transaction, consumer consume2.Consumer[fin.RecurringEntry]) error }
type RecurringEntryApplier ¶
type RecurringEntryApplier interface { DoEntryChangesRunner UpdateRecurringEntryRunner RecurringEntryByIdRunner }
type RecurringEntryByIdRunner ¶
type RecurringEntryByIdRunner interface { // RecurringEntryById gets a recurring entry by id. RecurringEntryById( t db.Transaction, id int64, entry *fin.RecurringEntry) error }
type RecurringEntrySkipper ¶
type RecurringEntrySkipper interface { RecurringEntryByIdRunner UpdateRecurringEntryRunner }
type RemoveAccountRunner ¶
type RemoveAccountRunner interface { // RemoveAccount removes an account. RemoveAccount(t db.Transaction, accountId int64) error }
type RemoveAllocationRunner ¶
type RemoveAllocationRunner interface { // RemoveAllocation removes an envelope allocation. RemoveAllocation(t db.Transaction, year, expenseId int64) error }
type RemoveRecurringEntryByIdRunner ¶
type RemoveRecurringEntryByIdRunner interface { // RemoveRecurringEntryById removes a recurring entry by id. RemoveRecurringEntryById(t db.Transaction, id int64) error }
type RemoveUserByNameRunner ¶
type RemoveUserByNameRunner interface { // RemoveUserByName removes a user by name. RemoveUserByName(t db.Transaction, name string) error }
type UpdateAccountRunner ¶
type UpdateAccountRunner interface { // UpdateAccount updates an account. UpdateAccount( t db.Transaction, account *fin.Account) error }
type UpdateRecurringEntryRunner ¶
type UpdateRecurringEntryRunner interface { // UpdateRecurringEntry updates a recurring entry. UpdateRecurringEntry(t db.Transaction, entry *fin.RecurringEntry) error }
type UpdateUserByNameRunner ¶
type UpdateUserByNameRunner interface { UserByNameRunner UpdateUserRunner }
type UpdateUserRunner ¶
type UpdateUserRunner interface { // UpdateUser updates a user. UpdateUser(t db.Transaction, user *fin.User) error }
type UserByIdRunner ¶
type UserByNameRunner ¶
type UsersRunner ¶
Directories
¶
Path | Synopsis |
---|---|
Package fixture provides test suites to test implementations of the interfaces in the findb package.
|
Package fixture provides test suites to test implementations of the interfaces in the findb package. |
Package for_sqlite stores types in fin package in a sqlite database.
|
Package for_sqlite stores types in fin package in a sqlite database. |
Package sqlite_setup sets up a sqlite database for personal finance.
|
Package sqlite_setup sets up a sqlite database for personal finance. |