models

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const Asset = "asset"
View Source
const Completed string = "COMPLETED"
View Source
const Failed string = "FAILED"
View Source
const Liability = "liability"
View Source
const Processing string = "PROCESSING"
View Source
const Submitted string = "SUBMITTED"

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	gorm.Model
	Name          string
	AccountTypeID uint
	AccountType   AccountType
}

type AccountRepository

type AccountRepository struct {
	DB *gorm.DB
}

func (*AccountRepository) DeleteAccountByID

func (ar *AccountRepository) DeleteAccountByID(accountID uint) (err error)

Soft deletes an account and all associated transactions and balances

func (*AccountRepository) GetAccountByID

func (ar *AccountRepository) GetAccountByID(id uint) (Account, error)

func (*AccountRepository) GetAllAccounts

func (ar *AccountRepository) GetAllAccounts() ([]Account, error)

func (*AccountRepository) Save

func (ar *AccountRepository) Save(account Account) (id uint, err error)

Save is an UPSERT operation, returning the ID of the record and an optional error

type AccountType

type AccountType struct {
	gorm.Model
	Name            string  `gorm:"uniqueIndex"`
	LedgerType      string  // asset vs liability
	AccountCategory string  // checking, brokerage, credit card, loan, etc
	DefaultParser   *string // institution-specific parser for CSVs
}

type AccountTypeRepository

type AccountTypeRepository struct {
	DB *gorm.DB
}

func (*AccountTypeRepository) GetAccountTypeByID

func (atr *AccountTypeRepository) GetAccountTypeByID(id uint) (AccountType, error)

func (*AccountTypeRepository) GetAllAccountTypes

func (atr *AccountTypeRepository) GetAllAccountTypes() ([]AccountType, error)

type AverageByMonth

type AverageByMonth struct {
	Average int
	Month   time.Time
}

type Balance

type Balance struct {
	gorm.Model
	EffectiveDate      string
	Amount             int
	AccountID          uint
	Account            Account
	ImportSubmissionID *uint
	ImportSubmission   *ImportSubmission
}

type BalanceRepository

type BalanceRepository struct {
	DB *gorm.DB
}

func (*BalanceRepository) GetAllBalances

func (br *BalanceRepository) GetAllBalances(ctx context.Context) ([]Balance, error)

func (*BalanceRepository) GetBalanceByID

func (br *BalanceRepository) GetBalanceByID(ctx context.Context, balanceID uint) Balance

func (*BalanceRepository) GetBalancesByMonth

func (br *BalanceRepository) GetBalancesByMonth(ctx context.Context, ledgerType string, startYearMonth time.Time, endYearMonth time.Time) []BalancesWithDate

func (*BalanceRepository) GetBalancesForAccount

func (br *BalanceRepository) GetBalancesForAccount(ctx context.Context, accountID uint) []Balance

func (*BalanceRepository) GetBalancesOfAllAssetsByMonth

func (br *BalanceRepository) GetBalancesOfAllAssetsByMonth(ctx context.Context, startYearMonth time.Time, endYearMonth time.Time) []BalancesWithDate

func (*BalanceRepository) GetBalancesOfAllLiabilitiesByMonth

func (br *BalanceRepository) GetBalancesOfAllLiabilitiesByMonth(ctx context.Context, startYearMonth time.Time, endYearMonth time.Time) []BalancesWithDate

func (*BalanceRepository) GetLatestBalanceForAccount

func (br *BalanceRepository) GetLatestBalanceForAccount(ctx context.Context, accountID uint) (balance Balance, err error)

func (*BalanceRepository) Save

func (br *BalanceRepository) Save(balance Balance) (id uint, err error)

Save is an UPSERT operation, returning the ID of the record and an optional error

type BalancesWithDate

type BalancesWithDate struct {
	Date     time.Time
	Balances []Balance
}

type Bootstrapper

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

func NewBootstrapper

func NewBootstrapper(db *gorm.DB) *Bootstrapper

func (*Bootstrapper) BootstrapDatabase

func (b *Bootstrapper) BootstrapDatabase(ctx context.Context)

type Budget

type Budget struct {
	gorm.Model
	Amount     int
	CategoryID uint
	Category   Category
}

type BudgetRepository

type BudgetRepository struct {
	DB *gorm.DB
}

func (*BudgetRepository) DeleteByID

func (br *BudgetRepository) DeleteByID(budgetID uint) (err error)

func (*BudgetRepository) GetAllBudgets

func (*BudgetRepository) GetAllBudgets() ([]Budget, error)

func (*BudgetRepository) GetBudgetByID

func (*BudgetRepository) GetBudgetByID(id uint) (Budget, error)

func (*BudgetRepository) Save

func (*BudgetRepository) Save(budget Budget) (id uint, err error)

Save is an UPSERT operation, returning the ID of the record and an optional error

type Category

type Category struct {
	gorm.Model
	Name string `gorm:"uniqueIndex"`
}

type CategoryAndBudgetStatus

type CategoryAndBudgetStatus struct {
	Category
	HasBudget bool
}

type CategoryRepository

type CategoryRepository struct {
	DB *gorm.DB
}

func (*CategoryRepository) DeleteCategoryByID

func (cr *CategoryRepository) DeleteCategoryByID(categoryID uint) (err error)

Soft deletes a category and sets all associated transactions to Unknown

func (*CategoryRepository) GetAllCategories

func (cr *CategoryRepository) GetAllCategories() ([]Category, error)

func (*CategoryRepository) GetAllCategoriesAndBudgetStatus

func (cr *CategoryRepository) GetAllCategoriesAndBudgetStatus() (categories []CategoryAndBudgetStatus, err error)

func (*CategoryRepository) GetCategoryByID

func (cr *CategoryRepository) GetCategoryByID(id uint) (Category, error)

func (*CategoryRepository) GetCategoryByName

func (cr *CategoryRepository) GetCategoryByName(name string) (Category, error)

func (*CategoryRepository) Save

func (cr *CategoryRepository) Save(category Category) (id uint, err error)

Save is an UPSERT operation, returning the ID of the record and an optional error

type ImportSubmission

type ImportSubmission struct {
	gorm.Model
	FileName             string
	SubmissionDateTime   string
	Status               string
	AccountType          string
	TransactionsImported int
	TransactionsSkipped  int
	BalancesImported     int
	BalancesSkipped      int
	AccountID            uint
	Account              Account
}

type ImportSubmissionRepository

type ImportSubmissionRepository struct {
	DB *gorm.DB
}

func (*ImportSubmissionRepository) Save

func (isr *ImportSubmissionRepository) Save(submission ImportSubmission) (id uint, err error)

Save is an UPSERT operation, returning the ID of the record and an optional error

type NetIncomeDataByDate

type NetIncomeDataByDate struct {
	Date      time.Time `gorm:"type:time"`
	NetIncome int
	Income    int
	Expenses  int
}

type Settings added in v1.1.0

type Settings struct {
	gorm.Model
	LaunchBrowserOnStartup bool `gorm:"default:true"`
}

type SettingsRepository added in v1.1.0

type SettingsRepository struct {
	DB *gorm.DB
}

func (*SettingsRepository) GetSettings added in v1.1.0

func (sr *SettingsRepository) GetSettings() (settings *Settings, err error)

func (*SettingsRepository) PopulateSettings added in v1.1.0

func (sr *SettingsRepository) PopulateSettings() (err error)

func (*SettingsRepository) Save added in v1.1.0

func (sr *SettingsRepository) Save(settings *Settings) (err error)

Save is an UPSERT operation, returning the ID of the record and an optional error

type TTMAverageByDate

type TTMAverageByDate struct {
	Date       time.Time
	TTMAverage int
}

type TotalByCategory

type TotalByCategory struct {
	Amount   int
	Category string
}

type TotalByMonth

type TotalByMonth struct {
	Amount int
	Month  time.Time
}

type Transaction

type Transaction struct {
	gorm.Model
	Date               string
	Description        string
	Amount             int
	Excluded           bool // Will be stored as 0 or 1 in SQLite
	Hash               string
	UseForTraining     bool
	AccountID          uint
	Account            Account
	CategoryID         uint
	Category           Category
	ImportSubmissionID *uint
	ImportSubmission   *ImportSubmission
}

type TransactionRepository

type TransactionRepository struct {
	DB *gorm.DB
}

func (*TransactionRepository) Create

func (tr *TransactionRepository) Create(txn *Transaction) error

func (*TransactionRepository) DeleteTransactionByID

func (tr *TransactionRepository) DeleteTransactionByID(ctx context.Context, id uint) (err error)

Soft deletes a transaction

func (*TransactionRepository) GetAllTransactions

func (tr *TransactionRepository) GetAllTransactions(accountID uint, categoryID uint, description string, startDate *time.Time, endDate *time.Time) ([]Transaction, error)

func (*TransactionRepository) GetLatestTransactionForAccount

func (tr *TransactionRepository) GetLatestTransactionForAccount(accountID uint) (txn Transaction, err error)

func (*TransactionRepository) GetNetIncomeTotalsByDate

func (tr *TransactionRepository) GetNetIncomeTotalsByDate(ctx context.Context, startYearMonth time.Time, endYearMonth time.Time) (NITByDate []NetIncomeDataByDate, err error)

func (*TransactionRepository) GetSumOfTransactionsByCategory

func (tr *TransactionRepository) GetSumOfTransactionsByCategory(startDate time.Time, endDate time.Time) (totals []TotalByCategory, err error)

func (*TransactionRepository) GetSumOfTransactionsByCategoryAndMonth

func (tr *TransactionRepository) GetSumOfTransactionsByCategoryAndMonth(categoryID uint, startDate time.Time, endDate time.Time) (totals []TotalByMonth, err error)

func (*TransactionRepository) GetSumOfTransactionsByCategoryID

func (tr *TransactionRepository) GetSumOfTransactionsByCategoryID(categoryID uint, startDate time.Time, endDate time.Time) (int, error)

func (*TransactionRepository) GetTTMStatistics

func (tr *TransactionRepository) GetTTMStatistics(ctx context.Context, yearMonth time.Time) (average int, twentyFifthPercentile int, seventyFifthPercentile int, err error)

func (*TransactionRepository) GetTransactionByID

func (tr *TransactionRepository) GetTransactionByID(id uint) (Transaction, error)

func (*TransactionRepository) GetTransactionsByHash

func (tr *TransactionRepository) GetTransactionsByHash(hash string, submissionID uint) ([]Transaction, error)

func (*TransactionRepository) GetTransactionsByImportSubmission

func (tr *TransactionRepository) GetTransactionsByImportSubmission(id uint) ([]Transaction, error)

func (*TransactionRepository) GetTransactionsForTraining

func (tr *TransactionRepository) GetTransactionsForTraining() ([]Transaction, error)

func (*TransactionRepository) Save

func (tr *TransactionRepository) Save(txn Transaction) (id uint, err error)

Save is an UPSERT operation, returning the ID of the record and an optional error

type TransactionsByDate

type TransactionsByDate struct {
	Date         time.Time
	Transactions []Transaction
}

Jump to

Keyboard shortcuts

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