services

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

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountManager

type AccountManager struct {
	AccountRepository     AccountRepositoryInterface
	AccountTypeRepository AccountTypeRepositoryInterface
}

func (*AccountManager) GetAccountNamesAndIDs

func (am *AccountManager) GetAccountNamesAndIDs() (result []AccountNameAndID, err error)

func (*AccountManager) GetAccountTypeByID

func (am *AccountManager) GetAccountTypeByID(id uint) (models.AccountType, error)

GetAccountTypeByID returns the account type for a given account ID If the account type is not found, it returns an error

Arguments: id - The ID of the account type to retrieve

Returns: - The account type object - An error if the account type is not found or if there was an error retrieving it

type AccountNameAndID

type AccountNameAndID struct {
	AccountName string
	AccountID   uint
}

type AccountNotFoundError

type AccountNotFoundError struct {
	AccountID uint
}

func (*AccountNotFoundError) Error

func (a *AccountNotFoundError) Error() string

type AccountRepositoryInterface

type AccountRepositoryInterface interface {
	GetAllAccounts() ([]models.Account, error)
}

type AccountTypeRepositoryInterface

type AccountTypeRepositoryInterface interface {
	GetAccountTypeByID(id uint) (models.AccountType, error)
}

type BalanceRepositoryInterface

type BalanceRepositoryInterface interface {
	Save(balance models.Balance) (uint, error)
}

type BankOfAmericaCreditCardCSVParser

type BankOfAmericaCreditCardCSVParser struct{}

func (BankOfAmericaCreditCardCSVParser) Parse

func (BankOfAmericaCreditCardCSVParser) Parse(statement string) (transactions []models.Transaction, balances []models.Balance, err error)

Parses CSVs with the header as the 1st row, date in 0th column, description in 2nd column, and amount in 4th column

type BudgetAndSpend

type BudgetAndSpend struct {
	ID           uint
	CategoryName string
	Amount       int
	Spend        int
	PercentUsed  int
	Month        time.Time
}

type BudgetRepositoryInterface

type BudgetRepositoryInterface interface {
	GetBudgetByID(id uint) (models.Budget, error)
	GetAllBudgets() ([]models.Budget, error)
}

type BudgetService

type BudgetService struct {
	BudgetRepository      BudgetRepositoryInterface
	CategoryRepository    CategoryRepositoryInterface
	TransactionRepository TransactionRepositoryInterface
}

func (*BudgetService) GetAllBudgetsAndCurrentSpend

func (bs *BudgetService) GetAllBudgetsAndCurrentSpend() (budgetsAndSpend []BudgetAndSpend, err error)

func (*BudgetService) GetBudgetAndMonthlySpend

func (bs *BudgetService) GetBudgetAndMonthlySpend(budgetID uint, numOfMonths int) (budgetsAndSpend []BudgetAndSpend, err error)

func (*BudgetService) GetMeanAndStandardDeviation

func (bs *BudgetService) GetMeanAndStandardDeviation(budgetID uint, numOfMonths int) (averageSpend int, standardDeviation int, err error)

type CapitalOneCreditCardCSVParser

type CapitalOneCreditCardCSVParser struct{}

func (CapitalOneCreditCardCSVParser) Parse

func (s CapitalOneCreditCardCSVParser) Parse(statement string) (transactions []models.Transaction, balances []models.Balance, err error)

Parses CSVs with the header as the 1st row, date in 0th column, description in 3rd column, category in 4th column, debits (purchases) in 5th column, credit (payments/refunds) amount in 6th column

type CapitalOneSavingsCSVParser

type CapitalOneSavingsCSVParser struct{}

func (CapitalOneSavingsCSVParser) Parse

func (s CapitalOneSavingsCSVParser) Parse(statement string) (transactions []models.Transaction, balances []models.Balance, err error)

Parses CSVs with the header as the 1st row, description in 1st column, date in 2nd column, transaction type (credit vs debit) in 3rd column, amount in 4th column, and balance in 5th column. Transactions are sorted by newest transaction first, so the balance is the first row after the header

type CashFlowData added in v1.2.0

type CashFlowData struct {
	TotalIncome   int
	TotalExpenses int
	Expenses      []ExpenseByCategory
}

type CashFlowService added in v1.2.0

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

func NewCashFlowService added in v1.2.0

func NewCashFlowService(tr *models.TransactionRepository) *CashFlowService

func (*CashFlowService) GetCashFlowData added in v1.2.0

func (s *CashFlowService) GetCashFlowData(ctx context.Context, startDate time.Time, endDate time.Time) (cashFlowData *CashFlowData, err error)

type CategorizerInterface

type CategorizerInterface interface {
	BuildModel() error
	CategorizeTransaction(txn *models.Transaction) (models.Category, error)
}

type Categorizes

type Categorizes interface {
	CategorizeTransaction(transaction *models.Transaction) (category models.Category, err error)
}

type CategoryRepositoryInterface

type CategoryRepositoryInterface interface {
	GetCategoryByID(id uint) (models.Category, error)
}

type ChaseCheckingCSVParser

type ChaseCheckingCSVParser struct{}

func (ChaseCheckingCSVParser) Parse

func (ChaseCheckingCSVParser) Parse(statement string) (transactions []models.Transaction, balances []models.Balance, err error)

Parses CSVs with the header as the 1st row, date in 1st column, description in 2nd column, and amount in 3rd column

type ChaseCreditCardCSVParser

type ChaseCreditCardCSVParser struct{}

func (ChaseCreditCardCSVParser) Parse

func (s ChaseCreditCardCSVParser) Parse(statement string) (transactions []models.Transaction, balances []models.Balance, err error)

Parses CSVs with the header as the 1st row, date in 0th column, description in 2nd column, and amount in 4th column

type ExpenseByCategory added in v1.2.0

type ExpenseByCategory struct {
	Name   string
	Amount int
}

type FidelityBrokerageCSVParser

type FidelityBrokerageCSVParser struct{}

func (FidelityBrokerageCSVParser) Parse

func (FidelityBrokerageCSVParser) Parse(statement string) (transactions []models.Transaction, balances []models.Balance, err error)

Parses CSVs with the header as the 2nd row, date in 0th column, description in 1st column, amount in 10th column, and balance in 11th column Transactions are sorted by newest transaction first, so the balance is the first row after the header

type FidelityCreditCardCSVParser

type FidelityCreditCardCSVParser struct{}

func (FidelityCreditCardCSVParser) Parse

func (FidelityCreditCardCSVParser) Parse(statement string) (transactions []models.Transaction, balances []models.Balance, err error)

Parses CSVs with the header as the 1st row, date in 0th column, description in 2nd column, and amount in 4th column

type GeneralCSVParser

type GeneralCSVParser struct{}

func (GeneralCSVParser) Parse

func (g GeneralCSVParser) Parse(statement string, dateCol int, descCol int, amountCol int, skipHeader bool, skipRecordLengthValidation bool) (transactions []models.Transaction, balances []models.Balance, err error)

type ImportAccountRepositoryInterface

type ImportAccountRepositoryInterface interface {
	GetAccountByID(id uint) (models.Account, error)
}

AccountRepositoryInterface specifically for ImportService

type ImportService

type ImportService struct {
	AccountRepository          ImportAccountRepositoryInterface
	BalanceRepository          BalanceRepositoryInterface
	Categorizer                CategorizerInterface
	ImportSubmissionRepository ImportSubmissionRepositoryInterface
	TransactionRepository      ImportTransactionRepositoryInterface
}

func (*ImportService) ImportStatement

func (is *ImportService) ImportStatement(filename string, statement string, accountID uint) (result *models.ImportSubmission, err error)

type ImportSubmissionRepositoryInterface

type ImportSubmissionRepositoryInterface interface {
	Save(sub models.ImportSubmission) (uint, error)
}

type ImportTransactionRepositoryInterface

type ImportTransactionRepositoryInterface interface {
	GetTransactionsByHash(hash string, submissionID uint) ([]models.Transaction, error)
	Save(txn models.Transaction) (uint, error)
}

TransactionRepositoryInterface specifically for ImportService

type MLCategorizer

type MLCategorizer struct {
	Bag                   *bag.Bag
	CategoryRepository    *models.CategoryRepository
	TransactionRepository *models.TransactionRepository
}

func (*MLCategorizer) BuildModel

func (mc *MLCategorizer) BuildModel() error

func (*MLCategorizer) CategorizeTransaction

func (mc *MLCategorizer) CategorizeTransaction(transaction *models.Transaction) (category models.Category, err error)

Should this return just the category name as a string, a category object, both, or something else?

type MockAccountRepository

type MockAccountRepository struct {
	Account  models.Account
	Accounts []models.Account
	Err      error
}

func (*MockAccountRepository) GetAccountByID

func (m *MockAccountRepository) GetAccountByID(id uint) (models.Account, error)

type MockBalanceRepository

type MockBalanceRepository struct {
	Saved []models.Balance
}

func (*MockBalanceRepository) Save

func (m *MockBalanceRepository) Save(balance models.Balance) (uint, error)

type MockCategorizer

type MockCategorizer struct {
	Category models.Category
	CatErr   error
	BuildErr error
}

func (*MockCategorizer) BuildModel

func (m *MockCategorizer) BuildModel() error

func (*MockCategorizer) CategorizeTransaction

func (m *MockCategorizer) CategorizeTransaction(txn *models.Transaction) (models.Category, error)

type MockCategoryRepository

type MockCategoryRepository struct {
	Category models.Category
	Err      error
}

type MockImportSubmissionRepository

type MockImportSubmissionRepository struct {
	Saved   []models.ImportSubmission
	SaveErr error
}

func (*MockImportSubmissionRepository) Save

type MockParser

type MockParser struct {
	Txns     []models.Transaction
	Balances []models.Balance
	ParseErr error
}

func (*MockParser) Parse

func (m *MockParser) Parse(statement string) ([]models.Transaction, []models.Balance, error)

type MockTransactionRepository

type MockTransactionRepository struct {
	Err        error
	SaveErr    error
	Sum        int
	Totals     []models.TotalByMonth
	TxnsByHash map[string][]models.Transaction
}

func (*MockTransactionRepository) GetTransactionsByHash

func (m *MockTransactionRepository) GetTransactionsByHash(hash string, submissionID uint) ([]models.Transaction, error)

func (*MockTransactionRepository) Save

type NoParserError

type NoParserError struct{}

func (*NoParserError) Error

func (*NoParserError) Error() string

type Parser

type Parser interface {
	Parse(string) ([]models.Transaction, []models.Balance, error)
}

type SchwabBrokerageCSVParser

type SchwabBrokerageCSVParser struct{}

func (SchwabBrokerageCSVParser) Parse

func (s SchwabBrokerageCSVParser) Parse(statement string) (transactions []models.Transaction, balances []models.Balance, err error)

Parses CSVs with the header as the 1st row, date in 0th column, action in 1st column, symbol in 2nd column, description in 3rd column, amount in 7th column,

type SchwabCheckingCSVParser

type SchwabCheckingCSVParser struct{}

func (SchwabCheckingCSVParser) Parse

func (s SchwabCheckingCSVParser) Parse(statement string) (transactions []models.Transaction, balances []models.Balance, err error)

Parses CSVs with the header as the 1st row, date in 0th column, description in 4th column, withdrawal amount in 5th column, deposit Amount in 6th column, and running balance in 7th column

type TargetCreditCardCSVParser

type TargetCreditCardCSVParser struct{}

func (TargetCreditCardCSVParser) Parse

func (s TargetCreditCardCSVParser) Parse(statement string) (transactions []models.Transaction, balances []models.Balance, err error)

Parses CSVs with the header as the 1st row, date in 0th column, posting date in 1st column, ref# in 2nd column (which we won't use), amount in 3rd column, description in 4th column, last 4 digits of card number in 5th column, and transaction type in 6th column. Transaction typ[e is either `Payment`, `Sale`, or `Refund`.

type TransactionRepositoryInterface

type TransactionRepositoryInterface interface {
	GetSumOfTransactionsByCategoryAndMonth(categoryID uint, startDate time.Time, endDate time.Time) ([]models.TotalByMonth, error)
	GetSumOfTransactionsByCategoryID(categoryID uint, startDate time.Time, endDate time.Time) (int, error)
}

type UWCUMortgageCSVParser

type UWCUMortgageCSVParser struct{}

func (UWCUMortgageCSVParser) Parse

func (s UWCUMortgageCSVParser) Parse(statement string) (transactions []models.Transaction, balances []models.Balance, err error)

Parses CSVs with the header as the 1st row, date in 2nd column, amount in 3rd column, description in 4th column, and balance in the 7th column. Transactions are sorted by newest transaction first, so the balance is the first row after the header

Jump to

Keyboard shortcuts

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